@foray1010/eslint-config 10.0.0 → 10.0.1
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 +7 -0
- package/README.md +5 -21
- package/bases/base.mjs +6 -3
- package/constants.mjs +10 -3
- package/index.mjs +0 -1
- package/package.json +2 -2
- package/utils/applyConfig.mjs +15 -14
- package/bases/files.mjs +0 -8
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,13 @@
|
|
|
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.0.1](https://github.com/foray1010/common-presets/compare/@foray1010/eslint-config@10.0.0...@foray1010/eslint-config@10.0.1) (2023-03-23)
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
- **eslint-config:** fix wrong assumption, `files` only does not filter ([661d0c6](https://github.com/foray1010/common-presets/commit/661d0c6bd05f688c8f6956fb26844e597c851dc4))
|
|
11
|
+
- **eslint-config:** should not use ignores in config, and allow user defined ignores ([05b0ca0](https://github.com/foray1010/common-presets/commit/05b0ca09a76ed677c903b654cef3eeef7773610e))
|
|
12
|
+
|
|
6
13
|
## [10.0.0](https://github.com/foray1010/common-presets/compare/@foray1010/eslint-config@9.2.0...@foray1010/eslint-config@10.0.0) (2023-03-23)
|
|
7
14
|
|
|
8
15
|
### ⚠ BREAKING CHANGES
|
package/README.md
CHANGED
|
@@ -26,16 +26,11 @@ Z for looser rules
|
|
|
26
26
|
|
|
27
27
|
```js
|
|
28
28
|
import {
|
|
29
|
-
eslintFilesConfig,
|
|
30
29
|
eslintIgnoresConfig,
|
|
31
30
|
eslintNodeConfig,
|
|
32
31
|
} from '@foray1010/eslint-config'
|
|
33
32
|
|
|
34
|
-
const config = [
|
|
35
|
-
...eslintIgnoresConfig,
|
|
36
|
-
...eslintFilesConfig,
|
|
37
|
-
...eslintNodeConfig,
|
|
38
|
-
]
|
|
33
|
+
const config = [...eslintIgnoresConfig, ...eslintNodeConfig]
|
|
39
34
|
export default config
|
|
40
35
|
```
|
|
41
36
|
|
|
@@ -43,16 +38,11 @@ Z for looser rules
|
|
|
43
38
|
|
|
44
39
|
```js
|
|
45
40
|
import {
|
|
46
|
-
eslintFilesConfig,
|
|
47
41
|
eslintIgnoresConfig,
|
|
48
42
|
eslintBrowserConfig,
|
|
49
43
|
} from '@foray1010/eslint-config'
|
|
50
44
|
|
|
51
|
-
const config = [
|
|
52
|
-
...eslintIgnoresConfig,
|
|
53
|
-
...eslintFilesConfig,
|
|
54
|
-
...eslintBrowserConfig,
|
|
55
|
-
]
|
|
45
|
+
const config = [...eslintIgnoresConfig, ...eslintBrowserConfig]
|
|
56
46
|
export default config
|
|
57
47
|
```
|
|
58
48
|
|
|
@@ -60,16 +50,11 @@ Z for looser rules
|
|
|
60
50
|
|
|
61
51
|
```js
|
|
62
52
|
import {
|
|
63
|
-
eslintFilesConfig,
|
|
64
53
|
eslintIgnoresConfig,
|
|
65
54
|
eslintReactConfig,
|
|
66
55
|
} from '@foray1010/eslint-config'
|
|
67
56
|
|
|
68
|
-
const config = [
|
|
69
|
-
...eslintIgnoresConfig,
|
|
70
|
-
...eslintFilesConfig,
|
|
71
|
-
...eslintReactConfig,
|
|
72
|
-
]
|
|
57
|
+
const config = [...eslintIgnoresConfig, ...eslintReactConfig]
|
|
73
58
|
export default config
|
|
74
59
|
```
|
|
75
60
|
|
|
@@ -78,7 +63,6 @@ Z for looser rules
|
|
|
78
63
|
```js
|
|
79
64
|
import {
|
|
80
65
|
applyConfig,
|
|
81
|
-
eslintFilesConfig,
|
|
82
66
|
eslintIgnoresConfig,
|
|
83
67
|
eslintNodeConfig,
|
|
84
68
|
eslintReactConfig,
|
|
@@ -86,10 +70,10 @@ Z for looser rules
|
|
|
86
70
|
|
|
87
71
|
const config = [
|
|
88
72
|
...eslintIgnoresConfig,
|
|
89
|
-
...eslintFilesConfig,
|
|
90
73
|
...applyConfig(
|
|
91
74
|
{
|
|
92
|
-
|
|
75
|
+
filePrefixes: '.',
|
|
76
|
+
ignores: ['src/**'],
|
|
93
77
|
},
|
|
94
78
|
eslintNodeConfig,
|
|
95
79
|
),
|
package/bases/base.mjs
CHANGED
|
@@ -12,7 +12,11 @@ import eslintPluginSimpleImportSort from 'eslint-plugin-simple-import-sort'
|
|
|
12
12
|
import eslintPluginUnicorn from 'eslint-plugin-unicorn'
|
|
13
13
|
import globals from 'globals'
|
|
14
14
|
|
|
15
|
-
import {
|
|
15
|
+
import {
|
|
16
|
+
testFileGlobs,
|
|
17
|
+
typeScriptFileGlobs,
|
|
18
|
+
typeScriptTestFileGlobs,
|
|
19
|
+
} from '../constants.mjs'
|
|
16
20
|
|
|
17
21
|
/** @type {import('eslint').Linter.FlatConfig} */
|
|
18
22
|
const cjsConfig = {
|
|
@@ -354,8 +358,7 @@ const baseConfig = [
|
|
|
354
358
|
},
|
|
355
359
|
},
|
|
356
360
|
{
|
|
357
|
-
files:
|
|
358
|
-
ignores: testFileGlobs.map((glob) => `!${glob}`),
|
|
361
|
+
files: typeScriptTestFileGlobs,
|
|
359
362
|
plugins: {
|
|
360
363
|
'@typescript-eslint': eslintPluginTypescriptEslint,
|
|
361
364
|
jest: eslintPluginJest,
|
package/constants.mjs
CHANGED
|
@@ -1,8 +1,15 @@
|
|
|
1
|
+
export const supportedFilesGlob = '**/*.{cjs,cts,js,mjs,mts,ts,tsx}'
|
|
1
2
|
export const testFileGlobs = [
|
|
2
|
-
'**/__fixtures__
|
|
3
|
-
'**/__mocks__
|
|
4
|
-
'**/__tests__
|
|
3
|
+
'**/__fixtures__/**/*.{cjs,cts,js,mjs,mts,ts,tsx}',
|
|
4
|
+
'**/__mocks__/**/*.{cjs,cts,js,mjs,mts,ts,tsx}',
|
|
5
|
+
'**/__tests__/**/*.{cjs,cts,js,mjs,mts,ts,tsx}',
|
|
5
6
|
'**/*.{spec,test}.{cjs,cts,js,mjs,mts,ts,tsx}',
|
|
6
7
|
]
|
|
7
8
|
|
|
8
9
|
export const typeScriptFileGlobs = ['**/*.{cts,mts,ts,tsx}']
|
|
10
|
+
export const typeScriptTestFileGlobs = [
|
|
11
|
+
'**/__fixtures__/**/*.{cts,mts,ts,tsx}',
|
|
12
|
+
'**/__mocks__/**/*.{cts,mts,ts,tsx}',
|
|
13
|
+
'**/__tests__/**/*.{cts,mts,ts,tsx}',
|
|
14
|
+
'**/*.{spec,test}.{cts,mts,ts,tsx}',
|
|
15
|
+
]
|
package/index.mjs
CHANGED
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.0.
|
|
4
|
+
"version": "10.0.1",
|
|
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": {
|
|
@@ -58,5 +58,5 @@
|
|
|
58
58
|
"publishConfig": {
|
|
59
59
|
"access": "public"
|
|
60
60
|
},
|
|
61
|
-
"gitHead": "
|
|
61
|
+
"gitHead": "c722884bc466360097d9ab80e72f350a15ed7cad"
|
|
62
62
|
}
|
package/utils/applyConfig.mjs
CHANGED
|
@@ -1,15 +1,22 @@
|
|
|
1
1
|
import path from 'node:path'
|
|
2
2
|
|
|
3
|
+
import { supportedFilesGlob } from '../constants.mjs'
|
|
4
|
+
|
|
3
5
|
/**
|
|
4
6
|
* Extend the flat configs with default files and ignores
|
|
5
7
|
* @param {{
|
|
6
|
-
* readonly filePrefixes
|
|
7
|
-
* readonly
|
|
8
|
+
* readonly filePrefixes: string | string[],
|
|
9
|
+
* readonly ignores?: string | string[] | undefined
|
|
8
10
|
* }} options
|
|
9
11
|
* @param {readonly import('eslint').Linter.FlatConfig[]} flatConfigs
|
|
10
12
|
* @returns {readonly import('eslint').Linter.FlatConfig[]}
|
|
11
13
|
*/
|
|
12
14
|
export function applyConfig(options, flatConfigs) {
|
|
15
|
+
const filePrefixes = [options.filePrefixes].flat()
|
|
16
|
+
if (filePrefixes.length === 0) {
|
|
17
|
+
throw new TypeError('filePrefixes must not be empty')
|
|
18
|
+
}
|
|
19
|
+
|
|
13
20
|
// Do not allow string such as "eslint:recommended" because it cannot be overridden by files/ignores
|
|
14
21
|
for (const config of flatConfigs) {
|
|
15
22
|
if (typeof config === 'string') {
|
|
@@ -18,35 +25,29 @@ export function applyConfig(options, flatConfigs) {
|
|
|
18
25
|
)
|
|
19
26
|
}
|
|
20
27
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
keys.length === 1 &&
|
|
24
|
-
(keys.includes('files') || keys.includes('ignores'))
|
|
25
|
-
) {
|
|
26
|
-
throw new TypeError('Do not use `files` or `ignores` only')
|
|
28
|
+
if (Object.keys(config).includes('ignores')) {
|
|
29
|
+
throw new TypeError('Do not use `ignores` in config')
|
|
27
30
|
}
|
|
28
31
|
}
|
|
29
32
|
|
|
30
33
|
return flatConfigs.map((config) => {
|
|
31
|
-
const files = generateCombinations(
|
|
32
|
-
const ignores = generateCombinations(options.ignorePrefixes, config.ignores)
|
|
34
|
+
const files = generateCombinations(filePrefixes, config.files)
|
|
33
35
|
return {
|
|
34
36
|
...config,
|
|
35
37
|
...(files ? { files } : {}),
|
|
36
|
-
...(ignores ? { ignores } : {}),
|
|
38
|
+
...(options.ignores ? { ignores: options.ignores } : {}),
|
|
37
39
|
}
|
|
38
40
|
})
|
|
39
41
|
}
|
|
40
42
|
|
|
41
43
|
/**
|
|
42
|
-
* @param {string[]
|
|
44
|
+
* @param {string[]} prefixes
|
|
43
45
|
* @param {string | string[] | undefined} originalGlobs
|
|
44
46
|
* @returns {string | string[] | undefined}
|
|
45
47
|
*/
|
|
46
48
|
function generateCombinations(prefixes, originalGlobs) {
|
|
47
|
-
if (!prefixes || prefixes.length === 0) return originalGlobs
|
|
48
49
|
if (!originalGlobs || originalGlobs.length === 0) {
|
|
49
|
-
return prefixes.map((prefix) => path.join(prefix,
|
|
50
|
+
return prefixes.map((prefix) => path.join(prefix, supportedFilesGlob))
|
|
50
51
|
}
|
|
51
52
|
|
|
52
53
|
const originalGlobList = [originalGlobs].flat()
|
package/bases/files.mjs
DELETED