@foray1010/eslint-config 7.12.0 → 8.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 +10 -0
- package/package.json +3 -2
- package/presets/base.js +23 -20
- package/presets/node.js +21 -4
- package/presets/react.js +1 -1
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
|
+
## [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
|
+
|
|
8
|
+
### ⚠ BREAKING CHANGES
|
|
9
|
+
|
|
10
|
+
- enforce file extension and use native esm typescript
|
|
11
|
+
|
|
12
|
+
### Features
|
|
13
|
+
|
|
14
|
+
- enforce file extension and use native esm typescript ([c885710](https://github.com/foray1010/common-presets/commit/c8857103a3f828d2cf9946885495bd92d15b8d5d))
|
|
15
|
+
|
|
6
16
|
## [7.12.0](https://github.com/foray1010/common-presets/compare/@foray1010/eslint-config@7.11.0...@foray1010/eslint-config@7.12.0) (2022-10-20)
|
|
7
17
|
|
|
8
18
|
### Features
|
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": "8.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": {
|
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
"@typescript-eslint/parser": "^5.38.1",
|
|
29
29
|
"confusing-browser-globals": "^1.0.10",
|
|
30
30
|
"eslint-config-prettier": "^8.3.0",
|
|
31
|
+
"eslint-import-resolver-typescript": "^3.5.2",
|
|
31
32
|
"eslint-plugin-compat": "^4.0.0",
|
|
32
33
|
"eslint-plugin-deprecation": "^1.3.2",
|
|
33
34
|
"eslint-plugin-eslint-comments": "^3.2.0",
|
|
@@ -58,5 +59,5 @@
|
|
|
58
59
|
"publishConfig": {
|
|
59
60
|
"access": "public"
|
|
60
61
|
},
|
|
61
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "c6310f72bc0c02649d5b7fe7cdb059e1c36e8200"
|
|
62
63
|
}
|
package/presets/base.js
CHANGED
|
@@ -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.js')
|
|
7
7
|
|
|
8
8
|
/** @type {import('eslint').Linter.BaseConfig} */
|
|
9
9
|
const cjsConfig = {
|
|
@@ -33,19 +33,6 @@ const esmConfig = {
|
|
|
33
33
|
},
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
/** @type {import('eslint').Linter.BaseConfig} */
|
|
37
|
-
const esmConfigForJs = {
|
|
38
|
-
...esmConfig,
|
|
39
|
-
rules: {
|
|
40
|
-
...esmConfig.rules,
|
|
41
|
-
'import/extensions': [
|
|
42
|
-
'error',
|
|
43
|
-
// https://nodejs.org/docs/latest-v14.x/api/esm.html#esm_mandatory_file_extensions
|
|
44
|
-
'always',
|
|
45
|
-
],
|
|
46
|
-
},
|
|
47
|
-
}
|
|
48
|
-
|
|
49
36
|
/** @type {import('eslint').Linter.Config} */
|
|
50
37
|
module.exports = {
|
|
51
38
|
extends: [
|
|
@@ -84,6 +71,21 @@ module.exports = {
|
|
|
84
71
|
'func-names': ['error', 'as-needed'],
|
|
85
72
|
// this rule doesn't support commonjs, some dependencies are using commonjs
|
|
86
73
|
'import/default': 'off',
|
|
74
|
+
// enforce extensions for both cjs and esm
|
|
75
|
+
'import/extensions': [
|
|
76
|
+
'error',
|
|
77
|
+
// https://nodejs.org/docs/latest-v14.x/api/esm.html#esm_mandatory_file_extensions
|
|
78
|
+
'always',
|
|
79
|
+
{
|
|
80
|
+
pattern: {
|
|
81
|
+
// ignore cts/mts/ts/tsx because typescript uses cjs/mjs/js instead
|
|
82
|
+
cts: 'never',
|
|
83
|
+
mts: 'never',
|
|
84
|
+
ts: 'never',
|
|
85
|
+
tsx: 'never',
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
],
|
|
87
89
|
// make sure import statements above the others
|
|
88
90
|
'import/first': 'error',
|
|
89
91
|
// separate import statements from the others
|
|
@@ -143,7 +145,7 @@ module.exports = {
|
|
|
143
145
|
overrides: [
|
|
144
146
|
{
|
|
145
147
|
files: ['*.js'],
|
|
146
|
-
...(isESM() ?
|
|
148
|
+
...(isESM() ? esmConfig : cjsConfig),
|
|
147
149
|
},
|
|
148
150
|
{
|
|
149
151
|
files: ['*.cjs'],
|
|
@@ -151,7 +153,7 @@ module.exports = {
|
|
|
151
153
|
},
|
|
152
154
|
{
|
|
153
155
|
files: ['*.mjs'],
|
|
154
|
-
...
|
|
156
|
+
...esmConfig,
|
|
155
157
|
},
|
|
156
158
|
{
|
|
157
159
|
files: testFileGlobs,
|
|
@@ -186,15 +188,16 @@ module.exports = {
|
|
|
186
188
|
// allowAutomaticSingleRunInference: true,
|
|
187
189
|
project: ['./tsconfig*.json', './packages/*/tsconfig*.json'],
|
|
188
190
|
},
|
|
191
|
+
settings: {
|
|
192
|
+
'import/resolver': {
|
|
193
|
+
typescript: true,
|
|
194
|
+
},
|
|
195
|
+
},
|
|
189
196
|
plugins: [
|
|
190
197
|
'@typescript-eslint/eslint-plugin',
|
|
191
198
|
'eslint-plugin-deprecation',
|
|
192
199
|
'eslint-plugin-functional',
|
|
193
200
|
],
|
|
194
|
-
env: {
|
|
195
|
-
// allow commonjs globals as we haven't moved to es modules
|
|
196
|
-
commonjs: true,
|
|
197
|
-
},
|
|
198
201
|
rules: {
|
|
199
202
|
// extend existing rule
|
|
200
203
|
'@typescript-eslint/ban-types': [
|
package/presets/node.js
CHANGED
|
@@ -1,13 +1,20 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
+
// @ts-expect-error
|
|
4
|
+
const { isESM } = require('@foray1010/common-presets-utils')
|
|
5
|
+
|
|
6
|
+
/** @type {import('eslint').Linter.BaseConfig} */
|
|
7
|
+
const cjsConfig = {
|
|
8
|
+
globals: {
|
|
9
|
+
__dirname: 'readonly',
|
|
10
|
+
__filename: 'readonly',
|
|
11
|
+
},
|
|
12
|
+
}
|
|
13
|
+
|
|
3
14
|
/** @type {import('eslint').Linter.Config} */
|
|
4
15
|
module.exports = {
|
|
5
16
|
plugins: ['eslint-plugin-n'],
|
|
6
17
|
globals: {
|
|
7
|
-
// used in commonjs and typescript
|
|
8
|
-
__dirname: 'readonly',
|
|
9
|
-
// used in commonjs and typescript
|
|
10
|
-
__filename: 'readonly',
|
|
11
18
|
// hack to mute no-undef error, and show n/prefer-global/buffer error instead
|
|
12
19
|
Buffer: 'readonly',
|
|
13
20
|
// hack to mute no-undef error, and show n/prefer-global/process error instead
|
|
@@ -41,4 +48,14 @@ module.exports = {
|
|
|
41
48
|
// enforce shebang on the entry bin file
|
|
42
49
|
'n/shebang': 'error',
|
|
43
50
|
},
|
|
51
|
+
overrides: [
|
|
52
|
+
{
|
|
53
|
+
files: ['*.js'],
|
|
54
|
+
...(isESM() ? {} : cjsConfig),
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
files: ['*.cjs', '*.cts'],
|
|
58
|
+
...cjsConfig,
|
|
59
|
+
},
|
|
60
|
+
],
|
|
44
61
|
}
|