|
| 1 | +// The ESLint ecmaVersion argument is inconsistently used. Some rules will ignore it entirely, so if the rule has |
| 2 | +// been set, it will still error even if it's not applicable to that version number. Since Google sets these |
| 3 | +// rules, we have to turn them off ourselves. |
| 4 | +var DISABLED_ES6_OPTIONS = { |
| 5 | + 'no-var': 'off', |
| 6 | + 'prefer-rest-params': 'off' |
| 7 | +}; |
| 8 | + |
| 9 | +var SHAREDB_RULES = { |
| 10 | + // Comma dangle is not supported in ES3 |
| 11 | + 'comma-dangle': ['error', 'never'], |
| 12 | + // We control our own objects and prototypes, so no need for this check |
| 13 | + 'guard-for-in': 'off', |
| 14 | + // Google prescribes different indents for different cases. Let's just use 2 spaces everywhere. Note that we have |
| 15 | + // to override ESLint's default of 0 indents for this. |
| 16 | + indent: ['error', 2, { |
| 17 | + SwitchCase: 1 |
| 18 | + }], |
| 19 | + // Less aggressive line length than Google, which is especially useful when we have a lot of callbacks in our code |
| 20 | + 'max-len': ['error', |
| 21 | + { |
| 22 | + code: 120, |
| 23 | + tabWidth: 2, |
| 24 | + ignoreUrls: true |
| 25 | + } |
| 26 | + ], |
| 27 | + // Google overrides the default ESLint behaviour here, which is slightly better for catching erroneously unused |
| 28 | + // variables |
| 29 | + 'no-unused-vars': ['error', {vars: 'all', args: 'after-used'}], |
| 30 | + // It's more readable to ensure we only have one statement per line |
| 31 | + 'max-statements-per-line': ['error', {max: 1}], |
| 32 | + // ES3 doesn't support spread |
| 33 | + 'prefer-spread': 'off', |
| 34 | + // as-needed quote props are easier to write |
| 35 | + 'quote-props': ['error', 'as-needed'], |
| 36 | + 'require-jsdoc': 'off', |
| 37 | + 'valid-jsdoc': 'off' |
| 38 | +}; |
| 39 | + |
| 40 | +module.exports = { |
| 41 | + extends: 'google', |
| 42 | + parserOptions: { |
| 43 | + ecmaVersion: 3 |
| 44 | + }, |
| 45 | + rules: Object.assign( |
| 46 | + {}, |
| 47 | + DISABLED_ES6_OPTIONS, |
| 48 | + SHAREDB_RULES |
| 49 | + ) |
| 50 | +}; |
0 commit comments