|
| 1 | +import eslint from '@eslint/js' |
| 2 | +import globals from 'globals' |
| 3 | +import perfectionist from 'eslint-plugin-perfectionist' |
| 4 | +import stylistic from '@stylistic/eslint-plugin' |
| 5 | +import typescript from 'typescript-eslint' |
| 6 | +import vue from 'eslint-plugin-vue' |
| 7 | + |
| 8 | +const jsRules = { |
| 9 | + '@stylistic/js/array-bracket-spacing': ['warn', 'always'], |
| 10 | + '@stylistic/js/arrow-parens': [2, "as-needed", { "requireForBlockBody": true }], |
| 11 | + '@stylistic/js/block-spacing': ['warn', 'always'], |
| 12 | + '@stylistic/js/brace-style': ['warn', 'stroustrup', { 'allowSingleLine': false }], |
| 13 | + '@stylistic/js/comma-dangle': [ |
| 14 | + 'error', |
| 15 | + { |
| 16 | + "arrays": "always-multiline", |
| 17 | + "exports": "always-multiline", |
| 18 | + "functions": "never", |
| 19 | + "imports": "always-multiline", |
| 20 | + "objects": "always-multiline", |
| 21 | + }, |
| 22 | + ], |
| 23 | + '@stylistic/js/consistent-return': 'off', |
| 24 | + '@stylistic/js/eol-last': ['error', 'always'], |
| 25 | + '@stylistic/js/indent': ['error', 8, { 'ignoreComments': false, 'MemberExpression': 1, 'SwitchCase': 1 }], |
| 26 | + '@stylistic/js/keyword-spacing': 'error', |
| 27 | + '@stylistic/js/linebreak-style': ['error', 'unix'], |
| 28 | + '@stylistic/js/max-len': ['warn', { code: 120, 'ignoreStrings': true }], |
| 29 | + '@stylistic/js/multiline-ternary': ['warn', 'always'], |
| 30 | + '@stylistic/js/no-console': 'off', |
| 31 | + '@stylistic/js/no-debugger': process.env.NODE_ENV === 'production' |
| 32 | + ? 'warn' |
| 33 | + : 'off', |
| 34 | + '@stylistic/js/no-plusplus': 'off', |
| 35 | + '@stylistic/js/no-restricted-globals': 'off', |
| 36 | + '@stylistic/js/object-curly-spacing': ['error', 'always'], |
| 37 | + '@stylistic/js/semi': ['error', 'always'], |
| 38 | + '@stylistic/js/space-before-blocks': ['warn', 'always'], |
| 39 | + '@stylistic/js/space-before-function-paren': ['warn', 'always'], |
| 40 | + 'arrow-body-style': ['warn', 'always'], |
| 41 | + 'curly': 'error', |
| 42 | + 'no-param-reassign': 'error', |
| 43 | + 'no-return-assign': ['error', 'except-parens'], |
| 44 | + 'no-unused-vars': 'off', |
| 45 | + 'no-useless-escape': 'warn', |
| 46 | + 'prefer-object-spread': 'error', |
| 47 | +}; |
| 48 | +const tsRules = { |
| 49 | + ...jsRules, |
| 50 | + '@stylistic/ts/no-unused-vars': 'off', |
| 51 | + 'perfectionist/sort-imports': ['off', { |
| 52 | + groups: [ |
| 53 | + ['builtin', 'external'], |
| 54 | + ['internal'], |
| 55 | + ['parent', 'siblings', 'side-effect'], |
| 56 | + ['side-effect-style'], |
| 57 | + ], |
| 58 | + 'newlines-between': 'ignore', |
| 59 | + }], |
| 60 | + 'perfectionist/sort-vue-attributes': 'off', |
| 61 | +} |
| 62 | +const vueRules = { |
| 63 | + '@stylistic/js/indent': 'off', // Turn off in favor of 'vue/script-indent' |
| 64 | + 'vue/attributes-order': 'off', |
| 65 | + 'vue/html-indent': ['error', 4, { |
| 66 | + 'attribute': 1, |
| 67 | + 'alignAttributesVertically': true, |
| 68 | + 'baseIndent': 1, |
| 69 | + }], |
| 70 | + 'vue/html-closing-bracket-newline': ['error', { |
| 71 | + 'singleline': 'never', |
| 72 | + 'multiline': 'always', |
| 73 | + "selfClosingTag": { |
| 74 | + "singleline": "never", |
| 75 | + "multiline": "always" |
| 76 | + } |
| 77 | + }], |
| 78 | + 'vue/multi-word-component-names': 'off', |
| 79 | + 'vue/no-side-effects-in-computed-properties': 'warn', |
| 80 | + 'vue/no-v-html': 'warn', // Warn (where we're using it, it is safe) |
| 81 | + 'vue/script-indent': ['error', 4, { |
| 82 | + 'baseIndent': 0, |
| 83 | + }], |
| 84 | + 'vue/singleline-html-element-content-newline': 'off', |
| 85 | + 'vue/valid-template-root': 'off', |
| 86 | + 'vue/valid-v-for': 'off', |
| 87 | +} |
| 88 | +const globalConfig = { |
| 89 | + ignores: [ |
| 90 | + '**/dist/**/*', |
| 91 | + '**/node_modules/**/*', |
| 92 | + ], |
| 93 | + languageOptions: { |
| 94 | + ecmaVersion: 2022, |
| 95 | + globals: { |
| 96 | + ...globals.browser, |
| 97 | + }, |
| 98 | + sourceType: 'module', |
| 99 | + }, |
| 100 | +}; |
| 101 | +const tsConfig = { |
| 102 | + ...eslint.configs.recommended, |
| 103 | + ...typescript.configs.recommended, |
| 104 | + ...vue.configs['flat/recommended'], |
| 105 | + files: [ "**/*.{js,mjs,cjs,ts,vue" ], |
| 106 | + ignores: [ |
| 107 | + "**/cypress", |
| 108 | + '*.d.ts', |
| 109 | + '**/coverage', |
| 110 | + '**/dist', |
| 111 | + '*.config.{js,ts}', |
| 112 | + ], |
| 113 | + languageOptions: { |
| 114 | + ecmaVersion: 2022, |
| 115 | + globals: globals.browser, |
| 116 | + parserOptions: { |
| 117 | + parser: typescript.parser, |
| 118 | + }, |
| 119 | + sourceType: "module", |
| 120 | + }, |
| 121 | + plugins: { |
| 122 | + perfectionist, |
| 123 | + '@stylistic': stylistic, |
| 124 | + }, |
| 125 | + // rules: { |
| 126 | + // ...tsRules, |
| 127 | + // ...vueRules, |
| 128 | + // }, |
| 129 | +}; |
| 130 | + |
| 131 | +export default [ |
| 132 | + globalConfig, |
| 133 | + tsConfig, |
| 134 | +]; |
0 commit comments