@foray1010/eslint-config 8.0.0 → 9.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 +31 -0
- package/{index.js → index.cjs} +1 -1
- package/package.json +14 -14
- package/presets/{base.js → base.cjs} +23 -2
- package/presets/{browser.js → browser.cjs} +0 -0
- package/presets/{node.js → node.cjs} +2 -2
- package/presets/{react.js → react.cjs} +1 -1
- package/presets/utils/{testUtil.js → testUtil.cjs} +0 -0
- package/react.cjs +9 -0
- package/react.js +0 -5
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,37 @@
|
|
|
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
|
+
## [9.0.0](https://github.com/foray1010/common-presets/compare/@foray1010/eslint-config@8.0.1...@foray1010/eslint-config@9.0.0) (2022-11-07)
|
|
7
|
+
|
|
8
|
+
### ⚠ BREAKING CHANGES
|
|
9
|
+
|
|
10
|
+
- drop nodejs 14.17 and 18.11
|
|
11
|
+
|
|
12
|
+
### Features
|
|
13
|
+
|
|
14
|
+
- **eslint-config:** disallow builtins to be created without `new` operator ([1c0c1a8](https://github.com/foray1010/common-presets/commit/1c0c1a86bbaf8a7c2bfcbd7998041418329fc8e2))
|
|
15
|
+
- **eslint-config:** disallow duplicated value in enum as it is error-prone ([5795a82](https://github.com/foray1010/common-presets/commit/5795a82945eaeec967a8403e167defbe587b4583))
|
|
16
|
+
- **eslint-config:** enable @typescript-eslint/no-unsafe-declaration-merging ([1b4abe2](https://github.com/foray1010/common-presets/commit/1b4abe27a5322729321b61f5d406cf9af7aaf51a))
|
|
17
|
+
- **eslint-config:** make sure functions which return a promise will just return a rejected promise ([06603f4](https://github.com/foray1010/common-presets/commit/06603f42098f5492037c0114ecc50fac623a11c3))
|
|
18
|
+
- **eslint-config:** prefer node protocol ([204e5c1](https://github.com/foray1010/common-presets/commit/204e5c168aacaa020d2481306489724dfd6da7bc))
|
|
19
|
+
- **eslint-config:** require switch-case statements to be exhaustive with union type ([2b13aa6](https://github.com/foray1010/common-presets/commit/2b13aa60c1622a75f4a84133b3bf31b90b676057))
|
|
20
|
+
- **eslint-config:** separate type exports which allow certain optimizations within compilers ([bbc6b9b](https://github.com/foray1010/common-presets/commit/bbc6b9b9a83fecf552ed85be838693ec04c8b149))
|
|
21
|
+
|
|
22
|
+
### Bug Fixes
|
|
23
|
+
|
|
24
|
+
- **deps:** update dependency eslint-import-resolver-typescript to v3 ([0ff474e](https://github.com/foray1010/common-presets/commit/0ff474ef79193b53a29ea0ad7026e3cc12e1227e))
|
|
25
|
+
- **eslint-config:** does not report error when importing ts files without extension ([aea8307](https://github.com/foray1010/common-presets/commit/aea83079cae7967c405a38599b2ad63169cf8be6))
|
|
26
|
+
|
|
27
|
+
### Miscellaneous Chores
|
|
28
|
+
|
|
29
|
+
- drop nodejs 14.17 and 18.11 ([8e5c967](https://github.com/foray1010/common-presets/commit/8e5c9677b89d38c88de465f069bb5de683a8a40b))
|
|
30
|
+
|
|
31
|
+
## [8.0.1](https://github.com/foray1010/common-presets/compare/@foray1010/eslint-config@8.0.0...@foray1010/eslint-config@8.0.1) (2022-10-22)
|
|
32
|
+
|
|
33
|
+
### Bug Fixes
|
|
34
|
+
|
|
35
|
+
- **eslint-config:** add back support for node 14.17 ([3264119](https://github.com/foray1010/common-presets/commit/3264119b95b5364cd6c952536dffce49b5f14955))
|
|
36
|
+
|
|
6
37
|
## [8.0.0](https://github.com/foray1010/common-presets/compare/@foray1010/eslint-config@7.12.0...@foray1010/eslint-config@8.0.0) (2022-10-21)
|
|
7
38
|
|
|
8
39
|
### ⚠ BREAKING CHANGES
|
package/{index.js → index.cjs}
RENAMED
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": "
|
|
4
|
+
"version": "9.0.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": {
|
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
},
|
|
12
12
|
"license": "MIT",
|
|
13
13
|
"exports": {
|
|
14
|
-
".": "./index.
|
|
15
|
-
"./react": "./react.
|
|
14
|
+
".": "./index.cjs",
|
|
15
|
+
"./react": "./react.cjs"
|
|
16
16
|
},
|
|
17
17
|
"files": [
|
|
18
18
|
"**/*.{cjs,js,json,mjs}",
|
|
@@ -23,9 +23,9 @@
|
|
|
23
23
|
"type:check": "tsc"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@foray1010/common-presets-utils": "^
|
|
27
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
28
|
-
"@typescript-eslint/parser": "^5.
|
|
26
|
+
"@foray1010/common-presets-utils": "^6.0.0",
|
|
27
|
+
"@typescript-eslint/eslint-plugin": "^5.42.1",
|
|
28
|
+
"@typescript-eslint/parser": "^5.42.1",
|
|
29
29
|
"confusing-browser-globals": "^1.0.10",
|
|
30
30
|
"eslint-config-prettier": "^8.3.0",
|
|
31
31
|
"eslint-import-resolver-typescript": "^3.5.2",
|
|
@@ -34,30 +34,30 @@
|
|
|
34
34
|
"eslint-plugin-eslint-comments": "^3.2.0",
|
|
35
35
|
"eslint-plugin-functional": "^4.4.1",
|
|
36
36
|
"eslint-plugin-import": "^2.22.1",
|
|
37
|
-
"eslint-plugin-jest": "^27.
|
|
37
|
+
"eslint-plugin-jest": "^27.1.3",
|
|
38
38
|
"eslint-plugin-jest-dom": "^4.0.0",
|
|
39
|
-
"eslint-plugin-jsdoc": "^39.3.
|
|
39
|
+
"eslint-plugin-jsdoc": "^39.3.25",
|
|
40
40
|
"eslint-plugin-n": "^15.3.0",
|
|
41
41
|
"eslint-plugin-prettier": "^4.0.0",
|
|
42
|
-
"eslint-plugin-react": "^7.31.
|
|
42
|
+
"eslint-plugin-react": "^7.31.10",
|
|
43
43
|
"eslint-plugin-react-hooks": "^4.2.0",
|
|
44
44
|
"eslint-plugin-simple-import-sort": "^8.0.0",
|
|
45
|
-
"eslint-plugin-testing-library": "^5.
|
|
46
|
-
"eslint-plugin-unicorn": "^
|
|
45
|
+
"eslint-plugin-testing-library": "^5.9.1",
|
|
46
|
+
"eslint-plugin-unicorn": "^44.0.2"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"@types/confusing-browser-globals": "1.0.0",
|
|
50
|
-
"@types/eslint": "8.4.
|
|
50
|
+
"@types/eslint": "8.4.10"
|
|
51
51
|
},
|
|
52
52
|
"peerDependencies": {
|
|
53
53
|
"eslint": "^8.0.0",
|
|
54
54
|
"prettier": "^2.0.0"
|
|
55
55
|
},
|
|
56
56
|
"engines": {
|
|
57
|
-
"node": "^14.
|
|
57
|
+
"node": "^14.18.0 || ^16.13.0 || >=18.12.0"
|
|
58
58
|
},
|
|
59
59
|
"publishConfig": {
|
|
60
60
|
"access": "public"
|
|
61
61
|
},
|
|
62
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "4acba77dace91746ac98872f4b8f62b410de82f5"
|
|
63
63
|
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// @ts-expect-error
|
|
4
4
|
const { hasDep, isESM } = require('@foray1010/common-presets-utils')
|
|
5
5
|
|
|
6
|
-
const { testFileGlobs } = require('./utils/testUtil.
|
|
6
|
+
const { testFileGlobs } = require('./utils/testUtil.cjs')
|
|
7
7
|
|
|
8
8
|
/** @type {import('eslint').Linter.BaseConfig} */
|
|
9
9
|
const cjsConfig = {
|
|
@@ -71,6 +71,7 @@ module.exports = {
|
|
|
71
71
|
'func-names': ['error', 'as-needed'],
|
|
72
72
|
// this rule doesn't support commonjs, some dependencies are using commonjs
|
|
73
73
|
'import/default': 'off',
|
|
74
|
+
// use with `n/file-extension-in-import`
|
|
74
75
|
// enforce extensions for both cjs and esm
|
|
75
76
|
'import/extensions': [
|
|
76
77
|
'error',
|
|
@@ -78,7 +79,7 @@ module.exports = {
|
|
|
78
79
|
'always',
|
|
79
80
|
{
|
|
80
81
|
pattern: {
|
|
81
|
-
//
|
|
82
|
+
// handled by `n/file-extension-in-import` because eslint-plugin-import does not support es modules in typescript files
|
|
82
83
|
cts: 'never',
|
|
83
84
|
mts: 'never',
|
|
84
85
|
ts: 'never',
|
|
@@ -139,8 +140,15 @@ module.exports = {
|
|
|
139
140
|
'jsdoc/valid-types': 'off',
|
|
140
141
|
// avoid assigning anonymous function to object key which is harder to trace when debug
|
|
141
142
|
'object-shorthand': ['error', 'always'],
|
|
143
|
+
// use with `unicorn/throw-new-error`
|
|
144
|
+
// disallow builtins to be created without `new` operator, to be consistent with es6 class syntax
|
|
145
|
+
'unicorn/new-for-builtins': 'error',
|
|
146
|
+
// prefer `import from 'node:xxx'`
|
|
147
|
+
'unicorn/prefer-node-protocol': 'error',
|
|
142
148
|
// prefer Number static properties over global ones
|
|
143
149
|
'unicorn/prefer-number-properties': 'error',
|
|
150
|
+
// use with `unicorn/new-for-builtins`
|
|
151
|
+
'unicorn/throw-new-error': 'error',
|
|
144
152
|
},
|
|
145
153
|
overrides: [
|
|
146
154
|
{
|
|
@@ -197,6 +205,7 @@ module.exports = {
|
|
|
197
205
|
'@typescript-eslint/eslint-plugin',
|
|
198
206
|
'eslint-plugin-deprecation',
|
|
199
207
|
'eslint-plugin-functional',
|
|
208
|
+
'eslint-plugin-n',
|
|
200
209
|
],
|
|
201
210
|
rules: {
|
|
202
211
|
// extend existing rule
|
|
@@ -210,6 +219,8 @@ module.exports = {
|
|
|
210
219
|
extendDefaults: true,
|
|
211
220
|
},
|
|
212
221
|
],
|
|
222
|
+
// separate type exports which allow certain optimizations within compilers
|
|
223
|
+
'@typescript-eslint/consistent-type-exports': 'error',
|
|
213
224
|
// separate type imports which allow certain optimizations within compilers
|
|
214
225
|
'@typescript-eslint/consistent-type-imports': [
|
|
215
226
|
'error',
|
|
@@ -233,6 +244,8 @@ module.exports = {
|
|
|
233
244
|
],
|
|
234
245
|
// sometimes auto detect can provide a better and narrower type
|
|
235
246
|
'@typescript-eslint/explicit-module-boundary-types': 'off',
|
|
247
|
+
// disallow duplicated value in enum as it is error-prone
|
|
248
|
+
'@typescript-eslint/no-duplicate-enum-values': 'error',
|
|
236
249
|
// need empty function for react context default value
|
|
237
250
|
'@typescript-eslint/no-empty-function': 'off',
|
|
238
251
|
// encourage to check error type before use in catch clauses
|
|
@@ -244,6 +257,8 @@ module.exports = {
|
|
|
244
257
|
'error',
|
|
245
258
|
{ checksVoidReturn: false },
|
|
246
259
|
],
|
|
260
|
+
// declaration merging between classes and interfaces is unsafe
|
|
261
|
+
'@typescript-eslint/no-unsafe-declaration-merging': 'error',
|
|
247
262
|
// do not block functions referring to other functions
|
|
248
263
|
'@typescript-eslint/no-use-before-define': [
|
|
249
264
|
'error',
|
|
@@ -265,6 +280,8 @@ module.exports = {
|
|
|
265
280
|
// use with functional/prefer-readonly-type
|
|
266
281
|
// mark class variables as readonly if it is not mutated
|
|
267
282
|
'@typescript-eslint/prefer-readonly': 'error',
|
|
283
|
+
// make sure functions which return a promise will just return a rejected promise instead of throwing an error
|
|
284
|
+
'@typescript-eslint/promise-function-async': 'error',
|
|
268
285
|
// allow primitive value in template string
|
|
269
286
|
'@typescript-eslint/restrict-template-expressions': [
|
|
270
287
|
'error',
|
|
@@ -276,6 +293,8 @@ module.exports = {
|
|
|
276
293
|
allowRegExp: true,
|
|
277
294
|
},
|
|
278
295
|
],
|
|
296
|
+
// avoid missed switch-case by requiring switch-case statements to be exhaustive with union type
|
|
297
|
+
'@typescript-eslint/switch-exhaustiveness-check': 'error',
|
|
279
298
|
// ignore static function as those are not supposed to use `this`
|
|
280
299
|
'@typescript-eslint/unbound-method': [
|
|
281
300
|
'error',
|
|
@@ -297,6 +316,8 @@ module.exports = {
|
|
|
297
316
|
],
|
|
298
317
|
// forbid unnecessary callback wrapper
|
|
299
318
|
'functional/prefer-tacit': 'error',
|
|
319
|
+
// use with `import/extensions` because it doesn't work with TypeScript
|
|
320
|
+
'n/file-extension-in-import': ['error', 'always'],
|
|
300
321
|
'no-restricted-syntax': [
|
|
301
322
|
'error',
|
|
302
323
|
{
|
|
File without changes
|
|
@@ -39,10 +39,10 @@ module.exports = {
|
|
|
39
39
|
'n/prefer-global/text-decoder': ['error', 'always'],
|
|
40
40
|
// prefer global `TextEncoder` to be isomorphic
|
|
41
41
|
'n/prefer-global/text-encoder': ['error', 'always'],
|
|
42
|
-
// prefer global `URLSearchParams` to be isomorphic
|
|
43
|
-
'n/prefer-global/url-search-params': ['error', 'always'],
|
|
44
42
|
// prefer global `URL` to be isomorphic
|
|
45
43
|
'n/prefer-global/url': ['error', 'always'],
|
|
44
|
+
// prefer global `URLSearchParams` to be isomorphic
|
|
45
|
+
'n/prefer-global/url-search-params': ['error', 'always'],
|
|
46
46
|
// make `process.exit()` expressions the same code path as `throw`
|
|
47
47
|
'n/process-exit-as-throw': 'error',
|
|
48
48
|
// enforce shebang on the entry bin file
|
|
File without changes
|
package/react.cjs
ADDED