|
| 1 | +module.exports = { |
| 2 | + extends: ['eslint:recommended', 'airbnb-base', 'plugin:import/recommended'], |
| 3 | + parser: '@babel/eslint-parser', |
| 4 | + parserOptions: { requireConfigFile: false }, |
| 5 | + env: { |
| 6 | + browser: true, |
| 7 | + node: true, |
| 8 | + }, |
| 9 | + settings: { |
| 10 | + 'import/ignore': ['node_modules', '.(scss|css)$', '.(jpe?g|png|gif|svg)'], |
| 11 | + }, |
| 12 | + rules: { |
| 13 | + /** |
| 14 | + * Possible Errors |
| 15 | + * http://eslint.org/docs/rus/#possible-errors |
| 16 | + */ |
| 17 | + |
| 18 | + // Allow dangling commas for multiline arrays and objects |
| 19 | + // http://eslint.org/docs/rules/comma-dangle |
| 20 | + 'comma-dangle': [1, 'only-multiline'], |
| 21 | + |
| 22 | + // Warn against use of console for non-error logging |
| 23 | + // http://eslint.org/docs/rules/no-console |
| 24 | + 'no-console': [1, { allow: ['error'] }], |
| 25 | + |
| 26 | + // Allow use of Object.prototypes builtins directly |
| 27 | + // http://eslint.org/docs/rules/no-prototype-builtins |
| 28 | + 'no-prototype-builtins': [0], |
| 29 | + |
| 30 | + /** |
| 31 | + * Best Practices |
| 32 | + * http://eslint.org/docs/rules/#best-practices |
| 33 | + */ |
| 34 | + |
| 35 | + // Allow else clauses after an if with a return |
| 36 | + // http://eslint.org/docs/rules/no-else-return |
| 37 | + 'no-else-return': [0], |
| 38 | + |
| 39 | + // Disallow reassignment of function parameters (but allow assigning to parameter's properties) |
| 40 | + // http://eslint.org/docs/rules/no-param-reassign.html |
| 41 | + 'no-param-reassign': [2, { props: false }], |
| 42 | + |
| 43 | + /** |
| 44 | + * Variables |
| 45 | + * http://eslint.org/docs/rules/#variables |
| 46 | + */ |
| 47 | + |
| 48 | + // Disallow use of variables and classes before they are defined |
| 49 | + // http://eslint.org/docs/rules/no-use-before-define |
| 50 | + 'no-use-before-define': [2, { functions: false, classes: true }], |
| 51 | + |
| 52 | + // Disallow declaration of variables that are not used in the code, unless they are prefixed by |
| 53 | + // `ignored` (useful for creating subset objects through destructuring and rest objects) |
| 54 | + // http://eslint.org/docs/rules/no-unused-vars |
| 55 | + 'no-unused-vars': [ |
| 56 | + 2, |
| 57 | + { |
| 58 | + vars: 'local', |
| 59 | + args: 'after-used', |
| 60 | + varsIgnorePattern: 'ignored.+', |
| 61 | + }, |
| 62 | + ], |
| 63 | + |
| 64 | + /** |
| 65 | + * Stylelistic Issues |
| 66 | + * (http://eslint.org/docs/rules/#stylistic-issues) |
| 67 | + */ |
| 68 | + |
| 69 | + // Enforce 4-space indents, except for switch cases |
| 70 | + // http://eslint.org/docs/rules/indent |
| 71 | + 'indent': [2, 4, { SwitchCase: 1, VariableDeclarator: 1 }], |
| 72 | + |
| 73 | + // Specify the maximum length of a code line to be 100 |
| 74 | + // http://eslint.org/docs/rules/max-len |
| 75 | + 'max-len': [ |
| 76 | + 2, |
| 77 | + { |
| 78 | + code: 105, // Use 105 to give some leeway for *just* slightly longer lines when convienient |
| 79 | + ignorePattern: '^(import|export) .* from .*$', |
| 80 | + ignoreComments: false, |
| 81 | + ignoreTrailingComments: true, |
| 82 | + ignoreUrls: true, |
| 83 | + }, |
| 84 | + ], |
| 85 | + |
| 86 | + // Require capitalization when using `new`, but don't require capitalized functions to be called |
| 87 | + // with new |
| 88 | + // http://eslint.org/docs/rules/new-cap |
| 89 | + 'new-cap': [2, { newIsCap: true, capIsNew: false }], |
| 90 | + |
| 91 | + // Allow the continue statement |
| 92 | + // http://eslint.org/docs/rules/no-continue |
| 93 | + 'no-continue': [0], |
| 94 | + |
| 95 | + // Disallow un-paren'd mixes of different operators if they're not of the same precendence |
| 96 | + // http://eslint.org/docs/rules/no-mixed-operators |
| 97 | + 'no-mixed-operators': [ |
| 98 | + 2, |
| 99 | + { |
| 100 | + groups: [ |
| 101 | + ['+', '-', '*', '/', '%', '**'], |
| 102 | + ['&', '|', '^', '~', '<<', '>>', '>>>'], |
| 103 | + ['==', '!=', '===', '!==', '>', '>=', '<', '<='], |
| 104 | + ['&&', '||'], |
| 105 | + ['in', 'instanceof'], |
| 106 | + ], |
| 107 | + allowSamePrecedence: true, |
| 108 | + }, |
| 109 | + ], |
| 110 | + |
| 111 | + // Allow use of unary increment/decrement operators |
| 112 | + // http://eslint.org/docs/rules/no-plusplus |
| 113 | + 'no-plusplus': [0], |
| 114 | + |
| 115 | + // Always allow dangling underscores |
| 116 | + // http://eslint.org/docs/rules/no-underscore-dangle |
| 117 | + 'no-underscore-dangle': [0], |
| 118 | + |
| 119 | + // Require unix-style line breaks |
| 120 | + // http://eslint.org/docs/rules/linebreak-style |
| 121 | + 'linebreak-style': [2, 'unix'], |
| 122 | + |
| 123 | + // Require operators to always be at the end of a line, except for the ternary operator |
| 124 | + // http://eslint.org/docs/rules/operator-linebreak |
| 125 | + 'operator-linebreak': [ |
| 126 | + 2, |
| 127 | + 'after', |
| 128 | + { overrides: { '?': 'ignore', ':': 'ignore' } }, |
| 129 | + ], |
| 130 | + |
| 131 | + // Require properties to be consistently quoted. Force numbers to be quoted, as they can have |
| 132 | + // weird behaviour during the coercion into a string) |
| 133 | + // http://eslint.org/docs/rules/quote-props |
| 134 | + 'quote-props': [ |
| 135 | + 2, |
| 136 | + 'consistent', |
| 137 | + { keywords: false, unnecessary: true, numbers: true }, |
| 138 | + ], |
| 139 | + |
| 140 | + // Require spaces before parens for anonymous function declarations |
| 141 | + // http://eslint.org/docs/rules/space-before-function-paren |
| 142 | + 'space-before-function-paren': [2, { anonymous: 'always', named: 'never' }], |
| 143 | + |
| 144 | + // Require a space immediately following the // or /* in a comment for most comments |
| 145 | + // http://eslint.org/docs/rules/spaced-comment |
| 146 | + 'spaced-comment': [ |
| 147 | + 2, |
| 148 | + 'always', |
| 149 | + { |
| 150 | + line: { |
| 151 | + exceptions: ['-', '+'], |
| 152 | + }, |
| 153 | + block: { |
| 154 | + exceptions: ['*'], |
| 155 | + }, |
| 156 | + }, |
| 157 | + ], |
| 158 | + |
| 159 | + // We don't like semicolons so kill them |
| 160 | + // http://eslint.org/docs/rules/semi |
| 161 | + 'semi': [2, 'never'], |
| 162 | + |
| 163 | + /** |
| 164 | + * Import rules |
| 165 | + * https://github.com/benmosher/eslint-plugin-import#rules |
| 166 | + */ |
| 167 | + |
| 168 | + // Ensure named imports coupled with named exports |
| 169 | + // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/named.md#when-not-to-use-it |
| 170 | + 'import/named': 2, |
| 171 | + |
| 172 | + // Ensure default import coupled with default export |
| 173 | + // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/default.md#when-not-to-use-it |
| 174 | + 'import/default': 2, |
| 175 | + |
| 176 | + // Disallow namespace (wildcard) imports |
| 177 | + // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-namespace.md |
| 178 | + 'import/no-namespace': 2, |
| 179 | + |
| 180 | + // Enforce imports to not specify a trailing .js extension |
| 181 | + // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/extensions.md |
| 182 | + 'import/extensions': [2, { js: 'never' }], |
| 183 | + |
| 184 | + // Enforce module import order: builtin -> external -> internal |
| 185 | + // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/order.md |
| 186 | + 'import/order': [ |
| 187 | + 2, |
| 188 | + { |
| 189 | + groups: [ |
| 190 | + 'builtin', |
| 191 | + 'external', |
| 192 | + ['internal', 'parent', 'sibling', 'index'], |
| 193 | + ], |
| 194 | + }, |
| 195 | + ], |
| 196 | + |
| 197 | + /** |
| 198 | + * ES6-specific Issues |
| 199 | + * (http://eslint.org/docs/rules/#ecmascript-6) |
| 200 | + */ |
| 201 | + 'arrow-body-style': [0], |
| 202 | + 'arrow-parens': [0], |
| 203 | + 'arrow-spacing': [0], |
| 204 | + 'constructor-super': [0], |
| 205 | + 'generator-star-spacing': [0], |
| 206 | + 'no-class-assign': [0], |
| 207 | + 'no-confusing-arrow': [0], |
| 208 | + 'no-const-assign': [0], |
| 209 | + 'no-dupe-class-members': [0], |
| 210 | + 'no-duplicate-imports': [0], |
| 211 | + 'no-new-symbol': [0], |
| 212 | + 'no-restricted-imports': [0], |
| 213 | + 'no-this-before-super': [0], |
| 214 | + 'no-useless-computed-key': [0], |
| 215 | + 'no-useless-constructor': [0], |
| 216 | + 'no-useless-rename': [0], |
| 217 | + 'no-var': [0], |
| 218 | + 'object-shorthand': [0], |
| 219 | + 'prefer-arrow-callback': [0], |
| 220 | + 'prefer-const': [0], |
| 221 | + 'prefer-reflect': [0], |
| 222 | + 'prefer-rest-params': [0], |
| 223 | + 'prefer-spread': [0], |
| 224 | + 'prefer-template': [0], |
| 225 | + 'require-yield': [0], |
| 226 | + 'rest-spread-spacing': [0], |
| 227 | + 'sort-imports': [0], |
| 228 | + 'template-curly-spacing': [0], |
| 229 | + 'yield-star-spacing': [0], |
| 230 | + }, |
| 231 | +} |
0 commit comments