scode-eslint-config/index.js

277 lines
9.4 KiB
JavaScript

module.exports = {
globals: {},
extends: 'eslint:recommended',
rules: {
// Possible Errors https://eslint.org/docs/rules/#possible-errors
'no-await-in-loop': 'warn',
'no-console': 'warn',
'no-constant-condition': ['error', { checkLoops: false }],
'no-dupe-else-if': 'error',
'no-extra-parens': ['error', 'all', { conditionalAssign: false }],
'no-import-assign': 'error',
'no-setter-return': 'error',
'no-template-curly-in-string': 'error',
'valid-typeof': ['error', { requireStringLiterals: true }],
// Best Practices https://eslint.org/docs/rules/#best-practices
'array-callback-return': ['error', { allowImplicit: false }],
'block-scoped-var': 'error',
'class-methods-use-this': 'error',
complexity: ['warn', { max: 5 }],
'consistent-return': ['error', { treatUndefinedAsUnspecified: false }],
curly: ['error', 'multi'],
'default-case': ['error', { commentPattern: '^no\\sdefault' }],
'default-param-last': 'error',
'dot-location': ['error', 'property'],
'dot-notation': ['error', { allowKeywords: true }],
eqeqeq: ['error', 'always'],
'grouped-accessor-pairs': ['error', 'getBeforeSet'],
'guard-for-in': 'error',
'max-classes-per-file': ['error', 1],
'no-alert': 'error',
'no-caller': 'error',
'no-constructor-return': 'error',
'no-div-regex': 'error',
'no-else-return': ['error', { allowElseIf: false }],
'no-empty-function': 'error',
'no-eq-null': 'error',
'no-eval': ['error', { allowIndirect: false }],
'no-extend-native': 'error',
'no-extra-bind': 'error',
'no-extra-label': 'error',
'no-fallthrough': ['error', { commentPattern: 'break[\\s\\w]*omitted' }],
'no-floating-decimal': 'error',
'no-implicit-coercion': 'error',
'no-implicit-globals': 'error',
'no-implied-eval': 'error',
'no-invalid-this': 'error',
'no-iterator': 'error',
'no-lone-blocks': 'error',
'no-loop-func': 'error',
'no-magic-numbers': ['error', { enforceConst: true, ignoreArrayIndexes: true, detectObjects: false }],
'no-multi-spaces': 'error',
'no-multi-str': 'error',
'no-new': 'error',
'no-new-func': 'error',
'no-new-wrappers': 'error',
'no-octal-escape': 'error',
'no-param-reassign': 'error',
'no-proto': 'error',
'no-restricted-properties': 'error',
'no-return-assign': ['error', 'except-parens'],
'no-return-await': 'error',
'no-script-url': 'error',
'no-self-compare': 'error',
'no-sequences': 'error',
'no-throw-literal': 'error',
'no-unmodified-loop-condition': 'error',
'no-unused-expressions': 'error',
'no-useless-call': 'error',
'no-useless-concat': 'error',
'no-useless-return': 'error',
'no-void': 'error',
'no-warning-comments': 'warn',
'prefer-named-capture-group': 'warn',
'prefer-promise-reject-errors': 'error',
'prefer-regex-literals': 'error',
radix: ['error', 'as-needed'],
'require-await': 'error',
'require-unicode-regexp': 'error',
'vars-on-top': 'error',
'wrap-iife': ['error', 'inside'],
yoda: ['error', 'always', { exceptRange: true }],
// Strict Mode https://eslint.org/docs/rules/#strict-mode
strict: ['error', 'safe'],
// Variables https://eslint.org/docs/rules/#variables
'init-declarations': ['error', 'always'],
'no-label-var': 'error',
'no-shadow': ['error', { builtinGlobals: true, hoist: 'all' }],
'no-undef-init': 'error',
'no-undefined': 'error',
'no-use-before-define': 'error',
// Node.js and CommonJS https://eslint.org/docs/rules/#node-js-and-commonjs
'callback-return': 'error',
'global-require': 'error',
'handle-callback-err': 'error',
'no-buffer-constructor': 'error',
'no-mixed-requires': 'error',
'no-new-require': 'error',
'no-path-concat': 'error',
'no-process-env': 'warn',
'no-process-exit': 'warn',
'no-sync': ['error', { allowAtRootLevel: true }],
// Stylistic Issues https://eslint.org/docs/rules/#stylistic-issues
'array-bracket-newline': ['error', { multiline: true, minItems: 2 }],
'array-bracket-spacing': ['error', 'always'],
'array-element-newline': ['error', { multiline: true, minItems: 2 }],
'block-spacing': ['error', 'always'],
'brace-style': ['error', 'stroustrup', { allowSingleLine: true }],
camelcase: 'error',
'comma-dangle': ['error', 'never'],
'comma-spacing': 'error',
'comma-style': 'error',
'computed-property-spacing': ['error', 'never'],
'consistent-this': 'error',
'eol-last': 'error',
'func-call-spacing': ['error', 'always'],
'func-name-matching': ['error', 'always'],
'func-names': ['error', 'always'],
'func-style': ['error', 'declaration', { allowArrowFunctions: false }],
'function-call-argument-newline': ['error', 'consistent'],
'function-paren-newline': ['error', 'multiline-arguments'],
'implicit-arrow-linebreak': ['error', 'beside'],
indent: ['error', 2],
'jsx-quotes': 'error',
'key-spacing': [
'error',
{
singleLine: {
beforeColon: false,
afterColon: true,
mode: 'strict'
},
align: {
on: 'value',
beforeColon: false,
afterColon: true,
mode: 'minimum'
},
multiLine: {
beforeColon: false,
afterColon: true,
mode: 'strict'
}
}
],
'keyword-spacing': 'error',
'line-comment-position': 'error',
'linebreak-style': ['error', 'unix'],
'lines-around-comment': [
'error',
{
beforeBlockComment: true,
beforeLineComment: true
}
],
'lines-between-class-members': [
'error',
'always',
{ exceptAfterSingleLine: true }
],
'max-depth': ['error', 4],
'max-len': ['error', { code: 80, tabWidth: 4 }],
'max-lines': [
'error',
{
max: 300,
skipBlankLines: true,
skipComments: true
}
],
'max-lines-per-function': [
'error',
{
max: 50,
skipBlankLines: true,
skipComments: true,
IIFEs: true
}],
'max-nested-callbacks': ['error', 3],
'max-params': ['error', 3],
'max-statements': ['error', 20],
'max-statements-per-line': 'error',
'multiline-comment-style': ['error', 'starred-block'],
'multiline-ternary': ['error', 'always-multiline'],
'new-cap': 'error',
'new-parens': ['error', 'never'],
'newline-per-chained-call': ['error', { ignoreChainWithDepth: 1 }],
'no-array-constructor': 'error',
'no-bitwise': 'warn',
'no-inline-comments': 'error',
'no-lonely-if': 'error',
'no-mixed-operators': 'error',
'no-multi-assign': 'error',
'no-multiple-empty-lines': ['error', { max: 2, maxEOF: 1, maxBOF: 0 }],
'no-negated-condition': 'error',
'no-nested-ternary': 'error',
'no-new-object': 'error',
'no-tabs': 'error',
'no-trailing-spaces': 'error',
'no-underscore-dangle': 'error',
'no-unneeded-ternary': 'error',
'no-whitespace-before-property': 'error',
'nonblock-statement-body-position': ['error', 'below'],
'object-curly-newline': ['error', { multiline: true }],
'object-curly-spacing': ['error', 'always'],
'object-property-newline': ['error', { allowAllPropertiesOnSameLine: true }],
'one-var': ['error', 'never'],
'one-var-declaration-per-line': ['error', 'always'],
'operator-assignment': ['error', 'always'],
'operator-linebreak': ['error', 'before'],
'padded-blocks': ['error', 'never'],
'prefer-exponentiation-operator': 'error',
'prefer-object-spread': 'error',
'quote-props': ['error', 'as-needed'],
quotes: ['error', 'single'],
semi: ['error', 'always'],
'semi-spacing': 'error',
'semi-style': 'error',
'sort-keys': [
'warn',
'asc',
{
minKeys: 10,
natural: true,
caseSensitive: true
}
],
'space-before-blocks': ['error', 'always'],
'space-before-function-paren': ['error', 'always'],
'space-in-parens': ['error', 'never'],
'space-infix-ops': 'error',
'space-unary-ops': [
'error', {
words: true,
nonwords: false
}],
'spaced-comment': ['error', 'always'],
'switch-colon-spacing': 'error',
'template-tag-spacing': 'error',
'unicode-bom': 'error',
'wrap-regex': 'error',
// ECMAScript 6 https://eslint.org/docs/rules/#ecmascript-6
'arrow-body-style': ['error', 'as-needed'],
'arrow-parens': 'error',
'arrow-spacing': 'error',
'generator-star-spacing': 'error',
'no-confusing-arrow': 'error',
'no-duplicate-imports': 'error',
'no-useless-computed-key': 'error',
'no-useless-constructor': 'error',
'no-useless-rename': 'error',
'no-var': 'error',
'object-shorthand': 'error',
'prefer-arrow-callback': 'error',
'prefer-const': 'error',
'prefer-destructuring': 'error',
'prefer-numeric-literals': 'error',
'prefer-rest-params': 'error',
'prefer-spread': 'error',
'prefer-template': 'error',
'rest-spread-spacing': 'error',
'sort-imports': 'error',
'symbol-description': 'error',
'template-curly-spacing': 'error',
'yield-star-spacing': 'error'
}
}