|
| 1 | +module.exports = { |
| 2 | + root: true, |
| 3 | + parser: 'babel-eslint', |
| 4 | + parserOptions: { |
| 5 | + sourceType: 'module' |
| 6 | + }, |
| 7 | + env: { |
| 8 | + browser: true, |
| 9 | + node: true |
| 10 | + }, |
| 11 | + extends: 'eslint:recommended', |
| 12 | + // required to lint *.vue files |
| 13 | + plugins: [ |
| 14 | + 'html' |
| 15 | + ], |
| 16 | + // check if imports actually resolve |
| 17 | + 'settings': { |
| 18 | + 'import/resolver': { |
| 19 | + 'webpack': { |
| 20 | + 'config': 'build/webpack.base.conf.js' |
| 21 | + } |
| 22 | + } |
| 23 | + }, |
| 24 | + // add your custom rules here |
| 25 | + 'rules': { |
| 26 | + // don't require .vue extension when importing |
| 27 | + // 'import/extensions': ['error', 'always', { |
| 28 | + // 'js': 'never', |
| 29 | + // 'vue': 'never' |
| 30 | + // }], |
| 31 | + // allow debugger during development |
| 32 | + 'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0, |
| 33 | + /* |
| 34 | + * Possible Errors |
| 35 | + */ |
| 36 | + |
| 37 | + // disallow unnecessary parentheses |
| 38 | + 'no-extra-parens': ['error', 'all', {'nestedBinaryExpressions': false}], |
| 39 | + |
| 40 | + // disallow negating the left operand of relational operators |
| 41 | + 'no-unsafe-negation': 'error', |
| 42 | + |
| 43 | + // enforce valid JSDoc comments |
| 44 | + 'valid-jsdoc': 'off', |
| 45 | + |
| 46 | + /* |
| 47 | + * Best Practices |
| 48 | + */ |
| 49 | + |
| 50 | + // enforce return statements in callbacks of array methods |
| 51 | + 'array-callback-return': 'error', |
| 52 | + |
| 53 | + // enforce consistent brace style for all control statements |
| 54 | + curly: ['error', 'multi-line'], |
| 55 | + |
| 56 | + // enforce consistent newlines before and after dots |
| 57 | + 'dot-location': ['error', 'property'], |
| 58 | + |
| 59 | + // enforce dot notation whenever possible |
| 60 | + 'dot-notation': 'error', |
| 61 | + |
| 62 | + // require the use of === and !== |
| 63 | + 'eqeqeq': ['error', 'smart'], |
| 64 | + |
| 65 | + // disallow the use of arguments.caller or arguments.callee |
| 66 | + 'no-caller': 'error', |
| 67 | + |
| 68 | + // disallow empty functions |
| 69 | + 'no-empty-function': 'error', |
| 70 | + |
| 71 | + // disallow unnecessary calls to .bind() |
| 72 | + 'no-extra-bind': 'error', |
| 73 | + |
| 74 | + // disallow unnecessary labels |
| 75 | + 'no-extra-label': 'error', |
| 76 | + |
| 77 | + // disallow leading or trailing decimal points in numeric literals |
| 78 | + 'no-floating-decimal': 'error', |
| 79 | + |
| 80 | + // disallow assignments to native objects or read-only global variables |
| 81 | + 'no-global-assign': 'error', |
| 82 | + |
| 83 | + // disallow the use of eval()-like methods |
| 84 | + 'no-implied-eval': 'error', |
| 85 | + |
| 86 | + // disallow the use of the __iterator__ property |
| 87 | + 'no-iterator': 'error', |
| 88 | + |
| 89 | + // disallow unnecessary nested blocks |
| 90 | + 'no-lone-blocks': 'error', |
| 91 | + |
| 92 | + // disallow multiple spaces |
| 93 | + 'no-multi-spaces': 'error', |
| 94 | + |
| 95 | + // disallow new operators with the String, Number, and Boolean objects |
| 96 | + 'no-new-wrappers': 'error', |
| 97 | + |
| 98 | + // disallow octal escape sequences in string literals |
| 99 | + 'no-octal-escape': 'error', |
| 100 | + |
| 101 | + // disallow the use of the __proto__ property |
| 102 | + 'no-proto': 'error', |
| 103 | + |
| 104 | + // disallow comparisons where both sides are exactly the same |
| 105 | + 'no-self-compare': 'error', |
| 106 | + |
| 107 | + // disallow throwing literals as exceptions |
| 108 | + 'no-throw-literal': 'error', |
| 109 | + |
| 110 | + // disallow unused expressions |
| 111 | + 'no-unused-expressions': 'error', |
| 112 | + |
| 113 | + // disallow unnecessary calls to .call() and .apply() |
| 114 | + 'no-useless-call': 'error', |
| 115 | + |
| 116 | + // disallow unnecessary concatenation of literals or template literals |
| 117 | + 'no-useless-concat': 'error', |
| 118 | + |
| 119 | + // disallow unnecessary escape characters |
| 120 | + 'no-useless-escape': 'error', |
| 121 | + |
| 122 | + // disallow void operators |
| 123 | + 'no-void': 'error', |
| 124 | + |
| 125 | + // require parentheses around immediate function invocations |
| 126 | + 'wrap-iife': 'error', |
| 127 | + |
| 128 | + // require or disallow “Yoda” conditions |
| 129 | + yoda: 'error', |
| 130 | + |
| 131 | + /* |
| 132 | + * Variables |
| 133 | + */ |
| 134 | + |
| 135 | + // disallow labels that share a name with a variable |
| 136 | + 'no-label-var': 'error', |
| 137 | + |
| 138 | + // disallow initializing variables to undefined |
| 139 | + 'no-undef-init': 'error', |
| 140 | + 'no-undef': 'off', |
| 141 | + // disallow the use of variables before they are defined |
| 142 | + 'no-use-before-define': 'error', |
| 143 | + |
| 144 | + /* |
| 145 | + * Node.js and CommonJS |
| 146 | + */ |
| 147 | + |
| 148 | + // disallow new operators with calls to require |
| 149 | + 'no-new-require': 'error', |
| 150 | + |
| 151 | + /* |
| 152 | + * Stylistic Issues |
| 153 | + */ |
| 154 | + |
| 155 | + // enforce consistent spacing inside array brackets |
| 156 | + 'array-bracket-spacing': 'error', |
| 157 | + |
| 158 | + // enforce consistent spacing inside single-line blocks |
| 159 | + 'block-spacing': 'error', |
| 160 | + |
| 161 | + // enforce consistent brace style for blocks |
| 162 | + 'brace-style': ['error', '1tbs', {'allowSingleLine': true}], |
| 163 | + |
| 164 | + // require or disallow trailing commas |
| 165 | + 'comma-dangle': 'error', |
| 166 | + |
| 167 | + // enforce consistent spacing before and after commas |
| 168 | + 'comma-spacing': 'error', |
| 169 | + |
| 170 | + // enforce consistent comma style |
| 171 | + 'comma-style': 'error', |
| 172 | + |
| 173 | + // enforce consistent spacing inside computed property brackets |
| 174 | + 'computed-property-spacing': 'error', |
| 175 | + |
| 176 | + // require or disallow spacing between function identifiers and their invocations |
| 177 | + 'func-call-spacing': 'error', |
| 178 | + |
| 179 | + // enforce consistent indentation |
| 180 | + indent: ['error', 2, {SwitchCase: 1}], |
| 181 | + |
| 182 | + // enforce the consistent use of either double or single quotes in JSX attributes |
| 183 | + 'jsx-quotes': 'error', |
| 184 | + |
| 185 | + // enforce consistent spacing between keys and values in object literal properties |
| 186 | + 'key-spacing': 'error', |
| 187 | + |
| 188 | + // enforce consistent spacing before and after keywords |
| 189 | + 'keyword-spacing': 'error', |
| 190 | + |
| 191 | + // enforce consistent linebreak style |
| 192 | + 'linebreak-style': 'error', |
| 193 | + |
| 194 | + // require or disallow newlines around directives |
| 195 | + 'lines-around-directive': 'error', |
| 196 | + |
| 197 | + // require constructor names to begin with a capital letter |
| 198 | + 'new-cap': 'off', |
| 199 | + |
| 200 | + // require parentheses when invoking a constructor with no arguments |
| 201 | + 'new-parens': 'error', |
| 202 | + |
| 203 | + // disallow Array constructors |
| 204 | + 'no-array-constructor': 'error', |
| 205 | + |
| 206 | + // disallow Object constructors |
| 207 | + 'no-new-object': 'error', |
| 208 | + |
| 209 | + // disallow trailing whitespace at the end of lines |
| 210 | + 'no-trailing-spaces': 'error', |
| 211 | + |
| 212 | + // disallow ternary operators when simpler alternatives exist |
| 213 | + 'no-unneeded-ternary': 'error', |
| 214 | + |
| 215 | + // disallow whitespace before properties |
| 216 | + 'no-whitespace-before-property': 'error', |
| 217 | + |
| 218 | + // enforce consistent spacing inside braces |
| 219 | + 'object-curly-spacing': ['error', 'always'], |
| 220 | + |
| 221 | + // require or disallow padding within blocks |
| 222 | + 'padded-blocks': ['error', 'never'], |
| 223 | + |
| 224 | + // require quotes around object literal property names |
| 225 | + 'quote-props': ['error', 'as-needed'], |
| 226 | + |
| 227 | + // enforce the consistent use of either backticks, double, or single quotes |
| 228 | + quotes: ['error', 'single'], |
| 229 | + |
| 230 | + // enforce consistent spacing before and after semicolons |
| 231 | + 'semi-spacing': 'error', |
| 232 | + |
| 233 | + // require or disallow semicolons instead of ASI |
| 234 | + // semi: ['error', 'never'], |
| 235 | + |
| 236 | + // enforce consistent spacing before blocks |
| 237 | + 'space-before-blocks': 'error', |
| 238 | + |
| 239 | + 'no-console': 'off', |
| 240 | + |
| 241 | + // enforce consistent spacing before function definition opening parenthesis |
| 242 | + 'space-before-function-paren': ['error', 'never'], |
| 243 | + |
| 244 | + // enforce consistent spacing inside parentheses |
| 245 | + 'space-in-parens': 'error', |
| 246 | + |
| 247 | + // require spacing around infix operators |
| 248 | + 'space-infix-ops': 'error', |
| 249 | + |
| 250 | + // enforce consistent spacing before or after unary operators |
| 251 | + 'space-unary-ops': 'error', |
| 252 | + |
| 253 | + // enforce consistent spacing after the // or /* in a comment |
| 254 | + 'spaced-comment': 'error', |
| 255 | + |
| 256 | + // require or disallow Unicode byte order mark (BOM) |
| 257 | + 'unicode-bom': 'error', |
| 258 | + |
| 259 | + |
| 260 | + /* |
| 261 | + * ECMAScript 6 |
| 262 | + */ |
| 263 | + |
| 264 | + // require braces around arrow function bodies |
| 265 | + 'arrow-body-style': 'error', |
| 266 | + |
| 267 | + // require parentheses around arrow function arguments |
| 268 | + 'arrow-parens': ['error', 'as-needed'], |
| 269 | + |
| 270 | + // enforce consistent spacing before and after the arrow in arrow functions |
| 271 | + 'arrow-spacing': 'error', |
| 272 | + |
| 273 | + // enforce consistent spacing around * operators in generator functions |
| 274 | + 'generator-star-spacing': ['error', 'after'], |
| 275 | + |
| 276 | + // disallow duplicate module imports |
| 277 | + 'no-duplicate-imports': 'error', |
| 278 | + |
| 279 | + // disallow unnecessary computed property keys in object literals |
| 280 | + 'no-useless-computed-key': 'error', |
| 281 | + |
| 282 | + // disallow unnecessary constructors |
| 283 | + 'no-useless-constructor': 'error', |
| 284 | + |
| 285 | + // disallow renaming import, export, and destructured assignments to the same name |
| 286 | + 'no-useless-rename': 'error', |
| 287 | + |
| 288 | + // require let or const instead of var |
| 289 | + 'no-var': 'error', |
| 290 | + |
| 291 | + // require or disallow method and property shorthand syntax for object literals |
| 292 | + 'object-shorthand': 'error', |
| 293 | + |
| 294 | + // require arrow functions as callbacks |
| 295 | + 'prefer-arrow-callback': 'error', |
| 296 | + |
| 297 | + // require const declarations for variables that are never reassigned after declared |
| 298 | + 'prefer-const': 'error', |
| 299 | + |
| 300 | + // disallow parseInt() in favor of binary, octal, and hexadecimal literals |
| 301 | + 'prefer-numeric-literals': 'error', |
| 302 | + |
| 303 | + // require rest parameters instead of arguments |
| 304 | + 'prefer-rest-params': 'error', |
| 305 | + |
| 306 | + // require spread operators instead of .apply() |
| 307 | + 'prefer-spread': 'error', |
| 308 | + |
| 309 | + // enforce spacing between rest and spread operators and their expressions |
| 310 | + 'rest-spread-spacing': 'error', |
| 311 | + |
| 312 | + // require or disallow spacing around embedded expressions of template strings |
| 313 | + 'template-curly-spacing': 'error', |
| 314 | + |
| 315 | + // require or disallow spacing around the * in yield* expressions |
| 316 | + 'yield-star-spacing': 'error' |
| 317 | + } |
| 318 | +} |
0 commit comments