@peerigon/configs 1.0.0-beta.8 → 1.0.0
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/CHANGELOG.md +130 -0
- package/README.md +42 -419
- package/docs/prettier.md +13 -0
- package/docs/typescript.md +15 -0
- package/eslint/README.md +119 -0
- package/eslint/presets/typescript-react.test/App.tsx +2 -0
- package/eslint/presets/typescript.test/main.ts +5 -1
- package/eslint/rules/javascript.js +6 -0
- package/eslint/rules/typescript.js +9 -1
- package/eslint/styles/no-default-export.js +2 -1
- package/package.json +120 -51
- package/prettier/README.md +35 -0
- package/prettier/base.js +6 -1
- package/prettier/css.test/styles.css +9 -0
- package/semantic-release/README.md +81 -0
- package/semantic-release/base.js +10 -13
- package/semantic-release/cross-publish.js +22 -0
- package/types/eslint/lib/glob-patterns.d.ts +9 -0
- package/types/eslint/lib/glob-patterns.d.ts.map +1 -0
- package/types/eslint/lib/rule-options.d.ts +95 -0
- package/types/eslint/lib/rule-options.d.ts.map +1 -0
- package/types/eslint/presets/javascript-browser.d.ts +4 -0
- package/types/eslint/presets/javascript-browser.d.ts.map +1 -0
- package/types/eslint/presets/javascript-node.d.ts +4 -0
- package/types/eslint/presets/javascript-node.d.ts.map +1 -0
- package/types/eslint/presets/javascript.d.ts +4 -0
- package/types/eslint/presets/javascript.d.ts.map +1 -0
- package/types/eslint/presets/javascript.test/eslint.config.d.ts +2 -0
- package/types/eslint/presets/javascript.test/eslint.config.d.ts.map +1 -0
- package/types/eslint/presets/javascript.test/main.d.ts +2 -0
- package/types/eslint/presets/javascript.test/main.d.ts.map +1 -0
- package/types/eslint/presets/javascript.test/other.d.ts +3 -0
- package/types/eslint/presets/javascript.test/other.d.ts.map +1 -0
- package/types/eslint/presets/typescript-node.d.ts +4 -0
- package/types/eslint/presets/typescript-node.d.ts.map +1 -0
- package/types/eslint/presets/typescript-react.d.ts +4 -0
- package/types/eslint/presets/typescript-react.d.ts.map +1 -0
- package/types/eslint/presets/typescript.d.ts +4 -0
- package/types/eslint/presets/typescript.d.ts.map +1 -0
- package/types/eslint/rules/base.d.ts +4 -0
- package/types/eslint/rules/base.d.ts.map +1 -0
- package/types/eslint/rules/browser.d.ts +4 -0
- package/types/eslint/rules/browser.d.ts.map +1 -0
- package/types/eslint/rules/javascript.d.ts +4 -0
- package/types/eslint/rules/javascript.d.ts.map +1 -0
- package/types/eslint/rules/node.d.ts +4 -0
- package/types/eslint/rules/node.d.ts.map +1 -0
- package/types/eslint/rules/react.d.ts +4 -0
- package/types/eslint/rules/react.d.ts.map +1 -0
- package/types/eslint/rules/typescript.d.ts +3 -0
- package/types/eslint/rules/typescript.d.ts.map +1 -0
- package/types/eslint/styles/jsx-no-literals.d.ts +4 -0
- package/types/eslint/styles/jsx-no-literals.d.ts.map +1 -0
- package/types/eslint/styles/no-default-export.d.ts +4 -0
- package/types/eslint/styles/no-default-export.d.ts.map +1 -0
- package/types/eslint/styles/no-default-export.test/eslint.config.d.ts +3 -0
- package/types/eslint/styles/no-default-export.test/eslint.config.d.ts.map +1 -0
- package/types/eslint/styles/no-default-export.test/main.d.ts +3 -0
- package/types/eslint/styles/no-default-export.test/main.d.ts.map +1 -0
- package/types/eslint/styles/no-null.d.ts +4 -0
- package/types/eslint/styles/no-null.d.ts.map +1 -0
- package/types/eslint/styles/no-null.test/eslint.config.d.ts +3 -0
- package/types/eslint/styles/no-null.test/eslint.config.d.ts.map +1 -0
- package/types/eslint/styles/no-null.test/main.d.ts +2 -0
- package/types/eslint/styles/no-null.test/main.d.ts.map +1 -0
- package/types/eslint/styles/prefer-array-shorthand.d.ts +4 -0
- package/types/eslint/styles/prefer-array-shorthand.d.ts.map +1 -0
- package/types/eslint/styles/prefer-array-shorthand.test/eslint.config.d.ts +3 -0
- package/types/eslint/styles/prefer-array-shorthand.test/eslint.config.d.ts.map +1 -0
- package/types/eslint/styles/prefer-array-shorthand.test/main.d.ts +3 -0
- package/types/eslint/styles/prefer-array-shorthand.test/main.d.ts.map +1 -0
- package/types/eslint/styles/prefer-interface.d.ts +4 -0
- package/types/eslint/styles/prefer-interface.d.ts.map +1 -0
- package/types/eslint/styles/prefer-interface.test/eslint.config.d.ts +3 -0
- package/types/eslint/styles/prefer-interface.test/eslint.config.d.ts.map +1 -0
- package/types/eslint/styles/prefer-interface.test/main.d.ts +7 -0
- package/types/eslint/styles/prefer-interface.test/main.d.ts.map +1 -0
- package/types/prettier/base.d.ts +4 -0
- package/types/prettier/base.d.ts.map +1 -0
- package/types/semantic-release/base.d.ts +4 -0
- package/types/semantic-release/base.d.ts.map +1 -0
- package/types/semantic-release/cross-publish.d.ts +4 -0
- package/types/semantic-release/cross-publish.d.ts.map +1 -0
- package/typescript/README.md +58 -0
- package/typescript/base.json +11 -3
- package/typescript/js-lib.json +9 -0
- package/typescript/lib.json +8 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,133 @@
|
|
|
1
|
+
# 1.0.0 (2025-02-04)
|
|
2
|
+
|
|
3
|
+
### Bug Fixes
|
|
4
|
+
|
|
5
|
+
- Add rootDir to lib tsconfig ([764e0c1](https://github.com/peerigon/configs/commit/764e0c191f07dfd1d996937a4df488d56be5a159))
|
|
6
|
+
- Adjust release script ([df43151](https://github.com/peerigon/configs/commit/df431514d28fd32d2bd69a50eeb8edf3e6cc1d44))
|
|
7
|
+
- Adjust release script ([3668267](https://github.com/peerigon/configs/commit/366826718205e6f542f69d890a44c3595fa84340))
|
|
8
|
+
- Changelog not formatted correctly ([cc12fa7](https://github.com/peerigon/configs/commit/cc12fa7abe725c4ab8597296094e2e485b1346e0))
|
|
9
|
+
- CHANGELOG.md not being properly formatted ([22720ea](https://github.com/peerigon/configs/commit/22720ea8bc3aab0477a89094b24f567571860c15))
|
|
10
|
+
- Downgrade ESLint ([d09f208](https://github.com/peerigon/configs/commit/d09f2084646c68fd9998685143563ba88ddaab0a))
|
|
11
|
+
- Improve error message for no-default-export ([198c911](https://github.com/peerigon/configs/commit/198c91151a3dfd33339715c21ec95aa7c5bfbe05))
|
|
12
|
+
- Missing files in package.json files array ([97111b6](https://github.com/peerigon/configs/commit/97111b66b1a741e25820bcf43b17355b59a95fca))
|
|
13
|
+
- Missing packages write permission in Github action ([ce0d482](https://github.com/peerigon/configs/commit/ce0d4820e2e75f164f5385e48bd8978c250216f1))
|
|
14
|
+
- Move package types to regular dependencies ([6d6c169](https://github.com/peerigon/configs/commit/6d6c1695989f04898a1e730b6320b2cbea158a8f))
|
|
15
|
+
- noEmit setting in TypeScript configs ([281334c](https://github.com/peerigon/configs/commit/281334c3565ca0cd1afcc8d39a94857a0d42e9ae))
|
|
16
|
+
- Prettify CHANGELOG.md ([f904e8d](https://github.com/peerigon/configs/commit/f904e8d535a8d04d615281bb942ccd8b2f12a9d9))
|
|
17
|
+
- Relax switch-exhaustiveness-check rule ([2f158a4](https://github.com/peerigon/configs/commit/2f158a4a25770897c6140d3356161349b79c1cc2))
|
|
18
|
+
- Remove rootDir config from lib tsconfig again ([84fe9dc](https://github.com/peerigon/configs/commit/84fe9dca95cdeba4e188d57a489ec6e12608fed4))
|
|
19
|
+
- Turn of TS's exactOptionalPropertyTypes ([4069985](https://github.com/peerigon/configs/commit/4069985cad9b2da629e441cc1f02fd0e4be7f4a0))
|
|
20
|
+
- Turn off unicorn/import-style ([f3be043](https://github.com/peerigon/configs/commit/f3be04315de51747319899f1ede9be15c1df5d6b))
|
|
21
|
+
- Turn off unicorn/no-single-promise-in-promise-methods ([0557a83](https://github.com/peerigon/configs/commit/0557a83c45b2fe3198f84d47412c90fbb87ddd69))
|
|
22
|
+
- TypeScript configs ([0c584e7](https://github.com/peerigon/configs/commit/0c584e70fd840e6ca857f4b177a21a389d958633))
|
|
23
|
+
- Use cross-publish semantic release config ([c079ce0](https://github.com/peerigon/configs/commit/c079ce0df36b436ffc46da9e86a562855b8f2082))
|
|
24
|
+
|
|
25
|
+
### Features
|
|
26
|
+
|
|
27
|
+
- Add docs ([83e7f61](https://github.com/peerigon/configs/commit/83e7f617d6fc44abcd7e0d05c700299d8e2910c2))
|
|
28
|
+
- Add shareable semantic-release config ([e0b585a](https://github.com/peerigon/configs/commit/e0b585a4eaaa4dbcfb206315870d3a22fa1d7186))
|
|
29
|
+
- Also release on Github ([0e3e84f](https://github.com/peerigon/configs/commit/0e3e84f54a4689c8c0c3a340435346c351662cc9))
|
|
30
|
+
- Enable .ts imports ([781a4a9](https://github.com/peerigon/configs/commit/781a4a97e15df6b218959c76c62a2e0893b3c026))
|
|
31
|
+
- Improve CSS property sorting ([f9b9790](https://github.com/peerigon/configs/commit/f9b97901a318146bdaa81b9c2019e9038104b389))
|
|
32
|
+
- Improve TS configs and add library types ([760a898](https://github.com/peerigon/configs/commit/760a8983b9d780601e7c6e2cb2c867f45f55f25f))
|
|
33
|
+
- Initial release ([8f12887](https://github.com/peerigon/configs/commit/8f128873b8481832dea06c88115a785c3c7a3627))
|
|
34
|
+
- Update dependencies ([07d0f37](https://github.com/peerigon/configs/commit/07d0f3781186cc86603444e0c2cf3b5185e3844a))
|
|
35
|
+
- Update dependencies ([839e69c](https://github.com/peerigon/configs/commit/839e69cdfef60349772479b7f5a7105c81be9d93))
|
|
36
|
+
- Update dependencies ([836a04f](https://github.com/peerigon/configs/commit/836a04f798741639837bb56fcf3ecbc028794c14))
|
|
37
|
+
- Update dependencies ([6bb1f24](https://github.com/peerigon/configs/commit/6bb1f242e7de360d96868b8e2b6aea58ce493c31))
|
|
38
|
+
|
|
39
|
+
# [1.0.0-beta.22](https://github.com/peerigon/configs/compare/v1.0.0-beta.21...v1.0.0-beta.22) (2025-02-04)
|
|
40
|
+
|
|
41
|
+
### Features
|
|
42
|
+
|
|
43
|
+
- Update dependencies ([07d0f37](https://github.com/peerigon/configs/commit/07d0f3781186cc86603444e0c2cf3b5185e3844a))
|
|
44
|
+
|
|
45
|
+
# [1.0.0-beta.21](https://github.com/peerigon/configs/compare/v1.0.0-beta.20...v1.0.0-beta.21) (2025-01-27)
|
|
46
|
+
|
|
47
|
+
### Bug Fixes
|
|
48
|
+
|
|
49
|
+
- Missing packages write permission in Github action ([ce0d482](https://github.com/peerigon/configs/commit/ce0d4820e2e75f164f5385e48bd8978c250216f1))
|
|
50
|
+
|
|
51
|
+
# [1.0.0-beta.20](https://github.com/peerigon/configs/compare/v1.0.0-beta.19...v1.0.0-beta.20) (2025-01-27)
|
|
52
|
+
|
|
53
|
+
### Bug Fixes
|
|
54
|
+
|
|
55
|
+
- Use cross-publish semantic release config ([c079ce0](https://github.com/peerigon/configs/commit/c079ce0df36b436ffc46da9e86a562855b8f2082))
|
|
56
|
+
|
|
57
|
+
# [1.0.0-beta.19](https://github.com/peerigon/configs/compare/v1.0.0-beta.18...v1.0.0-beta.19) (2025-01-27)
|
|
58
|
+
|
|
59
|
+
### Features
|
|
60
|
+
|
|
61
|
+
- Enable .ts imports ([781a4a9](https://github.com/peerigon/configs/commit/781a4a97e15df6b218959c76c62a2e0893b3c026))
|
|
62
|
+
- Update dependencies ([839e69c](https://github.com/peerigon/configs/commit/839e69cdfef60349772479b7f5a7105c81be9d93))
|
|
63
|
+
|
|
64
|
+
# [1.0.0-beta.18](https://github.com/peerigon/configs/compare/v1.0.0-beta.17...v1.0.0-beta.18) (2025-01-26)
|
|
65
|
+
|
|
66
|
+
### Features
|
|
67
|
+
|
|
68
|
+
- Add docs ([83e7f61](https://github.com/peerigon/configs/commit/83e7f617d6fc44abcd7e0d05c700299d8e2910c2))
|
|
69
|
+
|
|
70
|
+
# [1.0.0-beta.17](https://github.com/peerigon/configs/compare/v1.0.0-beta.16...v1.0.0-beta.17) (2025-01-20)
|
|
71
|
+
|
|
72
|
+
### Bug Fixes
|
|
73
|
+
|
|
74
|
+
- Changelog not formatted correctly ([cc12fa7](https://github.com/peerigon/configs/commit/cc12fa7abe725c4ab8597296094e2e485b1346e0))
|
|
75
|
+
|
|
76
|
+
# [1.0.0-beta.16](https://github.com/peerigon/configs/compare/v1.0.0-beta.15...v1.0.0-beta.16) (2025-01-20)
|
|
77
|
+
|
|
78
|
+
### Bug Fixes
|
|
79
|
+
|
|
80
|
+
- CHANGELOG.md not being properly formatted ([22720ea](https://github.com/peerigon/configs/commit/22720ea8bc3aab0477a89094b24f567571860c15))
|
|
81
|
+
|
|
82
|
+
### Features
|
|
83
|
+
|
|
84
|
+
- Improve CSS property sorting ([f9b9790](https://github.com/peerigon/configs/commit/f9b97901a318146bdaa81b9c2019e9038104b389))
|
|
85
|
+
|
|
86
|
+
# [1.0.0-beta.15](https://github.com/peerigon/configs/compare/v1.0.0-beta.14...v1.0.0-beta.15) (2024-12-30)
|
|
87
|
+
|
|
88
|
+
### Bug Fixes
|
|
89
|
+
|
|
90
|
+
- Remove rootDir config from lib tsconfig again ([84fe9dc](https://github.com/peerigon/configs/commit/84fe9dca95cdeba4e188d57a489ec6e12608fed4))
|
|
91
|
+
|
|
92
|
+
# [1.0.0-beta.14](https://github.com/peerigon/configs/compare/v1.0.0-beta.13...v1.0.0-beta.14) (2024-12-30)
|
|
93
|
+
|
|
94
|
+
### Bug Fixes
|
|
95
|
+
|
|
96
|
+
- Add rootDir to lib tsconfig ([764e0c1](https://github.com/peerigon/configs/commit/764e0c191f07dfd1d996937a4df488d56be5a159))
|
|
97
|
+
|
|
98
|
+
# [1.0.0-beta.13](https://github.com/peerigon/configs/compare/v1.0.0-beta.12...v1.0.0-beta.13) (2024-12-30)
|
|
99
|
+
|
|
100
|
+
### Bug Fixes
|
|
101
|
+
|
|
102
|
+
- Improve error message for no-default-export ([198c911](https://github.com/peerigon/configs/commit/198c91151a3dfd33339715c21ec95aa7c5bfbe05))
|
|
103
|
+
|
|
104
|
+
# [1.0.0-beta.12](https://github.com/peerigon/configs/compare/v1.0.0-beta.11...v1.0.0-beta.12) (2024-12-30)
|
|
105
|
+
|
|
106
|
+
### Bug Fixes
|
|
107
|
+
|
|
108
|
+
- Turn off unicorn/import-style ([f3be043](https://github.com/peerigon/configs/commit/f3be04315de51747319899f1ede9be15c1df5d6b))
|
|
109
|
+
|
|
110
|
+
# [1.0.0-beta.11](https://github.com/peerigon/configs/compare/v1.0.0-beta.10...v1.0.0-beta.11) (2024-12-15)
|
|
111
|
+
|
|
112
|
+
### Bug Fixes
|
|
113
|
+
|
|
114
|
+
- Move package types to regular dependencies ([6d6c169](https://github.com/peerigon/configs/commit/6d6c1695989f04898a1e730b6320b2cbea158a8f))
|
|
115
|
+
- noEmit setting in TypeScript configs ([281334c](https://github.com/peerigon/configs/commit/281334c3565ca0cd1afcc8d39a94857a0d42e9ae))
|
|
116
|
+
- Relax switch-exhaustiveness-check rule ([2f158a4](https://github.com/peerigon/configs/commit/2f158a4a25770897c6140d3356161349b79c1cc2))
|
|
117
|
+
|
|
118
|
+
# [1.0.0-beta.10](https://github.com/peerigon/configs/compare/v1.0.0-beta.9...v1.0.0-beta.10) (2024-12-11)
|
|
119
|
+
|
|
120
|
+
### Bug Fixes
|
|
121
|
+
|
|
122
|
+
- Turn of TS's exactOptionalPropertyTypes ([4069985](https://github.com/peerigon/configs/commit/4069985cad9b2da629e441cc1f02fd0e4be7f4a0))
|
|
123
|
+
- Turn off unicorn/no-single-promise-in-promise-methods ([0557a83](https://github.com/peerigon/configs/commit/0557a83c45b2fe3198f84d47412c90fbb87ddd69))
|
|
124
|
+
|
|
125
|
+
# [1.0.0-beta.9](https://github.com/peerigon/configs/compare/v1.0.0-beta.8...v1.0.0-beta.9) (2024-12-09)
|
|
126
|
+
|
|
127
|
+
### Features
|
|
128
|
+
|
|
129
|
+
- Improve TS configs and add library types ([760a898](https://github.com/peerigon/configs/commit/760a8983b9d780601e7c6e2cb2c867f45f55f25f))
|
|
130
|
+
|
|
1
131
|
# [1.0.0-beta.8](https://github.com/peerigon/configs/compare/v1.0.0-beta.7...v1.0.0-beta.8) (2024-11-16)
|
|
2
132
|
|
|
3
133
|
### Bug Fixes
|
package/README.md
CHANGED
|
@@ -1,451 +1,74 @@
|
|
|
1
|
-
#
|
|
1
|
+
# configs
|
|
2
2
|
|
|
3
|
-
**[
|
|
3
|
+
**Best practice configs for [ESLint](https://eslint.org/), [Prettier](https://prettier.io/), [TypeScript](https://www.typescriptlang.org/) & friends. By [Peerigon](https://www.peerigon.com/).**
|
|
4
4
|
|
|
5
|
-
[](https://www.npmjs.com/package/@peerigon/configs)
|
|
6
6
|
[](https://github.com/semantic-release/semantic-release)
|
|
7
|
-
[](https://www.npmjs.com/package/@peerigon/configs)<br>
|
|
8
|
+
[](./LICENSE)
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
## Installation
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
- ease of writing.
|
|
15
|
-
|
|
16
|
-
We think that
|
|
17
|
-
|
|
18
|
-
- code is read more often than refactored
|
|
19
|
-
- and refactored more often than written from scratch.
|
|
20
|
-
|
|
21
|
-
Our linting rules have been designed with these assumptions in mind.
|
|
22
|
-
|
|
23
|
-
## Table of contents
|
|
24
|
-
|
|
25
|
-
- [Quick start](#quick-start)
|
|
26
|
-
- [Practical guide](#practical-guide)
|
|
27
|
-
- [Provided configs](#provided-configs)
|
|
28
|
-
- [Styles](#styles)
|
|
29
|
-
|
|
30
|
-
## Quick start
|
|
31
|
-
|
|
32
|
-
Recommended configuration in your `package.json`:
|
|
33
|
-
|
|
34
|
-
```js
|
|
35
|
-
{
|
|
36
|
-
"scripts": {
|
|
37
|
-
"test:lint": "eslint --max-warnings 0 --cache",
|
|
38
|
-
"posttest": "npm run test:lint"
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
We also offer a [Prettier](https://prettier.io/) config that matches our ESLint config. Create a `.prettierrc.json` in your project with the following content:
|
|
44
|
-
|
|
45
|
-
```json
|
|
46
|
-
"eslint-config-peerigon/prettier.config.js"
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
There are presets for the most common setups:
|
|
50
|
-
|
|
51
|
-
### TypeScript
|
|
52
|
-
|
|
53
|
-
```
|
|
54
|
-
npm i eslint eslint-config-peerigon --save-dev
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
```js
|
|
58
|
-
{
|
|
59
|
-
"extends": [
|
|
60
|
-
"peerigon/presets/typescript.js"
|
|
61
|
-
],
|
|
62
|
-
"env": {
|
|
63
|
-
"node": true
|
|
64
|
-
},
|
|
65
|
-
"root": true
|
|
66
|
-
}
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
### TypeScript + React
|
|
70
|
-
|
|
71
|
-
```
|
|
72
|
-
npm i eslint eslint-config-peerigon eslint-plugin-react eslint-plugin-jsx-a11y eslint-plugin-react-hooks --save-dev
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
```js
|
|
76
|
-
{
|
|
77
|
-
"extends": [
|
|
78
|
-
"peerigon/presets/typescript-react.js"
|
|
79
|
-
],
|
|
80
|
-
"env": {
|
|
81
|
-
"node": true,
|
|
82
|
-
"browser": true
|
|
83
|
-
},
|
|
84
|
-
"root": true
|
|
85
|
-
}
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
### TypeScript + Node
|
|
89
|
-
|
|
90
|
-
```
|
|
91
|
-
npm i eslint eslint-config-peerigon eslint-plugin-n --save-dev
|
|
92
|
-
```
|
|
93
|
-
|
|
94
|
-
```js
|
|
95
|
-
{
|
|
96
|
-
"extends": [
|
|
97
|
-
"peerigon/presets/typescript-node.js"
|
|
98
|
-
],
|
|
99
|
-
"root": true
|
|
100
|
-
}
|
|
101
|
-
```
|
|
102
|
-
|
|
103
|
-
## Practical guide
|
|
104
|
-
|
|
105
|
-
### Disabling rules
|
|
106
|
-
|
|
107
|
-
Try to disable as less rules as possible. In most cases it's best to just write
|
|
108
|
-
|
|
109
|
-
```js
|
|
110
|
-
// eslint-disable-next-line [rule-code]
|
|
111
|
-
```
|
|
112
|
-
|
|
113
|
-
where `[rule-code]` is the code that is displayed along the error message. Disabling the next line is usually better because it resists [Prettier](https://prettier.io/) reformatting.
|
|
114
|
-
|
|
115
|
-
Sometimes it makes sense to disable a rule within a specifc file. In that case you can put the following snippet at the beginning of the file:
|
|
116
|
-
|
|
117
|
-
```js
|
|
118
|
-
/* eslint-disable [rule-code] */
|
|
119
|
-
```
|
|
120
|
-
|
|
121
|
-
If you don't agree with a rule, please do not just disable the rule. Often there are good reasons and the current setting is the result of years of experience. It's better to create an issue here to start a discussion about the pros and cons of a rule.
|
|
122
|
-
|
|
123
|
-
### Different styles
|
|
124
|
-
|
|
125
|
-
We acknowledge that there are certain rules where there are no actual pros and cons or where there is no clear winner. You just have to decide for one style and stick with it. We also know that some rules make sense in one project, but don't make sense in another project. That's why we also provide a list of [accepted custom styles](#styles) (see also [this discussion](https://github.com/peerigon/eslint-config-peerigon/issues/11)) which you can pick.
|
|
126
|
-
|
|
127
|
-
### VSCode
|
|
128
|
-
|
|
129
|
-
This is our recommended VSCode configuration using the [Prettier extension](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode). Adjust it to the needs of your particular project:
|
|
130
|
-
|
|
131
|
-
```json
|
|
132
|
-
{
|
|
133
|
-
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
|
134
|
-
"editor.formatOnSave": true,
|
|
135
|
-
"editor.codeActionsOnSave": {
|
|
136
|
-
"source.fixAll.eslint": true
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
```
|
|
140
|
-
|
|
141
|
-
### Experimental syntax using Babel
|
|
142
|
-
|
|
143
|
-
If you're using Babel you should set [`requireConfigFile: true`](https://github.com/babel/babel/tree/main/eslint/babel-eslint-parser#additional-parser-configuration) in your ESLint config. ESLint will then use your `babel.config.json`.
|
|
144
|
-
|
|
145
|
-
```js
|
|
146
|
-
{
|
|
147
|
-
"parserOptions": { "requireConfigFile": true },
|
|
148
|
-
}
|
|
149
|
-
```
|
|
150
|
-
|
|
151
|
-
### Naming conventions for properties
|
|
152
|
-
|
|
153
|
-
Sometimes we're not in full control over the naming conventions in our codebase, for instance if data is coming from a foreign API. While it often is preferable to transform property names into camelCase, it might not be practical. In these situations you can disable the check for properties like this:
|
|
154
|
-
|
|
155
|
-
```js
|
|
156
|
-
const options = require("eslint-config-peerigon/options.js");
|
|
157
|
-
|
|
158
|
-
module.exports = {
|
|
159
|
-
/* ... */
|
|
160
|
-
rules: {
|
|
161
|
-
// The API uses snake_case as properties
|
|
162
|
-
camelcase: [
|
|
163
|
-
"warn",
|
|
164
|
-
{
|
|
165
|
-
...options["camelcase"],
|
|
166
|
-
properties: "never",
|
|
167
|
-
},
|
|
168
|
-
],
|
|
169
|
-
},
|
|
170
|
-
};
|
|
171
|
-
```
|
|
172
|
-
|
|
173
|
-
**In TypeScript projects:**
|
|
174
|
-
|
|
175
|
-
```js
|
|
176
|
-
const options = require("eslint-config-peerigon/options.js");
|
|
177
|
-
|
|
178
|
-
module.exports = {
|
|
179
|
-
/* ... */
|
|
180
|
-
rules: {
|
|
181
|
-
// The API uses snake_case as properties
|
|
182
|
-
"@typescript-eslint/naming-convention": [
|
|
183
|
-
"warn",
|
|
184
|
-
options["@typescript-eslint/naming-convention"].ignoreProperties,
|
|
185
|
-
...options["@typescript-eslint/naming-convention"].defaultRules,
|
|
186
|
-
],
|
|
187
|
-
},
|
|
188
|
-
};
|
|
189
|
-
```
|
|
190
|
-
|
|
191
|
-
## Provided configs
|
|
192
|
-
|
|
193
|
-
### [`peerigon`](base.js)
|
|
194
|
-
|
|
195
|
-
**Base rules for every project. You should always add these rules.**
|
|
196
|
-
|
|
197
|
-
```
|
|
198
|
-
npm i eslint eslint-config-peerigon --save-dev
|
|
199
|
-
```
|
|
200
|
-
|
|
201
|
-
These rules assume a modern project with full ES2015 support, including ES modules. For specific environments like Node.js or old JS engines, see below. The base rules do not define an `env`, so you might want to do that for yourself to enable specific globals.
|
|
202
|
-
|
|
203
|
-
Add an `.eslintrc.json` to the project's root folder:
|
|
204
|
-
|
|
205
|
-
```js
|
|
206
|
-
{
|
|
207
|
-
"extends": [
|
|
208
|
-
// Base rules for every project
|
|
209
|
-
"peerigon"
|
|
210
|
-
],
|
|
211
|
-
// Do not search for further eslint configs in upper directories
|
|
212
|
-
"root": true,
|
|
213
|
-
// If you're using Babel, you should set requireConfigFile: true
|
|
214
|
-
// ESLint will then use your babel.config.json.
|
|
215
|
-
// "parserOptions": { "requireConfigFile": true },
|
|
216
|
-
}
|
|
217
|
-
```
|
|
218
|
-
|
|
219
|
-
The base rules use the `eslint-plugin-import` to resolve imports. Although it's possible to define [custom resolvers](https://github.com/benmosher/eslint-plugin-import#resolvers), it's highly discouraged to deviate from the common Node.js resolving algorithm. Other tools like linters and intellisense don't work reliably when you change the resolver.
|
|
220
|
-
|
|
221
|
-
### [`peerigon/typescript`](typescript.js)
|
|
222
|
-
|
|
223
|
-
Rules for [TypeScript](https://www.typescriptlang.org/).
|
|
224
|
-
|
|
225
|
-
```js
|
|
226
|
-
{
|
|
227
|
-
"extends": [
|
|
228
|
-
"peerigon",
|
|
229
|
-
"peerigon/typescript",
|
|
230
|
-
// Arrow functions are preferred with TypeScript
|
|
231
|
-
// See https://github.com/peerigon/eslint-config-peerigon/issues/23#issuecomment-472614432
|
|
232
|
-
"peerigon/styles/prefer-arrow"
|
|
233
|
-
],
|
|
234
|
-
"root": true,
|
|
235
|
-
}
|
|
12
|
+
```sh
|
|
13
|
+
npm install @peerigon/configs
|
|
236
14
|
```
|
|
237
15
|
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
```js
|
|
241
|
-
{
|
|
242
|
-
"scripts": {
|
|
243
|
-
"test:lint": "eslint --max-warnings 0 --cache --ext js,jsx,cjs,mjs,ts,tsx --ignore-path .gitignore ."
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
```
|
|
247
|
-
|
|
248
|
-
_We recommend using [`peerigon/styles/prefer-arrow`](#peerigonstylesprefer-arrow) because arrow functions (or function expressions in general) can leverage [TypeScript's contextual typing](https://www.typescriptlang.org/docs/handbook/type-inference.html#contextual-typing)._
|
|
249
|
-
|
|
250
|
-
### [`peerigon/node`](node.js)
|
|
16
|
+
Also checkout the instructions for each respective config:
|
|
251
17
|
|
|
252
|
-
|
|
18
|
+
- [ESLint](/eslint/README.md)
|
|
19
|
+
- [Prettier](/prettier/README.md)
|
|
20
|
+
- [TypeScript](/typescript/README.md)
|
|
21
|
+
- [Semantic release](/semantic-release/README.md)
|
|
253
22
|
|
|
254
|
-
|
|
255
|
-
npm i eslint-plugin-n --save-dev
|
|
256
|
-
```
|
|
257
|
-
|
|
258
|
-
```js
|
|
259
|
-
{
|
|
260
|
-
"extends": [
|
|
261
|
-
"peerigon",
|
|
262
|
-
"peerigon/node"
|
|
263
|
-
],
|
|
264
|
-
// Setting env.node = true is not necessary, this is already done by peerigon/node
|
|
265
|
-
"root": true
|
|
266
|
-
}
|
|
267
|
-
```
|
|
268
|
-
|
|
269
|
-
### [`peerigon/react`](react.js)
|
|
270
|
-
|
|
271
|
-
**Important: Requires [`eslint-plugin-react`](https://github.com/yannickcr/eslint-plugin-react), [`eslint-plugin-jsx-a11y`](https://github.com/evcohen/eslint-plugin-jsx-a11y) and [`eslint-plugin-react-hooks`](https://www.npmjs.com/package/eslint-plugin-react-hooks) as project dependency.**
|
|
272
|
-
|
|
273
|
-
```
|
|
274
|
-
npm i eslint-plugin-react eslint-plugin-jsx-a11y eslint-plugin-react-hooks --save-dev
|
|
275
|
-
```
|
|
276
|
-
|
|
277
|
-
Rules for [React](https://facebook.github.io/react/) development, including accessibility rules.
|
|
278
|
-
These rules are also applicable in other JSX environments, like [Preact](https://github.com/developit/preact):
|
|
279
|
-
|
|
280
|
-
```js
|
|
281
|
-
{
|
|
282
|
-
"extends": [
|
|
283
|
-
"peerigon",
|
|
284
|
-
"peerigon/react"
|
|
285
|
-
],
|
|
286
|
-
"root": true
|
|
287
|
-
}
|
|
288
|
-
```
|
|
289
|
-
|
|
290
|
-
_We recommend using [`peerigon/styles/react-jsx-no-literals`](#peerigonstylesreact-jsx-no-literals) if you're using i18n in your project._
|
|
291
|
-
_You can use [`peerigon/styles/react-jsx-no-bind`](#peerigonstylesreact-jsx-no-bind) if you're using `memo` and `shouldComponentUpdate` a lot._
|
|
292
|
-
|
|
293
|
-
### [`peerigon/jsdoc`](jsdoc.js)
|
|
294
|
-
|
|
295
|
-
**Important: Requires [`eslint-plugin-jsdoc`](https://github.com/gajus/eslint-plugin-jsdoc) as project dependency.**
|
|
296
|
-
|
|
297
|
-
```
|
|
298
|
-
npm i eslint-plugin-jsdoc --save-dev
|
|
299
|
-
```
|
|
300
|
-
|
|
301
|
-
Makes sure that JSDoc annotations are written in a standard-compliant and uniform way.
|
|
302
|
-
|
|
303
|
-
```js
|
|
304
|
-
{
|
|
305
|
-
"extends": [
|
|
306
|
-
"peerigon",
|
|
307
|
-
"peerigon/jsdoc"
|
|
308
|
-
],
|
|
309
|
-
"root": true
|
|
310
|
-
}
|
|
311
|
-
```
|
|
312
|
-
|
|
313
|
-
## Styles
|
|
314
|
-
|
|
315
|
-
The following rules enable specific writing styles. Use them as you prefer.
|
|
316
|
-
|
|
317
|
-
### [`peerigon/styles/prefer-arrow`](styles/prefer-arrow.js)
|
|
318
|
-
|
|
319
|
-
Enforces arrow function expressions instead of function declarations (see [#23](https://github.com/peerigon/eslint-config-peerigon/issues/23)).
|
|
320
|
-
Regular functions are still allowed as methods in objects or classes.
|
|
321
|
-
|
|
322
|
-
```js
|
|
323
|
-
"extends": [
|
|
324
|
-
"peerigon",
|
|
325
|
-
"peerigon/styles/prefer-arrow"
|
|
326
|
-
],
|
|
327
|
-
```
|
|
23
|
+
## Philosophy
|
|
328
24
|
|
|
329
|
-
|
|
25
|
+
Linting, formatting and type-checking rules are always a balance between:
|
|
330
26
|
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
"extends": [
|
|
335
|
-
"peerigon",
|
|
336
|
-
"peerigon/styles/no-default-export"
|
|
337
|
-
],
|
|
338
|
-
```
|
|
339
|
-
|
|
340
|
-
**Please note:** This rule is disabled in `.jsx` and `.tsx` files because React components are usually exported via `export default`. [`React.lazy`](https://reactjs.org/docs/code-splitting.html#reactlazy) even expects the lazy loaded component to be exported as `default`.
|
|
341
|
-
|
|
342
|
-
### [`peerigon/styles/no-null`](styles/no-null.js)
|
|
343
|
-
|
|
344
|
-
**Important: Requires [`eslint-plugin-no-null`](https://github.com/nene/eslint-plugin-no-null) as project dependency.**
|
|
345
|
-
|
|
346
|
-
```
|
|
347
|
-
npm i eslint-plugin-no-null --save-dev
|
|
348
|
-
```
|
|
349
|
-
|
|
350
|
-
Forbids the usage of `null`. In a codebase it's often better to use a single non-value to represent _the absence of a value_. With the rise of default parameters and destructuring defaults, JavaScript developed a clear tendency towards `undefined`. [This issue](https://github.com/peerigon/eslint-config-peerigon/issues/71) summarizes the arguments (and trade-offs) of **null vs. undefined**.
|
|
351
|
-
|
|
352
|
-
```js
|
|
353
|
-
"extends": [
|
|
354
|
-
"peerigon",
|
|
355
|
-
"peerigon/styles/no-null"
|
|
356
|
-
],
|
|
357
|
-
```
|
|
358
|
-
|
|
359
|
-
**Please note:** If you use this rule, you will probably still need a single `null` value which you can refer to whenever you need to use `null` because of third-party code:
|
|
360
|
-
|
|
361
|
-
```js
|
|
362
|
-
// eslint-disable-next-line no-null/no-null
|
|
363
|
-
export const NULL = null;
|
|
364
|
-
```
|
|
365
|
-
|
|
366
|
-
### [`peerigon/styles/prefer-interface`](styles/prefer-interface.js)
|
|
367
|
-
|
|
368
|
-
**Important: Use it in combination with [`peerigon/typescript`](typescript.js).**
|
|
369
|
-
|
|
370
|
-
[Prefer `interface` over `type`](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/prefer-interface.md).
|
|
371
|
-
|
|
372
|
-
```js
|
|
373
|
-
"extends": [
|
|
374
|
-
"peerigon",
|
|
375
|
-
"peerigon/typescript",
|
|
376
|
-
"peerigon/styles/prefer-interface"
|
|
377
|
-
],
|
|
378
|
-
```
|
|
379
|
-
|
|
380
|
-
### [`peerigon/styles/react-jsx-no-bind`](styles/react-jsx-no-bind.js)
|
|
381
|
-
|
|
382
|
-
**Important: Use it in combination with [`peerigon/react`](react.js).**
|
|
383
|
-
|
|
384
|
-
Depending on the way you write your components, it might be not ok to create functions during `render()`. Use it if you're using things like `React.memo()` or `shouldComponentUpdate` a lot.
|
|
385
|
-
|
|
386
|
-
```js
|
|
387
|
-
"extends": [
|
|
388
|
-
"peerigon",
|
|
389
|
-
"peerigon/react",
|
|
390
|
-
"peerigon/styles/react-jsx-no-bind"
|
|
391
|
-
],
|
|
392
|
-
```
|
|
393
|
-
|
|
394
|
-
### [`peerigon/styles/react-jsx-no-literals`](styles/react-jsx-no-literals.js)
|
|
27
|
+
- ease of reading
|
|
28
|
+
- ease of refactoring
|
|
29
|
+
- ease of writing.
|
|
395
30
|
|
|
396
|
-
|
|
31
|
+
We think that:
|
|
397
32
|
|
|
398
|
-
|
|
33
|
+
- code is read more often than refactored
|
|
34
|
+
- and refactored more often than written from scratch.
|
|
399
35
|
|
|
400
|
-
|
|
401
|
-
"extends": [
|
|
402
|
-
"peerigon",
|
|
403
|
-
"peerigon/react",
|
|
404
|
-
"peerigon/styles/react-jsx-no-literals"
|
|
405
|
-
],
|
|
406
|
-
```
|
|
36
|
+
Our configs have been designed with these assumptions in mind.
|
|
407
37
|
|
|
408
|
-
|
|
38
|
+
### Formatting
|
|
409
39
|
|
|
410
|
-
|
|
411
|
-
const Hello = <div>test</div>;
|
|
412
|
-
```
|
|
40
|
+
Formatting should follow the community standard. Our config is therefore based on Prettier's default config. Besides that it also:
|
|
413
41
|
|
|
414
|
-
|
|
42
|
+
- auto-sorts `import` statements
|
|
43
|
+
- formats JSDoc comments
|
|
44
|
+
- formats `package.json`
|
|
45
|
+
- formats and sorts CSS properties
|
|
46
|
+
- sorts Tailwind CSS class names
|
|
415
47
|
|
|
416
|
-
|
|
417
|
-
const Hello = <div>{"test"}</div>;
|
|
418
|
-
```
|
|
48
|
+
This makes git diffs smaller and reviewing them more focussed.
|
|
419
49
|
|
|
420
|
-
###
|
|
50
|
+
### Linting
|
|
421
51
|
|
|
422
|
-
|
|
52
|
+
Linting should mostly catch bugs in the control flow and prevent security issues. Furthermore, it should enforce a modern, idiomatic and consistent code style that is easy to read and to refactor.
|
|
423
53
|
|
|
424
|
-
|
|
54
|
+
However, it should **not** nit-pick on formatting or favor certain language features where other options are equally ok. Every rule must be legitimized by objective criteria. A simple “I find it easier to read” is not enough.
|
|
425
55
|
|
|
426
|
-
|
|
427
|
-
"extends": [
|
|
428
|
-
"peerigon",
|
|
429
|
-
"peerigon/typescript",
|
|
430
|
-
"peerigon/styles/prefer-array-shorthand"
|
|
431
|
-
],
|
|
432
|
-
```
|
|
56
|
+
Our linting rules:
|
|
433
57
|
|
|
434
|
-
|
|
58
|
+
- are mostly based on recommended sets
|
|
59
|
+
- use type information to catch logic bugs
|
|
60
|
+
- highlight a11y problems
|
|
61
|
+
- are less strict in tests
|
|
435
62
|
|
|
436
|
-
|
|
437
|
-
const foo: string[] = [];
|
|
438
|
-
```
|
|
63
|
+
### Type-checking
|
|
439
64
|
|
|
440
|
-
|
|
65
|
+
Type-checking should be rather strict because it is the foundation for safe and sound refactorings. If type-checking is too loose, it may lull the developer into a false sense of security. It should also prevent out-of-bounds errors when accessing arrays or objects.
|
|
441
66
|
|
|
442
|
-
|
|
443
|
-
const foo: Array<string> = [];
|
|
444
|
-
```
|
|
67
|
+
For highly dynamic code or incompatible types, local exceptions to type safety and escape hatches need to be possible.
|
|
445
68
|
|
|
446
69
|
## License
|
|
447
70
|
|
|
448
|
-
|
|
71
|
+
MIT
|
|
449
72
|
|
|
450
73
|
## Sponsors
|
|
451
74
|
|
package/docs/prettier.md
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
## Reasoning
|
|
2
|
+
|
|
3
|
+
### `noUncheckedIndexedAccess`
|
|
4
|
+
|
|
5
|
+
- Mention tiny-invariant
|
|
6
|
+
|
|
7
|
+
### `noPropertyAccessFromIndexSignature`
|
|
8
|
+
|
|
9
|
+
### `exactOptionalPropertyTypes`
|
|
10
|
+
|
|
11
|
+
### `verbatimModuleSyntax`
|
|
12
|
+
|
|
13
|
+
### `allowImportingTsExtensions`
|
|
14
|
+
|
|
15
|
+
### `rewriteRelativeImportExtensions`
|