@lidofinance/eslint-config 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +59 -6
- package/lib/build-config.js +2 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,10 +1,63 @@
|
|
|
1
|
-
|
|
1
|
+
# Lido ESint config
|
|
2
|
+
*Automated, non-opinionated ESLint config foundation*
|
|
3
|
+
> ❗ _Please note that this ESLint config is still 0.x and is subject to significant changes; it is mainly used by internal Lido teams._
|
|
2
4
|
|
|
3
|
-
Please, do not use it unless you specifically know what you are doing.
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
### Installation
|
|
7
|
+
```bash
|
|
8
|
+
npm install --dev @lidofinance/eslint-config
|
|
9
|
+
# and plugins
|
|
10
|
+
npm install --dev eslint @typescript-eslint/parser @typescript-eslint/eslint-plugin eslint-import-resolver-typescript eslint-plugin-eslint-comments eslint-plugin-import eslint-plugin-jest eslint-plugin-promise eslint-plugin-react eslint-plugin-react-hooks eslint-plugin-sonarjs eslint-plugin-unicorn @next/eslint-plugin-next
|
|
11
|
+
```
|
|
6
12
|
|
|
7
|
-
|
|
13
|
+
If using TypeScript, alter `tsconfig.json` line `includes` to include everything, like that:
|
|
14
|
+
`"include": ["**/*","**/.*"]`
|
|
8
15
|
|
|
9
|
-
-
|
|
10
|
-
|
|
16
|
+
> ℹ️ Modern module resolution [ESLint patch](https://www.npmjs.com/package/@rushstack/eslint-patch) by Rush team is intentionally not used, as it conflicts with same patch in `@next/eslint-plugin`.
|
|
17
|
+
|
|
18
|
+
### Configuration
|
|
19
|
+
Style rules are intentionally not provided; bring your own code style, whatever it is - prettier, airbnb, xo or standard.
|
|
20
|
+
|
|
21
|
+
```json5
|
|
22
|
+
// .eslintrc
|
|
23
|
+
{
|
|
24
|
+
"root": true,
|
|
25
|
+
|
|
26
|
+
"extends": [
|
|
27
|
+
// note: use every other config BEFORE @lidofinance config,
|
|
28
|
+
// EXCEPT prettier; prettier is bundled with multiple
|
|
29
|
+
// disable rules that should be turned off to avoid conflicts
|
|
30
|
+
|
|
31
|
+
//"airbnb",
|
|
32
|
+
"@lidofinance",
|
|
33
|
+
//"prettier"
|
|
34
|
+
]
|
|
35
|
+
}
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### What's inside
|
|
39
|
+
|
|
40
|
+
`@lidofinance/eslint-config` is feature-packed config that ships with some logic.
|
|
41
|
+
|
|
42
|
+
Following assumptions are done:
|
|
43
|
+
- ES version target is latest (2022); if you need other, change `env` in `.eslintrc`
|
|
44
|
+
- code is always server-ready
|
|
45
|
+
- code is client-ready if `react` package is present
|
|
46
|
+
- there is no magic resolution mechanism and usage of webpack loaders; only explicit file paths and `tsconfig.json` `paths` are considered
|
|
47
|
+
- latest version of TypeScript (4.6.x) and ESLint (^8.13) are used
|
|
48
|
+
|
|
49
|
+
For performance, developer experience and accuracy reasons some rules will turn on if following conditions will happen:
|
|
50
|
+
|
|
51
|
+
- `React` package is declared in `package.json`
|
|
52
|
+
- `react`, `react-hooks` rules will be used
|
|
53
|
+
- `Next` package is declared in `package.json`
|
|
54
|
+
- `next` plugin rules will be used
|
|
55
|
+
- react rule `react/react-in-jsx-scope` will turn off
|
|
56
|
+
- `Jest` package is declared in `package.json`
|
|
57
|
+
- `jest` plugin rules will be used
|
|
58
|
+
- some rules will be disabled (like "avoid code duplication" and "do not use any") for test-specific file patterns
|
|
59
|
+
- `Typescript` package is declared in `package.json`:
|
|
60
|
+
- `typescript-eslint` rules will be enabled
|
|
61
|
+
- parser will be switched to typescript-eslint
|
|
62
|
+
- if `tsconfig.json` is present, type-level lint rules will be enabled
|
|
63
|
+
- if `compilerOptions.strict` is `true`, additional anti-any rules will be enabled
|
package/lib/build-config.js
CHANGED
|
@@ -16,6 +16,8 @@ const loosenTsRules = {
|
|
|
16
16
|
'@typescript-eslint/require-await': 'off',
|
|
17
17
|
'@typescript-eslint/await-thenable': 'off',
|
|
18
18
|
'@typescript-eslint/no-explicit-any': 'off',
|
|
19
|
+
'@typescript-eslint/restrict-plus-operands': 'off',
|
|
20
|
+
'@typescript-eslint/restrict-template-expressions': 'off',
|
|
19
21
|
}
|
|
20
22
|
const loosenReactRules = {
|
|
21
23
|
// loosen some rules
|