Last active
January 4, 2021 16:01
-
-
Save madcampos/0bd2e6f3b6dea69c54055b6f2187deb4 to your computer and use it in GitHub Desktop.
ESLint config
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* eslint-disable max-lines, no-magic-numbers */ | |
/* eslint-env node */ | |
module.exports = { | |
root: true, | |
// Uses the typescript parser for ease of use and "new features". | |
// (a.k.a.: supported but not in the current js version yet) | |
parser: '@typescript-eslint/parser', | |
parserOptions: { | |
sourceType: 'module', | |
ecmaVersion: 12, | |
lib: ['ESNext', 'DOM'] | |
}, | |
ignorePatterns: ['/build/**', '/dist/**', '/vendor/**'], | |
env: { | |
browser: true, | |
webextensions: true, | |
'shared-node-browser': true, | |
es6: true, | |
es2017: true, | |
es2020: true | |
}, | |
plugins: ['jsdoc'], | |
rules: { | |
// Possible errors | |
'for-direction': 'error', | |
'getter-return': ['error', { allowImplicit: true }], | |
'no-await-in-loop': 'error', | |
'no-async-promise-executor': 'error', | |
'no-compare-neg-zero': 'error', | |
'no-cond-assign': ['error', 'always'], | |
'no-console': 'warn', | |
'no-constant-condition': 'error', | |
'no-control-regex': 'error', | |
'no-debugger': 'warn', | |
'no-dupe-args': 'error', | |
'no-dupe-else-if': 'error', | |
'no-dupe-keys': 'error', | |
'no-duplicate-case': 'error', | |
'no-empty': 'warn', | |
'no-empty-character-class': 'error', | |
'no-ex-assign': 'error', | |
'no-extra-boolean-cast': 'error', | |
'no-extra-parens': ['error', 'all', { nestedBinaryExpressions: true }], | |
'no-extra-semi': 'error', | |
'no-func-assign': 'error', | |
'no-import-assign': 'error', | |
'no-inner-declarations': ['error', 'both'], | |
'no-invalid-regexp': 'error', | |
'no-irregular-whitespace': ['error', { skipStrings: true, skipTemplates: true }], | |
'no-loss-of-precision': 'error', | |
'no-misleading-character-class': 'error', | |
'no-obj-calls': 'error', | |
'no-promise-executor-return': 'error', | |
'no-prototype-builtins': 'warn', | |
'no-regex-spaces': 'error', | |
'no-setter-return': 'error', | |
'no-sparse-arrays': 'error', | |
'no-template-curly-in-string': 'warn', | |
'no-unexpected-multiline': 'error', | |
'no-unreachable': 'error', | |
'no-unreachable-loop': 'error', | |
'no-unsafe-finally': 'error', | |
'no-unsafe-negation': 'error', | |
'no-unsafe-optional-chaining': 'error', | |
'no-useless-backreference': 'error', | |
'require-atomic-updates': 'warn', | |
'use-isnan': 'error', | |
'valid-typeof': 'warn', | |
// Best practices | |
'accessor-pairs': 'error', | |
'array-callback-return': 'error', | |
'block-scoped-var': 'warn', | |
'class-methods-use-this': 'warn', | |
complexity: 'error', | |
'consistent-return': 'warn', | |
curly: 'error', | |
'default-case': 'warn', | |
'default-case-last': 'error', | |
'default-param-last': 'error', | |
'dot-location': ['warn', 'property'], | |
'dot-notation': ['error', { allowPattern: '^[a-z]+(_[a-z]+)+$' }], | |
eqeqeq: ['error', 'smart'], | |
'grouped-accessor-pairs': 'error', | |
'guard-for-in': 'warn', | |
'max-classes-per-file': ['warn', 1], | |
'no-alert': 'error', | |
'no-caller': 'error', | |
'no-case-declarations': 'error', | |
'no-constructor-return': 'error', | |
'no-div-regex': 'error', | |
'no-else-return': 'warn', | |
'no-empty-function': 'error', | |
'no-empty-pattern': 'error', | |
'no-eq-null': 'error', | |
'no-eval': 'error', | |
'no-extend-native': 'error', | |
'no-extra-bind': 'error', | |
'no-extra-label': 'error', | |
'no-fallthrough': 'error', | |
'no-floating-decimal': 'error', | |
'no-global-assign': 'error', | |
'no-implicit-coercion': 'error', | |
'no-implicit-globals': 'warn', | |
'no-implied-eval': 'error', | |
'no-invalid-this': 'warn', | |
'no-iterator': 'error', | |
'no-labels': 'error', | |
'no-lone-blocks': 'error', | |
'no-loop-func': 'error', | |
'no-magic-numbers': ['warn', { enforceConst: true, ignoreArrayIndexes: true, ignore: [-1, 0, 1, 16] }], | |
'no-multi-spaces': 'error', | |
'no-multi-str': 'error', | |
'no-new': 'error', | |
'no-new-func': 'error', | |
'no-new-wrappers': 'error', | |
'no-nonoctal-decimal-escape': 'error', | |
'no-octal': 'error', | |
'no-octal-escape': 'error', | |
'no-param-reassign': 'warn', | |
'no-proto': 'error', | |
'no-redeclare': ['error', { builtinGlobals: true }], | |
'no-restricted-properties': 'off', | |
'no-return-assign': 'error', | |
'no-return-await': 'warn', | |
'no-script-url': 'error', | |
'no-self-assign': ['error', { props: true }], | |
'no-self-compare': 'error', | |
'no-sequences': 'error', | |
'no-throw-literal': 'error', | |
'no-unmodified-loop-condition': 'error', | |
'no-unused-expressions': ['error', { allowShortCircuit: true, allowTernary: true }], | |
'no-unused-labels': 'error', | |
'no-useless-call': 'error', | |
'no-useless-catch': 'error', | |
'no-useless-concat': 'error', | |
'no-useless-escape': 'error', | |
'no-useless-return': 'error', | |
'no-void': 'error', | |
'no-warning-comments': 'warn', | |
'no-with': 'error', | |
'prefer-named-capture-group': 'warn', | |
'prefer-promise-reject-errors': 'warn', | |
'prefer-regex-literals': 'warn', | |
radix: ['error', 'as-needed'], | |
'require-await': 'warn', | |
'require-unicode-regexp': 'warn', | |
'vars-on-top': 'warn', | |
'wrap-iife': ['error', 'inside'], | |
yoda: 'error', | |
// Strict mode | |
strict: ['warn', 'function'], | |
// Variables | |
'init-declarations': 'warn', | |
'no-delete-var': 'error', | |
'no-label-var': 'error', | |
'no-restricted-globals': ['error', 'event'], | |
'no-shadow': ['warn', { builtinGlobals: true, hoist: 'all', allow: ['name', 'status', 'self', 'event'] }], | |
'no-shadow-restricted-names': 'error', | |
'no-undef': ['error', { 'typeof': true }], | |
'no-undef-init': 'warn', | |
'no-undefined': 'error', | |
'no-unused-vars': ['warn', { args: 'all', caughtErrors: 'none', argsIgnorePattern: '^_' }], | |
'no-use-before-define': 'error', | |
// Stylistic rules | |
'array-bracket-newline': 'warn', | |
'array-bracket-spacing': 'warn', | |
'array-element-newline': ['error', 'consistent'], | |
'block-spacing': 'warn', | |
'brace-style': ['warn', '1tbs', { allowSingleLine: true }], | |
camelcase: 'warn', | |
'capitalized-comments': 'warn', | |
'comma-dangle': 'warn', | |
'comma-spacing': 'warn', | |
'comma-style': 'warn', | |
'computed-property-spacing': 'warn', | |
'consistent-this': ['warn', 'self'], | |
'eol-last': ['warn', 'always'], | |
'func-call-spacing': 'warn', | |
'func-name-matching': 'error', | |
'func-names': ['warn', 'as-needed'], | |
'func-style': ['warn', 'declaration', { allowArrowFunctions: true }], | |
'function-call-argument-newline': ['warn', 'consistent'], | |
'function-paren-newline': ['warn', 'consistent'], | |
'id-denylist': 'off', | |
'id-length': [ | |
'warn', | |
{ min: 3, max: 50, properties: 'never', exceptions: ['i', 'j', 'n', 'w', 'x', 'y', 'z', 'cb', 'id', 'fs', 'to', 'up'] } | |
], | |
'id-match': 'off', | |
'implicit-arrow-linebreak': 'error', | |
indent: ['error', 4, { SwitchCase: 1 }], | |
'jsx-quotes': 'warn', | |
'key-spacing': 'error', | |
'keyword-spacing': ['error', { before: true, after: true, overrides: { 'function': { after: false } } }], | |
'lines-between-class-members': 'off', | |
'line-comment-position': ['error', { position: 'above' }], | |
'linebreak-style': 'error', | |
'lines-around-comment': 'warn', | |
'max-depth': 'warn', | |
'max-len': [ | |
'warn', | |
{ | |
code: 180, | |
tabWidth: 4, | |
ignoreComments: true, | |
ignoreUrls: true, | |
ignoreStrings: true, | |
ignoreTemplateLiterals: true, | |
ignoreRegExpLiterals: true | |
} | |
], | |
'max-lines': ['warn', 1024], | |
'max-lines-per-function': ['warn', { max: 512 }], | |
'max-nested-callbacks': 'warn', | |
'max-params': ['warn', 6], | |
'max-statements': ['warn', 512], | |
'max-statements-per-line': 'warn', | |
'multiline-comment-style': 'off', | |
'multiline-ternary': ['warn', 'always-multiline'], | |
'new-cap': 'error', | |
'new-parens': 'error', | |
'newline-per-chained-call': ['warn', { ignoreChainWithDepth: 6 }], | |
'no-array-constructor': 'error', | |
'no-bitwise': 'error', | |
'no-continue': 'error', | |
'no-inline-comments': 'warn', | |
'no-lonely-if': 'warn', | |
'no-mixed-operators': ['warn', { allowSamePrecedence: true }], | |
'no-mixed-spaces-and-tabs': ['error', 'smart-tabs'], | |
'no-multi-assign': 'error', | |
'no-multiple-empty-lines': ['warn', { max: 2, maxEOF: 0, maxBOF: 0 }], | |
'no-negated-condition': 'off', | |
'no-nested-ternary': 'error', | |
'no-new-object': 'error', | |
'no-plusplus': ['warn', { allowForLoopAfterthoughts: true }], | |
'no-restricted-syntax': 'off', | |
'no-tabs': ['warn', { allowIndentationTabs: true }], | |
'no-ternary': 'error', | |
'no-trailing-spaces': 'error', | |
'no-underscore-dangle': 'error', | |
'no-unneeded-ternary': 'error', | |
'no-whitespace-before-property': 'warn', | |
'nonblock-statement-body-position': 'warn', | |
'object-curly-newline': 'warn', | |
'object-curly-spacing': ['warn', 'always'], | |
'object-property-newline': ['warn', { allowMultiplePropertiesPerLine: true }], | |
'one-var': ['warn', 'never'], | |
'one-var-declaration-per-line': 'warn', | |
'operator-assignment': 'warn', | |
'operator-linebreak': ['error', 'none'], | |
'padded-blocks': ['warn', 'never'], | |
'padding-line-between-statements': [ | |
'warn', | |
{ blankLine: 'always', prev: '*', next: 'return' }, | |
{ blankLine: 'always', prev: ['const', 'let', 'var'], next: '*' }, | |
{ blankLine: 'any', prev: ['const', 'let', 'var'], next: ['const', 'let', 'var'] }, | |
{ blankLine: 'always', prev: 'directive', next: '*' }, | |
{ blankLine: 'any', prev: 'directive', next: 'directive' }, | |
{ blankLine: 'always', prev: 'break', next: ['case', 'default'] } | |
], | |
'prefer-exponentiation-operator': 'warn', | |
'prefer-object-spread': 'error', | |
'quote-props': ['warn', 'as-needed', { keywords: true, numbers: true }], | |
quotes: ['warn', 'single', { avoidEscape: true }], | |
semi: 'error', | |
'semi-spacing': ['warn', { before: false, after: true }], | |
'semi-style': 'warn', | |
'sort-keys': 'off', | |
'sort-vars': 'warn', | |
'space-before-blocks': ['warn', { functions: 'always', keywords: 'always' }], | |
'space-before-function-paren': ['warn', { anonymous: 'never', named: 'never' }], | |
'space-in-parens': 'warn', | |
'space-infix-ops': 'warn', | |
'space-unary-ops': ['warn', { words: true, nonwords: false }], | |
'spaced-comment': 'warn', | |
'switch-colon-spacing': 'warn', | |
'template-tag-spacing': 'error', | |
'unicode-bom': 'error', | |
'wrap-regex': 'error', | |
// ES6 | |
'arrow-body-style': 'error', | |
'arrow-parens': 'error', | |
'arrow-spacing': 'error', | |
'constructor-super': 'error', | |
'generator-star-spacing': 'error', | |
'no-class-assign': 'error', | |
'no-confusing-arrow': ['warn', { allowParens: true }], | |
'no-const-assign': 'error', | |
'no-dupe-class-members': 'error', | |
'no-duplicate-imports': 'error', | |
'no-new-symbol': 'error', | |
'no-restricted-exports': 'off', | |
'no-restricted-imports': ['error', 'domain', 'v8', 'vm'], | |
'no-this-before-super': 'error', | |
'no-useless-computed-key': 'error', | |
'no-useless-constructor': 'error', | |
'no-useless-rename': 'error', | |
'no-var': 'warn', | |
'object-shorthand': 'warn', | |
'prefer-arrow-callback': 'warn', | |
'prefer-const': 'warn', | |
'prefer-destructuring': 'warn', | |
'prefer-numeric-literals': 'warn', | |
'prefer-rest-params': 'warn', | |
'prefer-spread': 'warn', | |
'prefer-template': 'warn', | |
'require-yield': 'error', | |
'rest-spread-spacing': 'error', | |
'sort-imports': ['warn', { ignoreCase: true, ignoreDeclarationSort: true }], | |
'symbol-description': 'error', | |
'template-curly-spacing': 'error', | |
'yield-star-spacing': 'error', | |
// Plugin JSDoc | |
'jsdoc/check-access': 'error', | |
'jsdoc/check-alignment': 'warn', | |
'jsdoc/check-examples': 'warn', | |
'jsdoc/check-indentation': 'warn', | |
'jsdoc/check-param-names': 'error', | |
'jsdoc/check-property-names': 'error', | |
'jsdoc/check-syntax': 'warn', | |
'jsdoc/check-tag-names': 'error', | |
'jsdoc/check-types': 'error', | |
'jsdoc/check-values': 'error', | |
'jsdoc/empty-tags': 'error', | |
'jsdoc/implements-on-classes': 'error', | |
'jsdoc/match-description': 'off', | |
'jsdoc/newline-after-description': 'error', | |
'jsdoc/no-bad-blocks': 'warn', | |
'jsdoc/no-defaults': 'off', | |
'jsdoc/no-types': 'off', | |
'jsdoc/no-undefined-types': 'warn', | |
'jsdoc/require-description-complete-sentence': 'warn', | |
'jsdoc/require-description': 'warn', | |
'jsdoc/require-example': 'off', | |
'jsdoc/require-file-overview': 'off', | |
'jsdoc/require-hyphen-before-param-description': ['warn', 'never'], | |
'jsdoc/require-jsdoc': 'warn', | |
'jsdoc/require-param-description': 'error', | |
'jsdoc/require-param-name': 'error', | |
'jsdoc/require-param-type': 'error', | |
'jsdoc/require-param': 'error', | |
'jsdoc/require-property-description': 'error', | |
'jsdoc/require-property-name': 'error', | |
'jsdoc/require-property-type': 'error', | |
'jsdoc/require-returns-check': 'error', | |
'jsdoc/require-returns-description': 'error', | |
'jsdoc/require-returns-type': 'error', | |
'jsdoc/require-returns': 'error', | |
'jsdoc/require-throws': 'error', | |
'jsdoc/valid-types': 'error' | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This ESLint config has all rules defined, but some are turned off.
It also uses the typescript parser for ease of use in some cases and ease of configure (the babel parser is just harder to configure).