@jwalsh/eslint-config-esnext v1.6.2
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-esnextAnd in your .eslintrc.yaml:
---
extends:
- esnextAlternatively, in your .eslintrc.js or .eslintrc.json:
{
"extends": ["esnext"]
}To add a git-hook to your commits, consider using husky
npm install --save-dev huskyAnd 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: trueenables ES6 features and CommonJS modules
parser: babel-eslintenables parsing all babel supported code
parserOptions:
ecmaVersion: 7
sourceType: module
ecmaFeatures:
impliedStrict: true
modules: true
experimentalObjectRestSpread: trueallows 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/warningsincludes the following rules:
constructor-super: requiresuper()calls in constructorsno-case-declarations: disallowlet,const,functionandclassdeclarations incase/defaultclauses insideswitchblocksno-class-assign: disallow reassigning variables declared as classesno-cond-assign: disallow assignment operators in conditional expressionsno-console: disallow the use ofconsoleno-const-assign: disallow reassigningconstvariablesno-constant-condition: disallow constant expressions in conditionsno-control-regex: disallow control characters in regular expressionsno-debugger: disallow the use ofdebuggerno-delete-var: disallow deleting variablesno-dupe-args: disallow duplicate arguments infunctiondefinitionsno-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 incatchclausesno-extra-boolean-cast: disallow unnecessary boolean castsno-extra-semi: disallow unnecessary semicolonsno-fallthrough: disallow fallthrough ofcasestatementsno-func-assign: disallow reassigningfunctiondeclarationsno-inner-declarations: disallowfunctionorvardeclarations in nested blocksno-invalid-regexp: disallow invalid regular expression strings inRegExpconstructorsno-irregular-whitespace: disallow irregular whitespace outside of strings and commentsno-mixed-spaces-and-tabs: disallow mixed spaces and tabs for indentationno-new-symbol: disallownewoperators with theSymbolobjectno-obj-calls: disallow calling global object properties as functionsno-octal: disallow octal literalsno-redeclare: disallowvarredeclarationno-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/superbefore 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, andbreakstatementsno-unsafe-finally: disallow control flow statements infinallyblocksno-unused-labels: disallow unused labelsno-unused-vars: disallow unused variablesrequire-yield: require generator functions to containyielduse-isnan: disallow comparisons withNaN, requiring calls toisNaN()insteadvalid-typeof: enforce comparingtypeofexpressions 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: enforcereturnstatements in callbacks to array prototype methods such asmap,reduce,findetc.arrow-body-style: require braces around arrow function bodies,as-neededclass-methods-use-this: disallow class methods that don't usethisdot-notation: enforce dot notation for accessing object properties whenever possibleeqeqeq: prefer===and!==over==and!=import/no-amd: report AMDrequireanddefinecallsimport/no-commonjs: report CommonJSrequirecalls andmodule.exportsorexports.*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 withvarorletimport/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, andpromptno-constant-condition: overrideeslint:recommendedwithcheckLoops: falseto avoid errors in infinite generatorsno-duplicate-imports: disallow duplicate module importsno-empty-function: disallow empty functionsno-else-return: disallowelseblocks afterreturnstatements inifblocksno-eval: disallow the use ofeval()no-extend-native: disallow extending built-in or native objectsno-extra-bind: disallow binding functions that don't usethisno-global-assign: disallow assignments to native objects or read-only global variablesno-implicit-globals: disallowvarand namedfunctiondeclarations in the global scope, doesn't apply to modulesno-implied-eval: disallow the use of eval()-like methodsno-invalid-this: disallowthisoutside of constructors, classes or methodsno-lonely-if: disallowifstatements as the only statement inelseblocksno-loop-func: disallowfunctions inside loopsno-new: disallownewoperators outside of assignments or comparisonsno-new-func: disallow creating functions with theFunctionconstructorno-new-wrappers: disallow creating objects with theString,Number, andBooleanconstructorsno-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: falseprefers||for default assignmentsno-unsafe-negation: disallow negating the left operand of relational operators likeinandinstanceofno-unused-expressions: disallow expressions that have no effect on the state of the program, withallowShortCircuit: trueandallowTernary: trueallowing&&,||and the ternary operator as shorthands forifandelseno-use-before-define: disallow the use of variables before they are defined;nofuncignoresfunctiondeclarations 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-escape: disallow unnecessary escape charactersno-useless-rename: disallow renamingimport,export, and destructured assignments to the same nameno-var: requireletorconstinstead ofvarno-with: disallowwithstatementsobject-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: requireconstdeclarations for variables that are never reassigned after declaredprefer-rest-params: require rest parameters instead ofargumentsprefer-spread: require spread operator instead of.apply()