UNPKG

23.2 kBMarkdownView Raw
1# @xwtec/eslint-config
2
3[![devDependencies](https://img.shields.io/david/dev/xwtec/eslint-config.svg?style=flat-square)](https://david-dm.org/xwtec/eslint-config)
4[![Issues](http://img.shields.io/github/issues/xwtec/eslint-config.svg?style=flat-square)](https://github.com/xwtec/eslint-config/issues)
5[![Issues](https://img.shields.io/github/issues-pr/xwtec/eslint-config.svg?style=flat-square)](https://github.com/xwtec/eslint-config/pulls)
6[![GitHub last commit](https://img.shields.io/github/last-commit/xwtec/eslint-config.svg?style=flat-square)](https://github.com/xwtec/eslint-config/commits)
7[![GitHub Release Date](https://img.shields.io/github/release-date/xwtec/eslint-config.svg?style=flat-square)](https://github.com/xwtec/eslint-config/releases)
8
9[![npm](https://img.shields.io/npm/v/@xwtec/eslint-config.svg?style=flat-square)](https://www.npmjs.com/package/@xwtec/eslint-config)
10[![npm](https://img.shields.io/npm/dt/@xwtec/eslint-config.svg?style=flat-square)](https://www.npmjs.com/package/@xwtec/eslint-config)
11[![Snyk Vulnerabilities for npm package version](https://img.shields.io/snyk/vulnerabilities/npm/@xwtec/eslint-config.svg?style=flat-square)](https://snyk.io/vuln/npm:@xwtec%2Feslint-config)
12
13[![styled with prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)
14[![MIT license](https://img.shields.io/github/license/xwtec/eslint-config.svg?style=flat-square)](http://opensource.org/licenses/MIT)
15
16> ESLint Configuration for xwtec projects
17
18## Install
19
20```bash
21# with yarn
22yarn add --dev eslint prettier @xwtec/eslint-config @xwtec/prettier-config
23
24# with npm
25npm install --save-dev eslint prettier @xwtec/eslint-config @xwtec/prettier-config
26```
27
28## Configuration
29
30Add following code
31
32```js
33module.exports = {
34 extends: ['@xwtec'],
35};
36```
37
38to `.eslintrc.js` in your project.
39
40_You may also want config `prettier` with [`@xwtec/prettier-config`](https://github.com/xwtec/prettier-config#configuration)._
41
42## Usage
43
44```bash
45npx eslint "**/*.js"
46```
47
48## Rules
49
50<!-- rules start -->
51
52<!-- AUTO GENERATED CONTENT, DON'T EDIT -->
53
54### Error
55
56| # | Type | Rule | Description |
57| :-: | :---: | :------------------------------------------------------------------------------- | :---------------------------------------------------------------------------------- |
58| 1 | error | [no-caller](https://eslint.org/docs/rules/no-caller) | disallow the use of `arguments.caller` or `arguments.callee` |
59| 2 | error | [no-class-assign](https://eslint.org/docs/rules/no-class-assign) | disallow reassigning class members |
60| 3 | error | [no-const-assign](https://eslint.org/docs/rules/no-const-assign) | disallow reassigning `const` variables |
61| 4 | error | [no-delete-var](https://eslint.org/docs/rules/no-delete-var) | disallow deleting variables |
62| 5 | error | [no-dupe-args](https://eslint.org/docs/rules/no-dupe-args) | disallow duplicate arguments in `function` definitions |
63| 6 | error | [no-dupe-class-members](https://eslint.org/docs/rules/no-dupe-class-members) | disallow duplicate class members |
64| 7 | error | [no-dupe-else-if](https://eslint.org/docs/rules/no-dupe-else-if) | disallow duplicate conditions in if-else-if chains |
65| 8 | error | [no-dupe-keys](https://eslint.org/docs/rules/no-dupe-keys) | disallow duplicate keys in object literals |
66| 9 | error | [no-empty-pattern](https://eslint.org/docs/rules/no-empty-pattern) | disallow empty destructuring patterns |
67| 10 | error | [no-eval](https://eslint.org/docs/rules/no-eval) | disallow the use of `eval()` |
68| 11 | error | [no-func-assign](https://eslint.org/docs/rules/no-func-assign) | disallow reassigning `function` declarations |
69| 12 | error | [no-implied-eval](https://eslint.org/docs/rules/no-implied-eval) | disallow the use of `eval()`-like methods |
70| 13 | error | [no-import-assign](https://eslint.org/docs/rules/no-import-assign) | disallow assigning to imported bindings |
71| 14 | error | [no-irregular-whitespace](https://eslint.org/docs/rules/no-irregular-whitespace) | disallow irregular whitespace |
72| 15 | error | [no-new-symbol](https://eslint.org/docs/rules/no-new-symbol) | disallow `new` operators with the `Symbol` object |
73| 16 | error | [no-obj-calls](https://eslint.org/docs/rules/no-obj-calls) | disallow calling global object properties as functions |
74| 17 | error | [no-redeclare](https://eslint.org/docs/rules/no-redeclare) | disallow variable redeclaration |
75| 18 | error | [no-self-compare](https://eslint.org/docs/rules/no-self-compare) | disallow comparisons where both sides are exactly the same |
76| 19 | error | [no-sequences](https://eslint.org/docs/rules/no-sequences) | disallow comma operators |
77| 20 | error | [no-setter-return](https://eslint.org/docs/rules/no-setter-return) | disallow returning values from setters |
78| 21 | error | [no-undef](https://eslint.org/docs/rules/no-undef) | disallow the use of undeclared variables unless mentioned in `/*global */` comments |
79| 22 | error | [radix](https://eslint.org/docs/rules/radix) | enforce the consistent use of the radix argument when using `parseInt()` |
80| 23 | error | [require-yield](https://eslint.org/docs/rules/require-yield) | require generator functions to contain `yield` |
81| 24 | error | [use-isnan](https://eslint.org/docs/rules/use-isnan) | require calls to `isNaN()` when checking for `NaN` |
82
83### Warn
84
85| # | Type | Rule | Description |
86| :-: | :--: | :----------------------------------------------------------------------------------------------------------- | :--------------------------------------------------------------------------------------- |
87| 1 | warn | [constructor-super](https://eslint.org/docs/rules/constructor-super) | require `super()` calls in constructors |
88| 2 | warn | [for-direction](https://eslint.org/docs/rules/for-direction) | enforce "for" loop update clause moving the counter in the right direction. |
89| 3 | warn | [getter-return](https://eslint.org/docs/rules/getter-return) | enforce `return` statements in getters |
90| 4 | warn | [no-case-declarations](https://eslint.org/docs/rules/no-case-declarations) | disallow lexical declarations in case clauses |
91| 5 | warn | [no-compare-neg-zero](https://eslint.org/docs/rules/no-compare-neg-zero) | disallow comparing against -0 |
92| 6 | warn | [no-constant-condition](https://eslint.org/docs/rules/no-constant-condition) | disallow constant expressions in conditions |
93| 7 | warn | [no-duplicate-case](https://eslint.org/docs/rules/no-duplicate-case) | disallow duplicate case labels |
94| 8 | warn | [no-empty](https://eslint.org/docs/rules/no-empty) | disallow empty block statements |
95| 9 | warn | [no-empty-character-class](https://eslint.org/docs/rules/no-empty-character-class) | disallow empty character classes in regular expressions |
96| 10 | warn | [no-ex-assign](https://eslint.org/docs/rules/no-ex-assign) | disallow reassigning exceptions in `catch` clauses |
97| 11 | warn | [no-extend-native](https://eslint.org/docs/rules/no-extend-native) | disallow extending native types |
98| 12 | warn | [no-fallthrough](https://eslint.org/docs/rules/no-fallthrough) | disallow fallthrough of `case` statements |
99| 13 | warn | [no-global-assign](https://eslint.org/docs/rules/no-global-assign) | disallow assignments to native objects or read-only global variables |
100| 14 | warn | [no-inner-declarations](https://eslint.org/docs/rules/no-inner-declarations) | disallow variable or `function` declarations in nested blocks |
101| 15 | warn | [no-invalid-regexp](https://eslint.org/docs/rules/no-invalid-regexp) | disallow invalid regular expression strings in `RegExp` constructors |
102| 16 | warn | [no-iterator](https://eslint.org/docs/rules/no-iterator) | disallow the use of the `__iterator__` property |
103| 17 | warn | [no-labels](https://eslint.org/docs/rules/no-labels) | disallow labeled statements |
104| 18 | warn | [no-multi-str](https://eslint.org/docs/rules/no-multi-str) | disallow multiline strings |
105| 19 | warn | [no-new-wrappers](https://eslint.org/docs/rules/no-new-wrappers) | disallow `new` operators with the `String`, `Number`, and `Boolean` objects |
106| 20 | warn | [no-octal](https://eslint.org/docs/rules/no-octal) | disallow octal literals |
107| 21 | warn | [no-octal-escape](https://eslint.org/docs/rules/no-octal-escape) | disallow octal escape sequences in string literals |
108| 22 | warn | [no-proto](https://eslint.org/docs/rules/no-proto) | disallow the use of the `__proto__` property |
109| 23 | warn | [no-restricted-globals](https://eslint.org/docs/rules/no-restricted-globals) | disallow specified global variables |
110| 24 | warn | [no-restricted-properties](https://eslint.org/docs/rules/no-restricted-properties) | disallow certain properties on certain objects |
111| 25 | warn | [no-self-assign](https://eslint.org/docs/rules/no-self-assign) | disallow assignments where both sides are exactly the same |
112| 26 | warn | [no-sparse-arrays](https://eslint.org/docs/rules/no-sparse-arrays) | disallow sparse arrays |
113| 27 | warn | [no-this-before-super](https://eslint.org/docs/rules/no-this-before-super) | disallow `this`/`super` before calling `super()` in constructors |
114| 28 | warn | [no-throw-literal](https://eslint.org/docs/rules/no-throw-literal) | disallow throwing literals as exceptions |
115| 29 | warn | [no-unmodified-loop-condition](https://eslint.org/docs/rules/no-unmodified-loop-condition) | disallow unmodified loop conditions |
116| 30 | warn | [no-unreachable](https://eslint.org/docs/rules/no-unreachable) | disallow unreachable code after `return`, `throw`, `continue`, and `break` statements |
117| 31 | warn | [no-unsafe-finally](https://eslint.org/docs/rules/no-unsafe-finally) | disallow control flow statements in `finally` blocks |
118| 32 | warn | [no-unsafe-negation](https://eslint.org/docs/rules/no-unsafe-negation) | disallow negating the left operand of relational operators |
119| 33 | warn | [no-unsafe-optional-chaining](https://eslint.org/docs/rules/no-unsafe-optional-chaining) | disallow use of optional chaining in contexts where the `undefined` value is not allowed |
120| 34 | warn | [no-unused-vars](https://eslint.org/docs/rules/no-unused-vars) | disallow unused variables |
121| 35 | warn | [no-useless-escape](https://eslint.org/docs/rules/no-useless-escape) | disallow unnecessary escape characters |
122| 36 | warn | [no-void](https://eslint.org/docs/rules/no-void) | disallow `void` operators |
123| 37 | warn | [no-with](https://eslint.org/docs/rules/no-with) | disallow `with` statements |
124| 38 | warn | [valid-typeof](https://eslint.org/docs/rules/valid-typeof) | enforce comparing `typeof` expressions against valid strings |
125| 39 | warn | [import/extensions](https://github.com/benmosher/eslint-plugin-import/blob/v2.23.4/docs/rules/extensions.md) |
126
127### Fixable
128
129| # | Type | Rule | Description |
130| :-: | :---: | :------------------------------------------------------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------- |
131| 1 | warn | [curly](https://eslint.org/docs/rules/curly) | enforce consistent brace style for all control statements |
132| 2 | warn | [dot-notation](https://eslint.org/docs/rules/dot-notation) | enforce dot notation whenever possible |
133| 3 | error | [eqeqeq](https://eslint.org/docs/rules/eqeqeq) | require the use of `===` and `!==` |
134| 4 | warn | [no-div-regex](https://eslint.org/docs/rules/no-div-regex) | disallow division operators explicitly at the beginning of regular expressions |
135| 5 | warn | [no-else-return](https://eslint.org/docs/rules/no-else-return) | disallow `else` blocks after `return` statements in `if` statements |
136| 6 | warn | [no-extra-bind](https://eslint.org/docs/rules/no-extra-bind) | disallow unnecessary calls to `.bind()` |
137| 7 | warn | [no-extra-boolean-cast](https://eslint.org/docs/rules/no-extra-boolean-cast) | disallow unnecessary boolean casts |
138| 8 | warn | [no-extra-label](https://eslint.org/docs/rules/no-extra-label) | disallow unnecessary labels |
139| 9 | warn | [no-regex-spaces](https://eslint.org/docs/rules/no-regex-spaces) | disallow multiple spaces in regular expressions |
140| 10 | warn | [no-undef-init](https://eslint.org/docs/rules/no-undef-init) | disallow initializing variables to `undefined` |
141| 11 | warn | [no-unneeded-ternary](https://eslint.org/docs/rules/no-unneeded-ternary) | disallow ternary operators when simpler alternatives exist |
142| 12 | warn | [no-unused-labels](https://eslint.org/docs/rules/no-unused-labels) | disallow unused labels |
143| 13 | warn | [no-useless-computed-key](https://eslint.org/docs/rules/no-useless-computed-key) | disallow unnecessary computed property keys in objects and classes |
144| 14 | warn | [no-useless-rename](https://eslint.org/docs/rules/no-useless-rename) | disallow renaming import, export, and destructured assignments to the same name |
145| 15 | warn | [no-useless-return](https://eslint.org/docs/rules/no-useless-return) | disallow redundant return statements |
146| 16 | warn | [no-var](https://eslint.org/docs/rules/no-var) | require `let` or `const` instead of `var` |
147| 17 | warn | [object-shorthand](https://eslint.org/docs/rules/object-shorthand) | require or disallow method and property shorthand syntax for object literals |
148| 18 | warn | [one-var](https://eslint.org/docs/rules/one-var) | enforce variables to be declared either together or separately in functions |
149| 19 | warn | [operator-assignment](https://eslint.org/docs/rules/operator-assignment) | require or disallow assignment operator shorthand where possible |
150| 20 | warn | [prefer-const](https://eslint.org/docs/rules/prefer-const) | require `const` declarations for variables that are never reassigned after declared |
151| 21 | warn | [prefer-destructuring](https://eslint.org/docs/rules/prefer-destructuring) | require destructuring from arrays and/or objects |
152| 22 | warn | [prefer-exponentiation-operator](https://eslint.org/docs/rules/prefer-exponentiation-operator) | disallow the use of `Math.pow` in favor of the `**` operator |
153| 23 | warn | [prefer-numeric-literals](https://eslint.org/docs/rules/prefer-numeric-literals) | disallow `parseInt()` and `Number.parseInt()` in favor of binary, octal, and hexadecimal literals |
154| 24 | warn | [prefer-object-spread](https://eslint.org/docs/rules/prefer-object-spread) | disallow using Object.assign with an object literal as the first argument and prefer the use of object spread instead. |
155| 25 | warn | [prefer-template](https://eslint.org/docs/rules/prefer-template) | require template literals instead of string concatenation |
156| 26 | warn | [spaced-comment](https://eslint.org/docs/rules/spaced-comment) | enforce consistent spacing after the `//` or `/*` in a comment |
157| 27 | warn | [yoda](https://eslint.org/docs/rules/yoda) | require or disallow "Yoda" conditions |
158| 28 | warn | [import/order](https://github.com/benmosher/eslint-plugin-import/blob/v2.23.4/docs/rules/order.md) |
159| 29 | warn | [prettier/prettier](https://github.com/prettier/eslint-plugin-prettier#options) |
160
161<!-- rules end -->
162
163## Related
164
165- [@xwtec/eslint-config-vue](https://github.com/xwtec/eslint-config-vue)
166- [@xwtec/eslint-config-legacy](https://github.com/xwtec/eslint-config-legacy)
167- [@xwtec/prettier-config](https://github.com/xwtec/prettier-config)
168
169## Links
170
171- [ESLint](https://eslint.org/)
172- [Prettier](https://prettier.io/)