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 | ## Quick Start
|
19 |
|
20 | ```sh
|
21 | yarn add eslint prettier @xwtec/eslint-config eslint-plugin-prettier
|
22 | echo module.exports = {extends: "@xwtec"};>.eslintrc.jsx
|
23 | eslint "**/*.js"
|
24 | ```
|
25 |
|
26 | ## Install
|
27 |
|
28 | ```sh
|
29 | # with yarn
|
30 | yarn add --dev eslint prettier @xwtec/eslint-config
|
31 |
|
32 | # with npm
|
33 | npm install --save-dev eslint prettier @xwtec/eslint-config
|
34 | ```
|
35 |
|
36 | ## Configuration
|
37 |
|
38 | `.eslintrc.js` format is recommended
|
39 |
|
40 | ```js
|
41 | module.exports = {
|
42 | extends: ['@xwtec'],
|
43 | };
|
44 | ```
|
45 |
|
46 | ## Rules
|
47 |
|
48 |
|
49 |
|
50 |
|
51 |
|
52 | ### Error
|
53 |
|
54 | | # | Type | Rule | Description |
|
55 | | :-: | :---: | :------------------------------------------------------------------------------- | :---------------------------------------------------------------------------------- |
|
56 | | 1 | error | [no-caller](https://eslint.org/docs/rules/no-caller) | disallow the use of `arguments.caller` or `arguments.callee` |
|
57 | | 2 | error | [no-class-assign](https://eslint.org/docs/rules/no-class-assign) | disallow reassigning class members |
|
58 | | 3 | error | [no-const-assign](https://eslint.org/docs/rules/no-const-assign) | disallow reassigning `const` variables |
|
59 | | 4 | error | [no-delete-var](https://eslint.org/docs/rules/no-delete-var) | disallow deleting variables |
|
60 | | 5 | error | [no-dupe-args](https://eslint.org/docs/rules/no-dupe-args) | disallow duplicate arguments in `function` definitions |
|
61 | | 6 | error | [no-dupe-class-members](https://eslint.org/docs/rules/no-dupe-class-members) | disallow duplicate class members |
|
62 | | 7 | error | [no-dupe-keys](https://eslint.org/docs/rules/no-dupe-keys) | disallow duplicate keys in object literals |
|
63 | | 8 | error | [no-empty-pattern](https://eslint.org/docs/rules/no-empty-pattern) | disallow empty destructuring patterns |
|
64 | | 9 | error | [no-eval](https://eslint.org/docs/rules/no-eval) | disallow the use of `eval()` |
|
65 | | 10 | error | [no-func-assign](https://eslint.org/docs/rules/no-func-assign) | disallow reassigning `function` declarations |
|
66 | | 11 | error | [no-implied-eval](https://eslint.org/docs/rules/no-implied-eval) | disallow the use of `eval()`-like methods |
|
67 | | 12 | error | [no-irregular-whitespace](https://eslint.org/docs/rules/no-irregular-whitespace) | disallow irregular whitespace |
|
68 | | 13 | error | [no-new-symbol](https://eslint.org/docs/rules/no-new-symbol) | disallow `new` operators with the `Symbol` object |
|
69 | | 14 | error | [no-obj-calls](https://eslint.org/docs/rules/no-obj-calls) | disallow calling global object properties as functions |
|
70 | | 15 | error | [no-redeclare](https://eslint.org/docs/rules/no-redeclare) | disallow variable redeclaration |
|
71 | | 16 | error | [no-self-compare](https://eslint.org/docs/rules/no-self-compare) | disallow comparisons where both sides are exactly the same |
|
72 | | 17 | error | [no-sequences](https://eslint.org/docs/rules/no-sequences) | disallow comma operators |
|
73 | | 18 | error | [no-undef](https://eslint.org/docs/rules/no-undef) | disallow the use of undeclared variables unless mentioned in `/*global */` comments |
|
74 | | 19 | error | [no-unsafe-negation](https://eslint.org/docs/rules/no-unsafe-negation) | disallow negating the left operand of relational operators |
|
75 | | 20 | error | [require-yield](https://eslint.org/docs/rules/require-yield) | require generator functions to contain `yield` |
|
76 | | 21 | error | [use-isnan](https://eslint.org/docs/rules/use-isnan) | require calls to `isNaN()` when checking for `NaN` |
|
77 |
|
78 | ### Warn
|
79 |
|
80 | | # | Type | Rule | Description |
|
81 | | :-: | :--: | :----------------------------------------------------------------------------------------- | :------------------------------------------------------------------------------------ |
|
82 | | 1 | warn | [constructor-super](https://eslint.org/docs/rules/constructor-super) | require `super()` calls in constructors |
|
83 | | 2 | warn | [for-direction](https://eslint.org/docs/rules/for-direction) | enforce "for" loop update clause moving the counter in the right direction. |
|
84 | | 3 | warn | [getter-return](https://eslint.org/docs/rules/getter-return) | enforce `return` statements in getters |
|
85 | | 4 | warn | [no-case-declarations](https://eslint.org/docs/rules/no-case-declarations) | disallow lexical declarations in case clauses |
|
86 | | 5 | warn | [no-compare-neg-zero](https://eslint.org/docs/rules/no-compare-neg-zero) | disallow comparing against -0 |
|
87 | | 6 | warn | [no-constant-condition](https://eslint.org/docs/rules/no-constant-condition) | disallow constant expressions in conditions |
|
88 | | 7 | warn | [no-duplicate-case](https://eslint.org/docs/rules/no-duplicate-case) | disallow duplicate case labels |
|
89 | | 8 | warn | [no-empty](https://eslint.org/docs/rules/no-empty) | disallow empty block statements |
|
90 | | 9 | warn | [no-empty-character-class](https://eslint.org/docs/rules/no-empty-character-class) | disallow empty character classes in regular expressions |
|
91 | | 10 | warn | [no-ex-assign](https://eslint.org/docs/rules/no-ex-assign) | disallow reassigning exceptions in `catch` clauses |
|
92 | | 11 | warn | [no-extend-native](https://eslint.org/docs/rules/no-extend-native) | disallow extending native types |
|
93 | | 12 | warn | [no-fallthrough](https://eslint.org/docs/rules/no-fallthrough) | disallow fallthrough of `case` statements |
|
94 | | 13 | warn | [no-global-assign](https://eslint.org/docs/rules/no-global-assign) | disallow assignments to native objects or read-only global variables |
|
95 | | 14 | warn | [no-inner-declarations](https://eslint.org/docs/rules/no-inner-declarations) | disallow variable or `function` declarations in nested blocks |
|
96 | | 15 | warn | [no-invalid-regexp](https://eslint.org/docs/rules/no-invalid-regexp) | disallow invalid regular expression strings in `RegExp` constructors |
|
97 | | 16 | warn | [no-iterator](https://eslint.org/docs/rules/no-iterator) | disallow the use of the `__iterator__` property |
|
98 | | 17 | warn | [no-labels](https://eslint.org/docs/rules/no-labels) | disallow labeled statements |
|
99 | | 18 | warn | [no-multi-str](https://eslint.org/docs/rules/no-multi-str) | disallow multiline strings |
|
100 | | 19 | warn | [no-new-wrappers](https://eslint.org/docs/rules/no-new-wrappers) | disallow `new` operators with the `String`, `Number`, and `Boolean` objects |
|
101 | | 20 | warn | [no-octal](https://eslint.org/docs/rules/no-octal) | disallow octal literals |
|
102 | | 21 | warn | [no-octal-escape](https://eslint.org/docs/rules/no-octal-escape) | disallow octal escape sequences in string literals |
|
103 | | 22 | warn | [no-proto](https://eslint.org/docs/rules/no-proto) | disallow the use of the `__proto__` property |
|
104 | | 23 | warn | [no-restricted-properties](https://eslint.org/docs/rules/no-restricted-properties) | disallow certain properties on certain objects |
|
105 | | 24 | warn | [no-self-assign](https://eslint.org/docs/rules/no-self-assign) | disallow assignments where both sides are exactly the same |
|
106 | | 25 | warn | [no-sparse-arrays](https://eslint.org/docs/rules/no-sparse-arrays) | disallow sparse arrays |
|
107 | | 26 | warn | [no-this-before-super](https://eslint.org/docs/rules/no-this-before-super) | disallow `this`/`super` before calling `super()` in constructors |
|
108 | | 27 | warn | [no-throw-literal](https://eslint.org/docs/rules/no-throw-literal) | disallow throwing literals as exceptions |
|
109 | | 28 | warn | [no-unmodified-loop-condition](https://eslint.org/docs/rules/no-unmodified-loop-condition) | disallow unmodified loop conditions |
|
110 | | 29 | warn | [no-unreachable](https://eslint.org/docs/rules/no-unreachable) | disallow unreachable code after `return`, `throw`, `continue`, and `break` statements |
|
111 | | 30 | warn | [no-unsafe-finally](https://eslint.org/docs/rules/no-unsafe-finally) | disallow control flow statements in `finally` blocks |
|
112 | | 31 | warn | [no-useless-escape](https://eslint.org/docs/rules/no-useless-escape) | disallow unnecessary escape characters |
|
113 | | 32 | warn | [no-void](https://eslint.org/docs/rules/no-void) | disallow `void` operators |
|
114 | | 33 | warn | [no-with](https://eslint.org/docs/rules/no-with) | disallow `with` statements |
|
115 | | 34 | warn | [radix](https://eslint.org/docs/rules/radix) | enforce the consistent use of the radix argument when using `parseInt()` |
|
116 | | 35 | warn | [valid-typeof](https://eslint.org/docs/rules/valid-typeof) | enforce comparing `typeof` expressions against valid strings |
|
117 |
|
118 | ### Fixable
|
119 |
|
120 | | # | Type | Rule | Description |
|
121 | | :-: | :---: | :------------------------------------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------- |
|
122 | | 1 | warn | [dot-notation](https://eslint.org/docs/rules/dot-notation) | enforce dot notation whenever possible |
|
123 | | 2 | error | [eqeqeq](https://eslint.org/docs/rules/eqeqeq) | require the use of `===` and `!==` |
|
124 | | 3 | warn | [no-div-regex](https://eslint.org/docs/rules/no-div-regex) | disallow division operators explicitly at the beginning of regular expressions |
|
125 | | 4 | warn | [no-else-return](https://eslint.org/docs/rules/no-else-return) | disallow `else` blocks after `return` statements in `if` statements |
|
126 | | 5 | warn | [no-extra-bind](https://eslint.org/docs/rules/no-extra-bind) | disallow unnecessary calls to `.bind()` |
|
127 | | 6 | warn | [no-extra-boolean-cast](https://eslint.org/docs/rules/no-extra-boolean-cast) | disallow unnecessary boolean casts |
|
128 | | 7 | warn | [no-extra-label](https://eslint.org/docs/rules/no-extra-label) | disallow unnecessary labels |
|
129 | | 8 | warn | [no-regex-spaces](https://eslint.org/docs/rules/no-regex-spaces) | disallow multiple spaces in regular expressions |
|
130 | | 9 | warn | [no-undef-init](https://eslint.org/docs/rules/no-undef-init) | disallow initializing variables to `undefined` |
|
131 | | 10 | warn | [no-unneeded-ternary](https://eslint.org/docs/rules/no-unneeded-ternary) | disallow ternary operators when simpler alternatives exist |
|
132 | | 11 | warn | [no-unused-labels](https://eslint.org/docs/rules/no-unused-labels) | disallow unused labels |
|
133 | | 12 | warn | [no-useless-computed-key](https://eslint.org/docs/rules/no-useless-computed-key) | disallow unnecessary computed property keys in object literals |
|
134 | | 13 | warn | [no-useless-rename](https://eslint.org/docs/rules/no-useless-rename) | disallow renaming import, export, and destructured assignments to the same name |
|
135 | | 14 | warn | [no-useless-return](https://eslint.org/docs/rules/no-useless-return) | disallow redundant return statements |
|
136 | | 15 | warn | [no-var](https://eslint.org/docs/rules/no-var) | require `let` or `const` instead of `var` |
|
137 | | 16 | warn | [object-shorthand](https://eslint.org/docs/rules/object-shorthand) | require or disallow method and property shorthand syntax for object literals |
|
138 | | 17 | warn | [one-var](https://eslint.org/docs/rules/one-var) | enforce variables to be declared either together or separately in functions |
|
139 | | 18 | warn | [operator-assignment](https://eslint.org/docs/rules/operator-assignment) | require or disallow assignment operator shorthand where possible |
|
140 | | 19 | warn | [prefer-const](https://eslint.org/docs/rules/prefer-const) | require `const` declarations for variables that are never reassigned after declared |
|
141 | | 20 | warn | [prefer-destructuring](https://eslint.org/docs/rules/prefer-destructuring) | require destructuring from arrays and/or objects |
|
142 | | 21 | 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 |
|
143 | | 22 | 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. |
|
144 | | 23 | warn | [prefer-template](https://eslint.org/docs/rules/prefer-template) | require template literals instead of string concatenation |
|
145 | | 24 | warn | [spaced-comment](https://eslint.org/docs/rules/spaced-comment) | enforce consistent spacing after the `//` or `/*` in a comment |
|
146 | | 25 | warn | [yoda](https://eslint.org/docs/rules/yoda) | require or disallow "Yoda" conditions |
|
147 | | 26 | warn | [prettier/prettier](https://github.com/prettier/eslint-plugin-prettier#options) |
|
148 |
|
149 |
|
150 |
|
151 | ## Relative
|
152 |
|
153 | - [@xwtec/eslint-config-legacy](https://github.com/xwtec/eslint-config-legacy)
|
154 | - [@xwtec/eslint-config-vue](https://github.com/xwtec/eslint-config-vue)
|
155 |
|
156 | ## Links
|
157 |
|
158 | - [ESLint](https://eslint.org/)
|
159 | - [Prettier](https://prettier.io/)
|
160 |
|
161 | ## License
|
162 |
|
163 | MIT © [xwtec](https://github.com/xwtec)
|