@foray1010/eslint-config 10.4.3 → 10.5.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 +10 -0
- package/README.md +10 -2
- package/bases/base.mjs +35 -11
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,16 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [10.5.0](https://github.com/foray1010/common-presets/compare/@foray1010/eslint-config@10.4.3...@foray1010/eslint-config@10.5.0) (2023-04-15)
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
- **eslint-config:** enable functional/prefer-immutable-types and type-declaration-immutability ([9dc211e](https://github.com/foray1010/common-presets/commit/9dc211e550df72c4538a5526285ad635b1a491d5))
|
|
11
|
+
|
|
12
|
+
### Bug Fixes
|
|
13
|
+
|
|
14
|
+
- **eslint-config:** remove warning message when uses with typescript v5 ([c3b1a82](https://github.com/foray1010/common-presets/commit/c3b1a822f6e598db6571a467bbb32d083acacdbb))
|
|
15
|
+
|
|
6
16
|
## [10.4.3](https://github.com/foray1010/common-presets/compare/@foray1010/eslint-config@10.4.2...@foray1010/eslint-config@10.4.3) (2023-03-31)
|
|
7
17
|
|
|
8
18
|
### Bug Fixes
|
package/README.md
CHANGED
|
@@ -20,7 +20,7 @@ Z for looser rules
|
|
|
20
20
|
|
|
21
21
|
1. `yarn add -DE @foray1010/eslint-config eslint prettier`
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
2. Create an `eslint.config.js` in the project root
|
|
24
24
|
|
|
25
25
|
- For general purpose or Node.js project (support TypeScript)
|
|
26
26
|
|
|
@@ -87,7 +87,15 @@ Z for looser rules
|
|
|
87
87
|
export default config
|
|
88
88
|
```
|
|
89
89
|
|
|
90
|
-
|
|
90
|
+
3. If the project support ES Modules, you can directly use `eslint` command with the following setting in `package.json`.
|
|
91
|
+
|
|
92
|
+
```json
|
|
93
|
+
{
|
|
94
|
+
"type": "module"
|
|
95
|
+
}
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
4. If the project does not support ES Modules, you have to put the config in `eslint.config.mjs` instead, and use the following npm script in `package.json`. Note that your editor may not support custom eslint config path and may not work properly.
|
|
91
99
|
|
|
92
100
|
```json
|
|
93
101
|
{
|
package/bases/base.mjs
CHANGED
|
@@ -154,9 +154,6 @@ async function generateTypeScriptConfig() {
|
|
|
154
154
|
typedefs: false,
|
|
155
155
|
},
|
|
156
156
|
],
|
|
157
|
-
// use with functional/prefer-readonly-type
|
|
158
|
-
// mark class variables as readonly if it is not mutated
|
|
159
|
-
'@typescript-eslint/prefer-readonly': 'error',
|
|
160
157
|
// make sure functions which return a promise will just return a rejected promise instead of throwing an error
|
|
161
158
|
'@typescript-eslint/promise-function-async': 'error',
|
|
162
159
|
// allow primitive value in template string
|
|
@@ -176,20 +173,47 @@ async function generateTypeScriptConfig() {
|
|
|
176
173
|
'@typescript-eslint/unbound-method': ['error', { ignoreStatic: true }],
|
|
177
174
|
// do not allow usage of deprecated code
|
|
178
175
|
'deprecation/deprecation': 'error',
|
|
179
|
-
// use with
|
|
180
|
-
'functional/prefer-
|
|
176
|
+
// use with functional/type-declaration-immutability
|
|
177
|
+
'functional/prefer-immutable-types': [
|
|
181
178
|
'error',
|
|
182
179
|
{
|
|
183
|
-
//
|
|
184
|
-
|
|
185
|
-
//
|
|
186
|
-
|
|
187
|
-
//
|
|
188
|
-
|
|
180
|
+
// as there is no native way to achieve `ReadonlyDeep` in TypeScript
|
|
181
|
+
enforcement: 'ReadonlyShallow',
|
|
182
|
+
// reduce the difficult to use this rule
|
|
183
|
+
ignoreInferredTypes: true,
|
|
184
|
+
// escape hatch without using eslint-disable
|
|
185
|
+
ignoreNamePattern: 'Mutable$',
|
|
186
|
+
ignoreTypePattern: [
|
|
187
|
+
'^React.', // Some React types does not work with `Readonly`
|
|
188
|
+
],
|
|
189
189
|
},
|
|
190
190
|
],
|
|
191
191
|
// forbid unnecessary callback wrapper
|
|
192
192
|
'functional/prefer-tacit': 'error',
|
|
193
|
+
// use with functional/prefer-immutable-types
|
|
194
|
+
'functional/type-declaration-immutability': [
|
|
195
|
+
'error',
|
|
196
|
+
{
|
|
197
|
+
rules: [
|
|
198
|
+
{
|
|
199
|
+
identifiers: '.+',
|
|
200
|
+
immutability: 'ReadonlyShallow',
|
|
201
|
+
comparator: 'AtLeast',
|
|
202
|
+
// modified from https://github.com/eslint-functional/eslint-plugin-functional/blob/main/docs/rules/type-declaration-immutability.md#preset-overrides
|
|
203
|
+
fixer: [
|
|
204
|
+
{
|
|
205
|
+
pattern: '^(Array|Map|Set)<(.+)>$',
|
|
206
|
+
replace: 'Readonly$1<$2>',
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
pattern: '^(.+)$',
|
|
210
|
+
replace: 'Readonly<$1>',
|
|
211
|
+
},
|
|
212
|
+
],
|
|
213
|
+
},
|
|
214
|
+
],
|
|
215
|
+
},
|
|
216
|
+
],
|
|
193
217
|
'no-restricted-syntax': [
|
|
194
218
|
'error',
|
|
195
219
|
{
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package",
|
|
3
3
|
"name": "@foray1010/eslint-config",
|
|
4
|
-
"version": "10.
|
|
4
|
+
"version": "10.5.0",
|
|
5
5
|
"homepage": "https://github.com/foray1010/common-presets/tree/master/packages/eslint-config#readme",
|
|
6
6
|
"bugs": "https://github.com/foray1010/common-presets/issues",
|
|
7
7
|
"repository": {
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
"eslint-config-prettier": "^8.8.0",
|
|
30
30
|
"eslint-import-resolver-typescript": "^3.5.2",
|
|
31
31
|
"eslint-plugin-compat": "^4.1.2",
|
|
32
|
-
"eslint-plugin-deprecation": "^1.
|
|
33
|
-
"eslint-plugin-functional": "^5.0.
|
|
32
|
+
"eslint-plugin-deprecation": "^1.4.0",
|
|
33
|
+
"eslint-plugin-functional": "^5.0.8",
|
|
34
34
|
"eslint-plugin-import": "^2.22.1",
|
|
35
35
|
"eslint-plugin-jest": "^27.1.3",
|
|
36
36
|
"eslint-plugin-jest-dom": "^4.0.0",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@types/confusing-browser-globals": "1.0.0",
|
|
49
|
-
"@types/eslint": "8.
|
|
49
|
+
"@types/eslint": "8.37.0"
|
|
50
50
|
},
|
|
51
51
|
"peerDependencies": {
|
|
52
52
|
"eslint": "^8.36.0",
|
|
@@ -64,5 +64,5 @@
|
|
|
64
64
|
"publishConfig": {
|
|
65
65
|
"access": "public"
|
|
66
66
|
},
|
|
67
|
-
"gitHead": "
|
|
67
|
+
"gitHead": "944fe72ee061b3626ffae018135f391a2fdd2013"
|
|
68
68
|
}
|