Skip to content

Instantly share code, notes, and snippets.

@bladerunner2020
Created November 24, 2021 13:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bladerunner2020/859156eee3c4ce3fc254c3bbd688ecca to your computer and use it in GitHub Desktop.
Save bladerunner2020/859156eee3c4ce3fc254c3bbd688ecca to your computer and use it in GitHub Desktop.
Airbnb-bases eslint rules (as a separate file, not complete)
env:
commonjs: false
es6: false
node: true
jest: true
globals:
$: readonly
createSharedVariable: readonly
Atomics: readonly
SharedArrayBuffer: readonly
parserOptions:
ecmaVersion: 3
sourceType: "script"
rules:
accessor-pairs: error
array-callback-return: error
block-scoped-var: error
complexity: [off, 20]
consistent-return: error
curly: [error, multi-line]
default-case: [error, { commentPattern: '^no default$' }]
default-param-last: error
dot-notation: [error, { allowKeywords: true }]
dot-location: [error, 'property']
eqeqeq: [error, 'always', { null: 'ignore' }]
grouped-accessor-pairs: error
guard-for-in: error
no-alert: warn
no-caller: error
no-case-declarations: error
no-constructor-return: error
no-div-regex: off
no-empty-pattern: error
no-eq-null: off
no-eval: error
no-extend-native: error
no-extra-label: error
no-fallthrough: error
no-floating-decimal: error
no-global-assign: error
no-native-reassign: off
no-implicit-coercion: [off, { boolean: false, number: true, string: true }]
no-implicit-globals: off
no-implied-eval: error
no-invalid-this: off
no-iterator: error
no-labels: [error, { allowLoop: false, allowSwitch: false }]
no-lone-blocks: error
no-loop-func: error
no-magic-numbers': [off, { ignoreArrayIndexes: true, detectObjects: false }]
no-multi-spaces: [error, { ignoreEOLComments: false }]
no-new: error
no-new-wrappers: error
no-octal: error
no-octal-escape: error
no-param-reassign: [error, {
props: true,
ignorePropertyModificationsFor: [
'acc', # for reduce accumulators
'accumulator', # for reduce accumulators
'e', # for e.returnvalue
'ctx', # for Koa routing
'context', # for Koa routing
'req', # for Express requests
'request', # for Express requests
'res', # for Express responses
'response', # for Express responses
'$scope', # for Angular 1 scopes
'staticContext' # for ReactRouter context
]
}]
no-proto: error
no-redeclare: error
no-restricted-properties: [error, {
object: 'arguments',
property: 'callee',
message: 'arguments.callee is deprecated',
}, {
object: 'global',
property: 'isFinite',
message: 'Please use Number.isFinite instead',
}, {
object: 'self',
property: 'isFinite',
message: 'Please use Number.isFinite instead',
}, {
object: 'window',
property: 'isFinite',
message: 'Please use Number.isFinite instead',
}, {
object: 'global',
property: 'isNaN',
message: 'Please use Number.isNaN instead',
}, {
object: 'self',
property: 'isNaN',
message: 'Please use Number.isNaN instead',
}, {
object: 'window',
property: 'isNaN',
message: 'Please use Number.isNaN instead',
}, {
property: '__defineGetter__',
message: 'Please use Object.defineProperty instead.',
}, {
property: '__defineSetter__',
message: 'Please use Object.defineProperty instead.',
}, {
object: 'Math',
property: 'pow',
message: 'Use the exponentiation operator (**) instead.',
}]
no-return-assign: [error, 'always']
no-script-url: error
no-self-assign: error
no-self-compare: error
no-sequences: error
no-throw-literal: error
no-unmodified-loop-condition: off
no-unused-labels: error
no-useless-call: off
no-useless-catch: error
no-useless-concat: error
no-useless-escape: error
no-useless-return: error
no-void: error
no-warning-comments: [off, { terms: ['todo', 'fixme', 'xxx'], location: 'start' }]
no-with: error
prefer-named-capture-group: off
radix: error
require-unicode-regexp: off
vars-on-top: off
array-bracket-newline: [off, 'consistent']
array-element-newline: [off, { multiline: true, minItems: 3 }]
array-bracket-spacing: [error, 'never']
block-spacing: [error, 'always']
brace-style: [error, '1tbs', { allowSingleLine: true }]
camelcase: [error, { properties: 'never', ignoreDestructuring: false }]
capitalized-comments: [off, 'never', {
line: {
ignorePattern: '.*',
ignoreInlineComments: true,
ignoreConsecutiveComments: true,
},
block: {
ignorePattern: '.*',
ignoreInlineComments: true,
ignoreConsecutiveComments: true,
},
}]
comma-dangle: [error, "never"]
comma-spacing: [error, { before: false, after: true }]
comma-style: [error, 'last', {
exceptions: {
ArrayExpression: false,
ArrayPattern: false,
ArrowFunctionExpression: false,
CallExpression: false,
FunctionDeclaration: false,
FunctionExpression: false,
ImportDeclaration: false,
ObjectExpression: false,
ObjectPattern: false,
VariableDeclaration: false,
NewExpression: false,
}
}]
computed-property-spacing: [error, 'never']
consistent-this: off
eol-last: [error, 'always']
function-call-argument-newline: [error, 'consistent']
func-call-spacing: [error, 'never']
func-name-matching: [off, 'always', {
includeCommonJSModuleExports: false,
considerPropertyDescriptor: true,
}]
func-names: [error, "never"]
func-style: [off, 'expression']
function-paren-newline: [error, 'multiline-arguments']
id-length: off
id-match: off
id-blacklist: [error, "State"]
indent: [error, 2, {
SwitchCase: 1,
VariableDeclarator: 1,
outerIIFEBody: 1,
FunctionDeclaration: {
parameters: 1,
body: 1
},
FunctionExpression: {
parameters: 1,
body: 1
},
CallExpression: {
arguments: 1
},
ArrayExpression: 1,
ObjectExpression: 1,
ImportDeclaration: 1,
flatTernaryExpressions: false,
## list derived from https://github.com/benjamn/ast-types/blob/HEAD/def/jsx.js
ignoreComments: false
}]
key-spacing: [error, { beforeColon: false, afterColon: true }]
keyword-spacing: [error, {
before: true,
after: true,
overrides: {
return: { after: true },
throw: { after: true },
case: { after: true }
}
}]
line-comment-position: [off, {
position: 'above',
ignorePattern: '',
applyDefaultPatterns: true,
}]
linebreak-style: [error, 'unix']
lines-between-class-members: [error, 'always', { exceptAfterSingleLine: false }]
lines-around-comment: off
lines-around-directive: [error, {
before: 'always',
after: 'always'
}]
max-depth: [off, 4]
max-len: [error, 120, 2, {
ignoreUrls: true,
ignoreComments: false,
ignoreRegExpLiterals: true,
ignoreStrings: true,
ignoreTemplateLiterals: true
}]
max-lines: [off, {
max: 300,
skipBlankLines: true,
skipComments: true
}]
max-lines-per-function: [off, {
max: 50,
skipBlankLines: true,
skipComments: true,
IIFEs: true
}]
max-nested-callbacks: off
max-params: [off, 3]
max-statements: [off, 10]
max-statements-per-line: [off, { max: 1 }]
multiline-comment-style: [off, 'starred-block']
multiline-ternary: [off, 'never']
new-cap: [error, {
newIsCap: true,
newIsCapExceptions: [],
capIsNew: false,
capIsNewExceptions: ['Immutable.Map', 'Immutable.Set', 'Immutable.List'],
}]
new-parens: error
newline-after-var: off
newline-before-return: off
newline-per-chained-call: [error, { ignoreChainWithDepth: 4 }]
no-array-constructor: error
no-bitwise: error
no-continue: error
no-inline-comments: off
no-lonely-if: error
no-mixed-operators: [error, {
groups: [
['%', '**'],
['%', '+'],
['%', '-'],
['%', '*'],
['%', '/'],
['/', '*'],
['&', '|', '<<', '>>', '>>>'],
['==', '!=', '===', '!=='],
['&&', '||'],
],
allowSamePrecedence: false
}]
no-mixed-spaces-and-tabs: error
no-multi-assign: [error]
no-multiple-empty-lines: [error, { max: 1, maxBOF: 0, maxEOF: 0 }]
no-negated-condition: off
no-nested-ternary: error
no-new-object: error
no-plusplus: [error, {"allowForLoopAfterthoughts": true}]
no-restricted-syntax: [
error,
{
selector: 'ForInStatement',
message: 'for..in loops iterate over the entire prototype chain, which is virtually never what you want. Use Object.{keys,values,entries}, and iterate over the resulting array.',
},
{
selector: 'ForOfStatement',
message: 'iterators/generators require regenerator-runtime, which is too heavyweight for this guide to allow them. Separately, loops should be avoided in favor of array iterations.',
},
{
selector: 'LabeledStatement',
message: 'Labels are a form of GOTO; using them makes code confusing and hard to maintain and understand.',
},
{
selector: 'WithStatement',
message: '`with` is disallowed in strict mode because it makes code impossible to predict and optimize.',
},
]
no-spaced-func: error
no-tabs: error
no-ternary: off
no-trailing-spaces: [error, {
skipBlankLines: false,
ignoreComments: false
}]
no-underscore-dangle: [error, {
allowAfterThis: false,
allowAfterSuper: false,
enforceInMethodNames: true
}]
no-unneeded-ternary: [error, { defaultAssignment: false }]
no-whitespace-before-property: error
nonblock-statement-body-position: [error, 'beside', { overrides: {} }]
object-curly-spacing: [error, 'always']
object-curly-newline: [error, {
ObjectExpression: { minProperties: 4, multiline: true, consistent: true },
ObjectPattern: { minProperties: 4, multiline: true, consistent: true },
ImportDeclaration: { minProperties: 4, multiline: true, consistent: true },
ExportDeclaration: { minProperties: 4, multiline: true, consistent: true },
}]
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, { overrides: { '=': 'none' } }]
padded-blocks: [error, {
blocks: never,
classes: never,
switches: never,
}, {
allowSingleLineBlocks: true,
}]
padding-line-between-statements: off
prefer-exponentiation-operator: error
prefer-object-spread: [off, never]
quote-props: [error, as-needed, { keywords: false, unnecessary: true, numbers: false }]
quotes: [error, single, { avoidEscape: true }]
require-jsdoc: off
semi: [error, always]
semi-spacing: [error, { before: false, after: true }]
semi-style: [error, last]
sort-keys: [off, asc, { caseSensitive: false, natural: true }]
sort-vars: off
space-before-blocks: error
space-before-function-paren: [error, "never"]
space-in-parens: [error, never]
space-infix-ops: error
space-unary-ops: [error, {
words: true,
nonwords: false,
overrides: {
},
}]
spaced-comment: [error, always, {
line: {
exceptions: ['-', '+'],
markers: ['=', '!', '/']
},
block: {
exceptions: ['-', '+'],
markers: ['=', '!', ':', '::'],
balanced: true,
}
}]
switch-colon-spacing: [error, { after: true, before: false }]
template-tag-spacing: [error, never]
unicode-bom: [error, never]
wrap-regex: off
init-declarations: off
no-catch-shadow: off
no-delete-var: error
no-label-var: error
no-restricted-globals: [error,
{
name: 'isFinite',
message:
'Use Number.isFinite instead https://github.com/airbnb/javascript#standard-library--isfinite',
},
{
name: 'isNaN',
message:
'Use Number.isNaN instead https://github.com/airbnb/javascript#standard-library--isnan',
},
]
no-shadow: error
no-shadow-restricted-names: error
no-undef: error
no-undef-init: error
no-undefined: off
no-unused-vars: ['error', { vars: 'all', args: 'after-used', ignoreRestSiblings: true }]
no-use-before-define: [error, { "functions": false }]
no-var: 0
prefer-template: 0
prefer-arrow-callback: 0
prefer-destructuring: 0
object-shorthand: 0
prefer-rest-params: 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment