Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 1,000,000+ packages pre-installed, including @xwtec/eslint-config with all npm packages installed. Try it out:

require("eslint/package.json"); // eslint is a peer dependency. require("prettier/package.json"); // prettier is a peer dependency. var eslintConfig = require("@xwtec/eslint-config")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

@xwtec/eslint-config v6.4.0

ESLint Configuration for xwtec projects

@xwtec/eslint-config

devDependencies Issues Issues GitHub last commit GitHub Release Date

npm npm Snyk Vulnerabilities for npm package version

styled with prettier MIT license

ESLint Configuration for xwtec projects

Install

# with yarn
yarn add --dev eslint prettier @xwtec/eslint-config @xwtec/prettier-config

# with npm
npm install --save-dev eslint prettier @xwtec/eslint-config @xwtec/prettier-config

Configuration

Add following code

module.exports = {
  extends: ['@xwtec'],
};

to .eslintrc.js in your project.

You may also want config prettier with @xwtec/prettier-config.

Usage

npx eslint "**/*.js"

Rules

Error

#TypeRuleDescription
1errorno-callerdisallow the use of arguments.caller or arguments.callee
2errorno-class-assigndisallow reassigning class members
3errorno-const-assigndisallow reassigning const variables
4errorno-delete-vardisallow deleting variables
5errorno-dupe-argsdisallow duplicate arguments in function definitions
6errorno-dupe-class-membersdisallow duplicate class members
7errorno-dupe-else-ifdisallow duplicate conditions in if-else-if chains
8errorno-dupe-keysdisallow duplicate keys in object literals
9errorno-empty-patterndisallow empty destructuring patterns
10errorno-evaldisallow the use of eval()
11errorno-func-assigndisallow reassigning function declarations
12errorno-implied-evaldisallow the use of eval()-like methods
13errorno-import-assigndisallow assigning to imported bindings
14errorno-irregular-whitespacedisallow irregular whitespace
15errorno-new-symboldisallow new operators with the Symbol object
16errorno-obj-callsdisallow calling global object properties as functions
17errorno-redeclaredisallow variable redeclaration
18errorno-self-comparedisallow comparisons where both sides are exactly the same
19errorno-sequencesdisallow comma operators
20errorno-setter-returndisallow returning values from setters
21errorno-undefdisallow the use of undeclared variables unless mentioned in /*global */ comments
22errorrequire-yieldrequire generator functions to contain yield
23erroruse-isnanrequire calls to isNaN() when checking for NaN

Warn

#TypeRuleDescription
1warnconstructor-superrequire super() calls in constructors
2warnfor-directionenforce "for" loop update clause moving the counter in the right direction.
3warngetter-returnenforce return statements in getters
4warnno-case-declarationsdisallow lexical declarations in case clauses
5warnno-compare-neg-zerodisallow comparing against -0
6warnno-constant-conditiondisallow constant expressions in conditions
7warnno-duplicate-casedisallow duplicate case labels
8warnno-emptydisallow empty block statements
9warnno-empty-character-classdisallow empty character classes in regular expressions
10warnno-ex-assigndisallow reassigning exceptions in catch clauses
11warnno-extend-nativedisallow extending native types
12warnno-fallthroughdisallow fallthrough of case statements
13warnno-global-assigndisallow assignments to native objects or read-only global variables
14warnno-inner-declarationsdisallow variable or function declarations in nested blocks
15warnno-invalid-regexpdisallow invalid regular expression strings in RegExp constructors
16warnno-iteratordisallow the use of the __iterator__ property
17warnno-labelsdisallow labeled statements
18warnno-multi-strdisallow multiline strings
19warnno-new-wrappersdisallow new operators with the String, Number, and Boolean objects
20warnno-octaldisallow octal literals
21warnno-octal-escapedisallow octal escape sequences in string literals
22warnno-protodisallow the use of the __proto__ property
23warnno-restricted-propertiesdisallow certain properties on certain objects
24warnno-self-assigndisallow assignments where both sides are exactly the same
25warnno-sparse-arraysdisallow sparse arrays
26warnno-this-before-superdisallow this/super before calling super() in constructors
27warnno-throw-literaldisallow throwing literals as exceptions
28warnno-unmodified-loop-conditiondisallow unmodified loop conditions
29warnno-unreachabledisallow unreachable code after return, throw, continue, and break statements
30warnno-unsafe-finallydisallow control flow statements in finally blocks
31warnno-unsafe-negationdisallow negating the left operand of relational operators
32warnno-unused-varsdisallow unused variables
33warnno-useless-escapedisallow unnecessary escape characters
34warnno-voiddisallow void operators
35warnno-withdisallow with statements
36warnradixenforce the consistent use of the radix argument when using parseInt()
37warnvalid-typeofenforce comparing typeof expressions against valid strings

Fixable

#TypeRuleDescription
1warndot-notationenforce dot notation whenever possible
2erroreqeqeqrequire the use of === and !==
3warnno-div-regexdisallow division operators explicitly at the beginning of regular expressions
4warnno-else-returndisallow else blocks after return statements in if statements
5warnno-extra-binddisallow unnecessary calls to .bind()
6warnno-extra-boolean-castdisallow unnecessary boolean casts
7warnno-extra-labeldisallow unnecessary labels
8warnno-regex-spacesdisallow multiple spaces in regular expressions
9warnno-undef-initdisallow initializing variables to undefined
10warnno-unneeded-ternarydisallow ternary operators when simpler alternatives exist
11warnno-unused-labelsdisallow unused labels
12warnno-useless-computed-keydisallow unnecessary computed property keys in objects and classes
13warnno-useless-renamedisallow renaming import, export, and destructured assignments to the same name
14warnno-useless-returndisallow redundant return statements
15warnno-varrequire let or const instead of var
16warnobject-shorthandrequire or disallow method and property shorthand syntax for object literals
17warnone-varenforce variables to be declared either together or separately in functions
18warnoperator-assignmentrequire or disallow assignment operator shorthand where possible
19warnprefer-constrequire const declarations for variables that are never reassigned after declared
20warnprefer-destructuringrequire destructuring from arrays and/or objects
21warnprefer-exponentiation-operatordisallow the use of Math.pow in favor of the ** operator
22warnprefer-numeric-literalsdisallow parseInt() and Number.parseInt() in favor of binary, octal, and hexadecimal literals
23warnprefer-object-spreaddisallow using Object.assign with an object literal as the first argument and prefer the use of object spread instead.
24warnprefer-templaterequire template literals instead of string concatenation
25warnspaced-commentenforce consistent spacing after the // or /* in a comment
26warnyodarequire or disallow "Yoda" conditions
27warnprettier/prettier

Related

Links

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free