eslint-config-esnext
v4.1.0
Published
Pluggable eslint config for ECMAScript Next that you can import, extend and override
Downloads
322,126
Maintainers
Readme
Pluggable ESLint config for ECMAScript Next that you can import, extend and override
ESNext: Safety Checks and Best Practices with a bias toward code concision / brevity
Usage
In your js project directory:
npm install --save-dev eslint-config-esnext
And in your .eslintrc.yaml
:
extends:
- esnext
Alternatively, in your .eslintrc.js
or .eslintrc.json
:
{
"extends": ["esnext"]
}
To add a git-hook to your commits, consider using husky
npm install --save-dev husky
And in your package.json
:
"scripts": {
"precommit": "eslint ."
}
Config
This config is biased and opinionated, and errs on the side of too many rules instead of too few. Think of this as a superset of your repo's lint config, and discard what you don't like in it. It's easy to override and disable the rules you find inconvenient.
env:
es6: true
commonjs: true
enables ES6 features and CommonJS modules
parser: babel-eslint
enables parsing all babel supported code
parserOptions:
ecmaVersion: 7
sourceType: module
ecmaFeatures:
impliedStrict: true
modules: true
experimentalObjectRestSpread: true
allows es2015 modules and es2016 object rest and spread to be parsed, and applies strict mode to all js code
extends:
- eslint:recommended
- plugin:import/errors
- plugin:import/warnings
includes the following rules:
constructor-super
: requiresuper()
calls in constructorsfor-direction
: enforce that a for loop update clause moves the counter in the right directiongetter-return
: enforce that a return statement is present in property gettersno-case-declarations
: disallowlet
,const
,function
andclass
declarations incase
/default
clauses insideswitch
blocksno-class-assign
: disallow reassigning variables declared as classesno-compare-neg-zero
: disallow comparing against -0no-cond-assign
: disallow assignment operators in conditional expressionsno-console
: disallow the use ofconsole
no-const-assign
: disallow reassigningconst
variablesno-constant-condition
: disallow constant expressions in conditionsno-control-regex
: disallow control characters in regular expressionsno-debugger
: disallow the use ofdebugger
no-delete-var
: disallow deleting variablesno-dupe-args
: disallow duplicate arguments infunction
definitionsno-dupe-class-members
: disallow duplicate class membersno-dupe-keys
: disallow duplicate keys in object literalsno-duplicate-case
: disallow duplicate case labelsno-empty
: disallow empty block statementsno-empty-character-class
: disallow empty character classes in regular expressionsno-empty-pattern
: disallow empty destructuring patternsno-ex-assign
: disallow reassigning exceptions incatch
clausesno-extra-boolean-cast
: disallow unnecessary boolean castsno-extra-semi
: disallow unnecessary semicolonsno-fallthrough
: disallow fallthrough ofcase
statementsno-func-assign
: disallow reassigningfunction
declarationsno-inner-declarations
: disallowfunction
orvar
declarations in nested blocksno-invalid-regexp
: disallow invalid regular expression strings inRegExp
constructorsno-irregular-whitespace
: disallow irregular whitespace outside of strings and commentsno-mixed-spaces-and-tabs
: disallow mixed spaces and tabs for indentationno-new-symbol
: disallownew
operators with theSymbol
objectno-obj-calls
: disallow calling global object properties as functionsno-octal
: disallow octal literalsno-redeclare
: disallowvar
redeclarationno-regex-spaces
: disallow multiple spaces in regular expression literalsno-self-assign
: disallow assignments where both sides are exactly the sameno-sparse-arrays
: disallow sparse arraysno-this-before-super
: disallowthis
/super
before callingsuper()
in constructorsno-undef
: disallow the use of undeclared variables unless mentioned in/-global -/
commentsno-unexpected-multiline
: disallow multiline expressions likely to cause ASI errorsno-unreachable
: disallow unreachable code afterreturn
,throw
,continue
, andbreak
statementsno-unsafe-finally
: disallow control flow statements infinally
blocksno-unused-labels
: disallow unused labelsno-unused-vars
: disallow unused variablesno-useless-escape
: disallow unnecessary escape charactersrequire-yield
: require generator functions to containyield
use-isnan
: disallow comparisons withNaN
, requiring calls toisNaN()
insteadvalid-typeof
: enforce comparingtypeof
expressions against valid type stringsimport/no-unresolved
: ensure imports point to a file/module that can be resolvedimport/named
: ensure named imports correspond to a named export in the remote fileimport/namespace
: ensure imported namespaces contain dereferenced properties as they are dereferencedimport/default
: ensure a default export is present, given a default importimport/export
: report any invalid exports, i.e. re-export of the same nameimport/no-named-as-default
: report use of exported name as identifier of default export; set to warn onlyimport/no-named-as-default-member
: report use of exported name as property of default export; set to warn only
rules:
selected from here, configured to:
array-callback-return
: enforcereturn
statements in callbacks to array prototype methods such asmap
,reduce
,find
etc.arrow-body-style
: require braces around arrow function bodies,as-needed
class-methods-use-this
: disallow class methods that don't usethis
dot-notation
: enforce dot notation for accessing object properties whenever possibleeqeqeq
: prefer===
and!==
over==
and!=
import/no-amd
: report AMDrequire
anddefine
callsimport/no-commonjs
: report CommonJSrequire
calls andmodule.exports
orexports.*
import/no-duplicates
: report repeated import of the same module in multiple placesimport/no-extraneous-dependencies
: forbid the use of extraneous packagesimport/no-mutable-exports
: forbid the use of mutable exports withvar
orlet
import/no-namespace
: report namespace importsimport/no-nodejs-modules
: disallow node.js builtin modulesimport/prefer-default-export
: prefer a default export if module exports a single nameno-alert
: disallow the use ofalert
,confirm
, andprompt
no-constant-condition
: overrideeslint:recommended
withcheckLoops: false
to avoid errors in infinite generatorsno-duplicate-imports
: disallow duplicate module importsno-empty-function
: disallow empty functionsno-else-return
: disallowelse
blocks afterreturn
statements inif
blocksno-eval
: disallow the use ofeval()
no-extend-native
: disallow extending built-in or native objectsno-extra-bind
: disallow binding functions that don't usethis
no-global-assign
: disallow assignments to native objects or read-only global variablesno-implicit-globals
: disallowvar
and namedfunction
declarations in the global scope, doesn't apply to modulesno-implied-eval
: disallow the use of eval()-like methodsno-invalid-this
: disallowthis
outside of constructors, classes or methodsno-lonely-if
: disallowif
statements as the only statement inelse
blocksno-loop-func
: disallowfunction
s inside loopsno-new
: disallownew
operators outside of assignments or comparisonsno-new-func
: disallow creating functions with theFunction
constructorno-new-wrappers
: disallow creating objects with theString
,Number
, andBoolean
constructorsno-proto
: disallow use of the__proto__
propertyno-script-url
: disallowjavascript:
urlsno-self-compare
: disallow comparisons where both sides are exactly the sameno-throw-literal
: disallow throwing literals as exceptionsno-unmodified-loop-condition
: enforce updating the loop condition in each iterationno-unneeded-ternary
: disallow ternary operators when simpler alternatives exist;defaultAssignment: false
prefers||
for default assignmentsno-unsafe-negation
: disallow negating the left operand of relational operators likein
andinstanceof
no-unused-expressions
: disallow expressions that have no effect on the state of the program, withallowShortCircuit: true
andallowTernary: true
allowing&&
,||
and the ternary operator as shorthands forif
andelse
no-use-before-define
: disallow the use of variables before they are defined;nofunc
ignoresfunction
declarations since they're hoistedno-useless-call
: disallow unnecessary.call()
and.apply()
no-useless-computed-key
: disallow unnecessary computed property keys in object literalsno-useless-concat
: disallow unnecessary concatenation of literals or template literalsno-useless-constructor
: disallow unnecessary constructorsno-useless-rename
: disallow renamingimport
,export
, and destructured assignments to the same nameno-var
: requirelet
orconst
instead ofvar
no-with
: disallowwith
statementsobject-shorthand
: require method and property shorthand syntax for object literalsoperator-assignment
: require assignment operator shorthand where possibleprefer-arrow-callback
: require callbacks to be arrow functionsprefer-const
: requireconst
declarations for variables that are never reassigned after declaredprefer-rest-params
: require rest parameters instead ofarguments
prefer-spread
: require spread operator instead of.apply()