|
| 1 | +// const { resolve } = require('path'); |
| 2 | + |
| 3 | +module.exports = { |
| 4 | + root: true, |
| 5 | + parserOptions: { |
| 6 | + extraFileExtensions: [`.vue`], |
| 7 | + parser: `@typescript-eslint/parser`, |
| 8 | + // project: resolve(__dirname, `./tsconfig.json`), |
| 9 | + tsconfigRootDir: __dirname, |
| 10 | + }, |
| 11 | + extends: [ |
| 12 | + `eslint:recommended`, |
| 13 | + `plugin:@typescript-eslint/recommended`, |
| 14 | + `plugin:vue/vue3-recommended`, |
| 15 | + `airbnb-base`, |
| 16 | + ], |
| 17 | + overrides: [ |
| 18 | + { |
| 19 | + files: [`*.vue`], |
| 20 | + rules: { |
| 21 | + indent: `off`, |
| 22 | + 'sort-keys': `off`, |
| 23 | + 'vue/sort-keys': `off`, |
| 24 | + 'operator-linebreak': `off`, |
| 25 | + }, |
| 26 | + }, |
| 27 | + { |
| 28 | + // disable the rule specifically for JavaScript files |
| 29 | + files: [`*.js`], |
| 30 | + rules: { |
| 31 | + '@typescript-eslint/explicit-function-return-type': `off`, |
| 32 | + '@typescript-eslint/explicit-module-boundary-types': `off`, |
| 33 | + }, |
| 34 | + }, |
| 35 | + { |
| 36 | + files: [`*.enum.ts`], |
| 37 | + rules: { |
| 38 | + 'no-shadow': `off`, // false positives in enum files |
| 39 | + }, |
| 40 | + }, |
| 41 | + ], |
| 42 | + plugins: [ |
| 43 | + `@typescript-eslint`, |
| 44 | + `import-quotes`, |
| 45 | + `prettier`, |
| 46 | + `vue`, |
| 47 | + ], |
| 48 | + rules: { |
| 49 | + '@typescript-eslint/array-type': [`error`, { default: `array` }], |
| 50 | + '@typescript-eslint/ban-ts-comment': [`warn`], |
| 51 | + '@typescript-eslint/default-param-last': [`error`], |
| 52 | + '@typescript-eslint/explicit-function-return-type': [`error`, { |
| 53 | + allowHigherOrderFunctions: false, |
| 54 | + }], |
| 55 | + '@typescript-eslint/func-call-spacing': [`error`], |
| 56 | + '@typescript-eslint/member-delimiter-style': [`error`, { |
| 57 | + multiline: { |
| 58 | + delimiter: `semi`, |
| 59 | + requireLast: true, |
| 60 | + }, |
| 61 | + singleline: { |
| 62 | + delimiter: `semi`, |
| 63 | + requireLast: false, |
| 64 | + }, |
| 65 | + }], |
| 66 | + '@typescript-eslint/naming-convention': [ |
| 67 | + `error`, |
| 68 | + { |
| 69 | + custom: { |
| 70 | + regex: `^I[A-Z]`, |
| 71 | + match: true, |
| 72 | + }, |
| 73 | + format: [`PascalCase`], |
| 74 | + selector: `interface`, |
| 75 | + }, |
| 76 | + { |
| 77 | + custom: { |
| 78 | + regex: `^E[A-Z]`, |
| 79 | + match: true, |
| 80 | + }, |
| 81 | + format: [`PascalCase`], |
| 82 | + selector: `enum`, |
| 83 | + }, |
| 84 | + { |
| 85 | + custom: { |
| 86 | + regex: `^T[A-Z]`, |
| 87 | + match: true, |
| 88 | + }, |
| 89 | + format: [`PascalCase`], |
| 90 | + selector: `typeAlias`, |
| 91 | + }, |
| 92 | + ], |
| 93 | + '@typescript-eslint/no-dupe-class-members': [`error`], |
| 94 | + '@typescript-eslint/no-empty-function': [`error`], |
| 95 | + '@typescript-eslint/no-redeclare': [`error`], |
| 96 | + '@typescript-eslint/no-shadow': `warn`, |
| 97 | + '@typescript-eslint/no-unused-vars': [`error`], |
| 98 | + '@typescript-eslint/no-useless-constructor': [`error`], |
| 99 | + '@typescript-eslint/space-before-function-paren': [`error`, { |
| 100 | + anonymous: `never`, |
| 101 | + asyncArrow: `always`, |
| 102 | + named: `never`, |
| 103 | + }], |
| 104 | + 'arrow-body-style': `off`, |
| 105 | + 'arrow-parens': [`error`, `as-needed`], |
| 106 | + 'block-scoped-var': `warn`, |
| 107 | + 'class-methods-use-this': `off`, |
| 108 | + 'default-param-last': `off`, |
| 109 | + 'function-paren-newline': `off`, |
| 110 | + 'func-call-spacing': `off`, |
| 111 | + 'guard-for-in': [`warn`], |
| 112 | + 'import/default': [`error`], |
| 113 | + 'import/export': [`error`], |
| 114 | + 'import/extension': 0, |
| 115 | + 'import/extensions': [ |
| 116 | + `off`, |
| 117 | + { |
| 118 | + ignorePackages: true, |
| 119 | + js: `never`, |
| 120 | + jsx: `never`, |
| 121 | + ts: `never`, |
| 122 | + tsx: `never`, |
| 123 | + }, |
| 124 | + ], |
| 125 | + 'import/first': `off`, |
| 126 | + 'import/named': [`error`], |
| 127 | + 'import/namespace': [`error`], |
| 128 | + 'import/no-cycle': [`off`], |
| 129 | + 'import/no-extraneous-dependencies': `off`, |
| 130 | + 'import/no-unresolved': `off`, |
| 131 | + 'import/prefer-default-export': `off`, |
| 132 | + 'import-quotes/import-quotes': [1, `single`], |
| 133 | + indent: [`error`, 2, { |
| 134 | + SwitchCase: 1, |
| 135 | + }], |
| 136 | + 'keyword-spacing': [ |
| 137 | + `error`, |
| 138 | + { |
| 139 | + after: true, |
| 140 | + before: true, |
| 141 | + overrides: { |
| 142 | + catch: { after: false }, |
| 143 | + for: { after: false }, |
| 144 | + if: { after: false }, |
| 145 | + switch: { after: false }, |
| 146 | + }, |
| 147 | + }, |
| 148 | + ], |
| 149 | + 'linebreak-style': 0, |
| 150 | + 'lines-between-class-members': `off`, |
| 151 | + 'max-len': [`warn`, { |
| 152 | + code: 200, |
| 153 | + ignoreComments: true, |
| 154 | + ignoreRegExpLiterals: true, |
| 155 | + ignoreStrings: true, |
| 156 | + ignoreTemplateLiterals: true, |
| 157 | + ignoreTrailingComments: true, |
| 158 | + ignoreUrls: true, |
| 159 | + }], |
| 160 | + 'no-console': [`warn`, { allow: [`error`, `groupCollapsed`, `groupEnd`, `info`, `trace`, `warn`] }], |
| 161 | + 'no-continue': `off`, |
| 162 | + 'no-dupe-class-members': `off`, |
| 163 | + 'no-else-return': `warn`, |
| 164 | + 'no-empty-function': `off`, |
| 165 | + 'no-nested-ternary': `warn`, |
| 166 | + 'no-param-reassign': [ |
| 167 | + `warn`, |
| 168 | + { |
| 169 | + props: false, |
| 170 | + }, |
| 171 | + ], |
| 172 | + 'no-plusplus': `off`, |
| 173 | + 'no-redeclare': [`off`], |
| 174 | + 'no-restricted-syntax': [ |
| 175 | + `warn`, |
| 176 | + `ForInStatement`, |
| 177 | + `LabeledStatement`, |
| 178 | + `WithStatement`, |
| 179 | + ], |
| 180 | + 'no-return-assign': [`error`], |
| 181 | + 'no-shadow': `off`, |
| 182 | + 'no-spaced-func': `off`, |
| 183 | + 'no-unused-expressions': [`error`, { allowTernary: true }], |
| 184 | + 'no-unused-vars': `off`, |
| 185 | + 'no-useless-constructor': `off`, |
| 186 | + 'no-void': `off`, |
| 187 | + 'prefer-const': [`error`, { ignoreReadBeforeAssign: false }], |
| 188 | + 'prefer-destructuring': `warn`, |
| 189 | + 'prefer-promise-reject-errors': `off`, |
| 190 | + quotes: `off`, |
| 191 | + semi: [`error`, `always`], |
| 192 | + 'sort-keys': `off`, |
| 193 | + 'space-before-function-paren': `off`, |
| 194 | + 'vue/attribute-hyphenation': [`error`, `always`], |
| 195 | + 'vue/attributes-order': [`warn`, { |
| 196 | + alphabetical: true, |
| 197 | + order: [ |
| 198 | + `CONDITIONALS`, |
| 199 | + `LIST_RENDERING`, |
| 200 | + `DEFINITION`, |
| 201 | + `RENDER_MODIFIERS`, |
| 202 | + `GLOBAL`, |
| 203 | + `UNIQUE`, |
| 204 | + `TWO_WAY_BINDING`, |
| 205 | + `OTHER_DIRECTIVES`, |
| 206 | + `OTHER_ATTR`, |
| 207 | + `EVENTS`, |
| 208 | + `CONTENT`, |
| 209 | + ], |
| 210 | + }], |
| 211 | + 'vue/component-name-in-template-casing': [`error`, `PascalCase`], |
| 212 | + 'vue/component-tags-order': [`error`, { order: [`template`, `script`, `style`] }], |
| 213 | + 'vue/first-attribute-linebreak': [`error`, { |
| 214 | + multiline: `below`, |
| 215 | + singleline: `beside`, |
| 216 | + }], |
| 217 | + 'vue/html-closing-bracket-newline': [`error`, { |
| 218 | + multiline: `never`, |
| 219 | + singleline: `never`, |
| 220 | + }], |
| 221 | + 'vue/html-closing-bracket-spacing': [`error`], |
| 222 | + 'vue/html-end-tags': [`error`], |
| 223 | + 'vue/html-indent': [`error`, 2], |
| 224 | + 'vue/html-quotes': [`error`, `double`], |
| 225 | + 'vue/html-self-closing': [`error`, { |
| 226 | + html: { |
| 227 | + component: `always`, |
| 228 | + normal: `never`, |
| 229 | + void: `always`, |
| 230 | + }, |
| 231 | + }], |
| 232 | + "vue/max-attributes-per-line": [`error`, { |
| 233 | + singleline: { |
| 234 | + max: 1, |
| 235 | + }, |
| 236 | + multiline: { |
| 237 | + max: 1, |
| 238 | + }, |
| 239 | + }], |
| 240 | + 'vue/multiline-html-element-content-newline': [`error`], |
| 241 | + 'vue/multi-word-component-names': `off`, |
| 242 | + 'vue/mustache-interpolation-spacing': [`error`], |
| 243 | + 'vue/component-definition-name-casing': [`error`, `PascalCase`], |
| 244 | + 'vue/no-multi-spaces': [`error`], |
| 245 | + 'vue/no-multiple-template-root': [`off`], |
| 246 | + 'vue/no-spaces-around-equal-signs-in-attribute': [`error`], |
| 247 | + 'vue/no-template-shadow': [`warn`], |
| 248 | + 'vue/no-use-v-if-with-v-for': [`error`], |
| 249 | + 'vue/no-v-html': [`warn`], |
| 250 | + 'vue/order-in-components': [`error`, { |
| 251 | + order: [ |
| 252 | + `name`, |
| 253 | + `components`, |
| 254 | + `mixins`, |
| 255 | + `validate`, |
| 256 | + `model`, |
| 257 | + `emits`, |
| 258 | + `data`, |
| 259 | + `computed`, |
| 260 | + `props`, |
| 261 | + `middleware`, |
| 262 | + `LIFECYCLE_HOOKS`, |
| 263 | + `methods`, |
| 264 | + `watch`, |
| 265 | + ], |
| 266 | + }], |
| 267 | + 'vue/prop-name-casing': [`error`], |
| 268 | + 'vue/require-default-prop': [`error`], |
| 269 | + 'vue/require-prop-types': [`error`], |
| 270 | + 'vue/require-v-for-key': `error`, |
| 271 | + 'vue/script-indent': [`error`, 2, { |
| 272 | + baseIndent: 1, |
| 273 | + switchCase: 1, |
| 274 | + }], |
| 275 | + 'vue/script-setup-uses-vars': `error`, |
| 276 | + 'vue/singleline-html-element-content-newline': [`error`], |
| 277 | + 'vue/this-in-template': [`error`], |
| 278 | + 'vue/v-bind-style': [`error`], |
| 279 | + 'vue/v-on-style': [`error`], |
| 280 | + 'vue/valid-template-root': [`error`], |
| 281 | + }, |
| 282 | +}; |
0 commit comments