eslint-config-vtex
Version:
VTEX's eslint config
304 lines (244 loc) • 9.75 kB
JavaScript
module.exports = {
rules: {
// Enforces return statements in callbacks of array's methods
// https://eslint.org/docs/rules/array-callback-return
'array-callback-return': ['error', { allowImplicit: true }],
// Treat var statements as if they were block scoped
// https://eslint.org/docs/rules/block-scoped-var
'block-scoped-var': 'error',
// Require default case in switch statements
// https://eslint.org/docs/rules/default-case
'default-case': ['error', { commentPattern: '^no default$' }],
// Disallow case statement fallthrough
// https://eslint.org/docs/rules/no-fallthrough
'no-fallthrough': [
'error',
{
commentPattern: '(break[\\s\\w]*omitted|falls\\s?through)',
},
],
// Enforce parameters with default values to be last
// https://eslint.org/docs/rules/default-param-last
'default-param-last': 'error',
// Encourages use of dot notation whenever possible
// https://eslint.org/docs/rules/dot-notation
'dot-notation': ['error', { allowKeywords: true }],
// Require the use of === and !==
// https://eslint.org/docs/rules/eqeqeq
eqeqeq: ['error', 'always', { null: 'ignore' }],
// Require grouped accessor pairs in object literals and classes
// https://eslint.org/docs/rules/grouped-accessor-pairs
'grouped-accessor-pairs': 'error',
// Enforce a maximum number of classes per file
// https://eslint.org/docs/rules/max-classes-per-file
// TODO, maybe turn on
'max-classes-per-file': ['off', 1],
// Disallow the use of alert, confirm, and prompt
// https://eslint.org/docs/rules/no-alert
'no-alert': 'warn',
// Disallow use of arguments.caller or arguments.callee
// https://eslint.org/docs/rules/no-caller
'no-caller': 'error',
// Disallow lexical declarations in case/default clauses
// https://eslint.org/docs/rules/no-case-declarations
'no-case-declarations': 'error',
// Disallow returning value in constructor
// https://eslint.org/docs/rules/no-constructor-return
'no-constructor-return': 'error',
// Disallow else after a return in an if
// https://eslint.org/docs/rules/no-else-return
'no-else-return': ['error', { allowElseIf: false }],
// Disallow empty functions, except for standalone funcs/arrows
// https://eslint.org/docs/rules/no-empty-function
'no-empty-function': [
'error',
{
allow: ['arrowFunctions', 'functions', 'methods'],
},
],
// Disallow use of eval()
// https://eslint.org/docs/rules/no-eval
'no-eval': 'error',
// Disallow adding to native types
// https://eslint.org/docs/rules/no-extend-native
'no-extend-native': 'error',
// Disallow unnecessary function binding
// https://eslint.org/docs/rules/no-extra-bind
'no-extra-bind': 'error',
// Disallow Unnecessary Labels
// https://eslint.org/docs/rules/no-extra-label
'no-extra-label': 'error',
// Disallow the use of leading or trailing decimal points in numeric literals
// https://eslint.org/docs/rules/no-floating-decimal
// Disabled because prettier already handle this rule
'no-floating-decimal': 'off',
// Disallow reassignments of native objects or read-only globals
// https://eslint.org/docs/rules/no-global-assign
'no-global-assign': 'error',
// Disallow use of eval()-like methods
// https://eslint.org/docs/rules/no-implied-eval
'no-implied-eval': 'error',
// Disallow usage of __iterator__ property
// https://eslint.org/docs/rules/no-iterator
'no-iterator': 'error',
// Disallow use of labels for anything other then loops and switches
// https://eslint.org/docs/rules/no-labels
'no-labels': 'error',
// Disallow unnecessary nested blocks
// https://eslint.org/docs/rules/no-lone-blocks
'no-lone-blocks': 'error',
// Disallow creation of functions within loops
// https://eslint.org/docs/rules/no-loop-func
'no-loop-func': 'error',
// Disallow magic numbers
// https://eslint.org/docs/rules/no-magic-numbers
// TODO enable? maybe too much
'no-magic-numbers': [
'off',
{
ignore: [0, 1, 2, 3],
ignoreArrayIndexes: true,
enforceConst: true,
detectObjects: false,
},
],
// Disallow use of multiline strings
// https://eslint.org/docs/rules/no-multi-str
'no-multi-str': 'error',
// Disallow use of new operator for Function object
// https://eslint.org/docs/rules/no-new-func
'no-new-func': 'error',
// Disallows creating new instances of String, Number, and Boolean
// https://eslint.org/docs/rules/no-new-wrappers
'no-new-wrappers': 'error',
// Disallow use of octal escape sequences in string literals, such as
// var foo = 'Copyright \251';
// https://eslint.org/docs/rules/no-octal-escape
'no-octal-escape': 'error',
// Disallow usage of __proto__ property
// https://eslint.org/docs/rules/no-proto
'no-proto': 'error',
// Disallow declaring the same variable more then once
// https://eslint.org/docs/rules/no-redeclare
'no-redeclare': 'error',
// Disallow use of assignment in return statement
// https://eslint.org/docs/rules/no-return-assign
'no-return-assign': ['error', 'except-parens'],
// Disallow redundant `return await`
// https://eslint.org/docs/rules/no-return-await
'no-return-await': 'error',
// Disallow use of `javascript:` urls.
// https://eslint.org/docs/rules/no-script-url
'no-script-url': 'error',
// Disallow comparisons where both sides are exactly the same
// https://eslint.org/docs/rules/no-self-compare
'no-self-compare': 'error',
// Disallow use of comma operator
// https://eslint.org/docs/rules/no-sequences
'no-sequences': 'error',
// Disallow unused labels
// https://eslint.org/docs/rules/no-unused-labels
'no-unused-labels': 'error',
// Disallow unnecessary catch clauses
// https://eslint.org/docs/rules/no-useless-catch
// TODO enable?
'no-useless-catch': 'off',
// Disallow unnecessary string escaping
// https://eslint.org/docs/rules/no-useless-escape
'no-useless-escape': 'error',
// Disallow redundant return; keywords
// https://eslint.org/docs/rules/no-useless-return
'no-useless-return': 'error',
// Disallow use of void operator
// https://eslint.org/docs/rules/no-void
'no-void': 'error',
// Prefer using regex literals instead of constructor
// https://eslint.org/docs/rules/prefer-regex-literals
'prefer-regex-literals': 'warn',
// Require use of the second argument for parseInt()
// https://eslint.org/docs/rules/radix
radix: 'error',
// Requires to declare all vars on top of their containing scope
// https://eslint.org/docs/rules/vars-on-top
'vars-on-top': 'error',
// https://eslint.org/docs/rules/constructor-super
'constructor-super': 'error',
// Disallow useless computed property keys
// https://eslint.org/docs/rules/no-useless-computed-key
'no-useless-computed-key': 'error',
// Disallow unnecessary constructor
// https://eslint.org/docs/rules/no-useless-constructor
'no-useless-constructor': 'error',
// Disallow renaming import, export, and destructured assignments to the same name
// https://eslint.org/docs/rules/no-useless-rename
'no-useless-rename': ['error'],
// Require let or const instead of var
// https://eslint.org/docs/rules/no-var
'no-var': 'error',
// Require method and property shorthand syntax for object literals
// https://eslint.org/docs/rules/object-shorthand
'object-shorthand': [
'error',
'always',
{
ignoreConstructors: false,
avoidQuotes: true,
},
],
// Suggest using arrow functions as callbacks
// https://eslint.org/docs/rules/prefer-arrow-callback
// TODO discussion
'prefer-arrow-callback': [
'off',
{
allowNamedFunctions: false,
allowUnboundThis: true,
},
],
// Suggest using of const declaration for variables that are never modified after declared
// https://eslint.org/docs/rules/prefer-const
'prefer-const': [
'error',
{
destructuring: 'all',
ignoreReadBeforeAssign: true,
},
],
// Prefer destructuring from arrays and objects
// https://eslint.org/docs/rules/prefer-destructuring
'prefer-destructuring': [
'warn',
{
VariableDeclarator: {
array: true,
object: true,
},
AssignmentExpression: {
array: false,
object: false,
},
},
{
enforceForRenamedProperties: false,
},
],
// Disallow parseInt() in favor of binary, octal, and hexadecimal literals
// https://eslint.org/docs/rules/prefer-numeric-literals
'prefer-numeric-literals': 'error',
// Use rest parameters instead of arguments
// https://eslint.org/docs/rules/prefer-rest-params
'prefer-rest-params': 'error',
// Suggest using the spread operator instead of .apply()
// https://eslint.org/docs/rules/prefer-spread
'prefer-spread': 'error',
// Suggest using template literals instead of string concatenation
// https://eslint.org/docs/rules/prefer-template
'prefer-template': 'warn',
// Disallow generator functions that do not have yield
// https://eslint.org/docs/rules/require-yield
'require-yield': 'error',
// Require a Symbol description
// https://eslint.org/docs/rules/symbol-description
'symbol-description': 'error',
},
}