.eslintrc.js
module.exports = {
extends: ['prettier', 'plugin:jest/recommended'],
parser: 'babel-eslint',
env: {
browser: true,
es6: true
},
parserOptions: {
ecmaVersion: 2018,
sourceType: 'module',
ecmaFeatures: {
arrowFunctions: true,
blockBindings: true,
classes: true,
defaultParams: true,
destructuring: true,
forOf: true,
generators: true,
modules: true,
objectLiteralComputedProperties: true,
objectLiteralShorthandMethods: true,
objectLiteralShorthandProperties: true,
restParams: true,
spread: true,
superInFunctions: true,
templateStrings: true,
unicodeCodePointEscapes: true
}
},
globals: {
inject: false,
module: false,
jasmine: false,
sinon: false,
describe: false,
it: false,
before: false,
beforeEach: false,
beforeAll: false,
after: false,
afterEach: false,
afterAll: false,
expect: false,
window: false,
document: false,
jest: false,
spyOn: false,
__DEV__: false,
__PRERELEASE__: false,
__dirname: false,
Promise: false,
jsdom: false,
cy: false,
Cypress: false
},
plugins: ['babel', 'jest', 'prettier'],
rules: {
'no-cond-assign': [2, 'always'],
'no-console': 0, // disable during development
'no-constant-condition': 2,
'no-control-regex': 2,
'no-debugger': 0, // disabled during development
'no-dupe-args': 2,
'no-dupe-keys': 2,
'no-duplicate-case': 2,
'no-empty-character-class': 2,
'no-empty': 2,
'no-ex-assign': 2,
'no-extra-boolean-cast': 2,
'no-func-assign': 2,
'no-inner-declarations': 2,
'no-invalid-regexp': 2,
'no-irregular-whitespace': 2,
'no-negated-in-lhs': 2,
'no-obj-calls': 2,
'no-regex-spaces': 2,
'no-sparse-arrays': 2,
'no-unreachable': 2,
'use-isnan': 2,
'valid-jsdoc': 2,
'valid-typeof': 2,
'no-unexpected-multiline': 2,
// # Best Practices http://eslint.org/docs/rules/#best-practices
'accessor-pairs': [2, { setWithoutGet: true }],
'block-scoped-var': 2,
complexity: [2, 10],
'consistent-return': 2,
curly: 2,
'default-case': 2,
'dot-notation': 2,
eqeqeq: [2, 'smart'],
'guard-for-in': 2,
'no-alert': 0, // disabled during development
'no-caller': 2,
'no-div-regex': 2,
'no-else-return': 2,
'no-eq-null': 2,
'no-eval': 2,
'no-extend-native': 2,
'no-extra-bind': 2, // this is pretty cool
'no-fallthrough': 2,
'no-floating-decimal': 2,
'no-implicit-coercion': 0, // debatable
'no-implied-eval': 2,
'no-iterator': 2,
'no-labels': 2,
'no-lone-blocks': 2,
'no-loop-func': 2,
'no-multi-str': 2,
'no-native-reassign': 2,
'no-new-func': 2,
'no-new-wrappers': 2,
'no-new': 2,
'no-octal-escape': 2,
'no-octal': 2,
'no-param-reassign': [2, { props: false }],
'no-process-env': 2, // webpack may violate this
'no-proto': 2,
'no-redeclare': 2,
'no-return-assign': 2,
'no-script-url': 2,
'no-self-compare': 2,
'no-sequences': 2,
'no-throw-literal': 2,
'no-unused-expressions': 2,
'no-useless-call': 2,
'no-useless-concat': 2,
'no-void': 2,
'no-warning-comments': [
1,
{ terms: ['todo', 'fixme', 'xxx'], location: 'start' }
],
'no-with': 2,
radix: 2,
'vars-on-top': 2,
yoda: 2,
// # Strict Mode http://eslint.org/docs/rules/#strict-mode
strict: [2, 'function'],
// # Variables http://eslint.org/docs/rules/#variables
'init-declarations': [2, 'always'],
'no-catch-shadow': 2,
'no-delete-var': 2,
'no-label-var': 2,
'no-shadow-restricted-names': 2,
'no-shadow': 2,
'no-undef-init': 2,
'no-undef': 2,
'no-undefined': 2,
'no-unused-vars': [2, { vars: 'all', args: 'after-used' }],
'no-use-before-define': 2,
// # Node.js and CommonJS http://eslint.org/docs/rules/#nodejs-and-commonjs
'callback-return': 2,
'handle-callback-err': 0,
'no-mixed-requires': [1, true],
'no-new-require': 2,
'no-path-concat': 2,
'no-restricted-modules': [
2,
'assert',
'buffer',
'child_process',
'cluster',
'crypto',
'dgram',
'dns',
'domain',
'events',
'freelist',
'fs',
'http',
'https',
'module',
'net',
'os',
'path',
'punycode',
'querystring',
'readline',
'repl',
'smalloc',
'stream',
'string_decoder',
'sys',
'timers',
'tls',
'tracing',
'tty',
'url',
'util',
'vm',
'zlib'
],
'no-sync': 2,
// # Stylistic Issues http://eslint.org/docs/rules/#stylistic-issues
camelcase: [0, { properties: 'always' }],
'consistent-this': [2, 'self'],
'func-names': 0,
'func-style': 0,
'id-length': [
2,
{ min: 1, max: 100, properties: 'always', exceptions: [] }
],
'id-match': 0,
'lines-around-comment': [2, { beforeBlockComment: true }],
'linebreak-style': [2, 'unix'],
'max-nested-callbacks': [0, 3],
'new-cap': 0,
'newline-after-var': [0, 'always'],
'no-array-constructor': 2,
'no-continue': 2,
'no-inline-comments': 0,
'no-lonely-if': 2,
'no-nested-ternary': 2,
'no-new-object': 2,
'no-ternary': 0,
'no-underscore-dangle': 0,
'no-unneeded-ternary': 2,
'object-curly-spacing': [0, 'never'],
'one-var': 0, //turned off
'operator-assignment': [2, 'always'],
quotes: [2, 'single', 'avoid-escape'],
'sort-vars': 0,
'spaced-comment': [2, 'always'],
// # ECMAScript 6 http://eslint.org/docs/rules/#ecmascript-6
'arrow-body-style': [2, 'as-needed'],
'constructor-super': 2,
'no-class-assign': 2,
'no-const-assign': 2,
'no-dupe-class-members': 2,
'no-this-before-super': 2,
'no-var': 1, // difficult for legacy code
'object-shorthand': 2,
'prefer-arrow-callback': 2,
'prefer-const': 0,
'prefer-spread': 2,
'prefer-template': 2,
'require-yield': 2,
// # Legacy http://eslint.org/docs/rules/#legacy
'max-depth': [2, 4], // TODO: need to dial this in
'max-len': [
2,
200,
2,
{
ignoreComments: true,
ignoreUrls: true,
ignorePattern: '^\\s*var\\s.+=\\s*require\\s*\\('
}
], // TODO: need to dial this in
'max-params': [2, 5],
'max-statements': [2, 200], //decrease when possible
'no-bitwise': 0,
'no-plusplus': 0,
'babel/no-invalid-this': 2
}
};