Package Exports
- eslint-config-esnext/style-guide
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (eslint-config-esnext) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Pluggable ESLint config for ECMAScript Next that you can import, extend and override
Usage
In your js project directory:
npm install --save-dev eslint-config-esnext
And in your .eslintrc.yaml
:
---
extends:
- esnext
- esnext/style-guide #optional
Alternatively, in your .eslintrc.js
or .eslintrc.json
:
{
"extends": ["esnext", "esnext/style-guide"]
}
To add a git-hook to your commits, consider using husky
npm install --save-dev husky
And in your package.json
:
"scripts": {
"precommit": "eslint ."
}
safety checks and best practices supporting commonly used ESNext features with a bias toward code concision / brevity
env:
es6: true
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
includes the following rules:
constructor-super
: requiresuper()
calls in constructorsno-case-declarations
: disallowlet
,const
,function
andclass
declarations incase
/default
clauses insideswitch
blocksno-class-assign
: disallow reassigning variables declared as classesno-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-native-reassign
: disallow assignments to native objects or read-only global variablesno-negated-in-lhs
: disallow negating the left operand inin
expressionsno-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 variablesrequire-yield
: require generator functions to containyield
use-isnan
: disallow comparisons withNaN
, requiring calls toisNaN()
insteadvalid-typeof
: enforce comparingtypeof
expressions against valid type strings
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
dot-notation
: enforce dot notation for accessing object properties whenever possibleeqeqeq
: prefer===
and!==
over==
and!=
no-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-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-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-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-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-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-escape
: disallow unnecessary escape charactersno-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()
style-guide: for consistency, readability and more brevity
---
plugins:
- babel
provides some alternatives to standard rules that are better compatible with babel-supported code
rules:
selected from here, configured to:
array-bracket-spacing
: enforce spacing inside array bracketsarrow-parens
: require parentheses around arrow function arguments,as-needed
arrow-spacing
: enforce spacing before and after=>
in arrow functionsbabel/generator-star-spacing
: alternative togenerator-star-spacing
that handlesasync
functions andawait
properlyblock-spacing
: enforce spacing inside single-line blocksbrace-style
: enforce K&R brace stylecamelcase
: enforce camelcase naming convention, ignore object propertiescomma-spacing
: disallow spacing before and enforce after commascomma-style
: allow commas only after and on the same line as an array element, object property, or variable declarationcomputed-property-spacing
: disallow spaces inside computed property bracketsconsistent-this
: allowthis
to only be assigned to a variable namedthat
curly
: require curly braces around blocks if they contain multiple statements, disallow braces if notdot-location
: require the dot in a member expression to be on the same line as the property portiongenerator-star-spacing
: enforce spacing before and disallow after*
operators in generator functionsindent
: enforce tabs (why?),SwitchCase: 1
; override in your.eslintrc
if you disagreekey-spacing
: disallow spacing after keys and enforce spacing before values in object literal propertieskeyword-spacing
: enforce spacing before and after keywordslinebreak-style
: enforce unix linebreaksnewline-per-chained-call
: require a newline after each call in a method chain exceeding 2 callsno-extra-parens
: disallow unnecessary parentheses; set to warn onlyno-multi-spaces
: disallow multiple spaces that are not used for indentationno-spaced-func
: disallow spacing betweenfunction
identifiers and their applicationsno-trailing-spaces
: disallow trailing whitespace at the end of linesno-whitespace-before-property
: disallow whitespace before propertiesobject-curly-newline
: require line breaks inside braces if there are line breaks inside properties or between properties in object literalsobject-curly-spacing
: enforce spacing inside curly bracesobject-property-newline
: enforce placing object properties on separate lines; set to warn onlyone-var-declaration-per-line
: require newlines around var initializationsoperator-linebreak
: require the line break to be placed before the operatorquote-props
: disallow unneeded quotes around object literal property namesquotes
: enforce single quotes, while allowing template literals and double quotes to avoid escape charactersrest-spread-spacing
: disallow spacing between rest and spread operators and their expressionssemi
: disallow semicolons (why?); override in your.eslintrc
if you disagreesemi-spacing
: disallow spacing before and enforce after semicolonssort-imports
: enforce sorted import declarations within modulesspace-before-blocks
: enforce spacing before blocksspace-before-function-paren
: enforce spacing beforefunction
definition opening parenthesisspace-in-parens
: disallow spacing inside parenthesesspace-infix-ops
: require spacing around operatorsspace-unary-ops
: require spacing between operand and unary word operators, disallow it between operand and unary non-word operatorspaced-comment
: enforce spacing after the//
or/*
in a commenttemplate-curly-spacing
: require spacing around embedded expressions of template stringsvalid-jsdoc
: enforce valid JSDoc comments; set to warn only