@bfra.me/eslint-config 0.2.0 → 0.3.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/lib/index.d.ts +4399 -1239
- package/lib/index.js +95 -54
- package/package.json +8 -8
- package/src/configs/epilogue.ts +26 -1
- package/src/define-config.ts +18 -10
- package/src/types.ts +3215 -223
package/lib/index.js
CHANGED
|
@@ -17,9 +17,76 @@ async function command() {
|
|
|
17
17
|
}
|
|
18
18
|
__name(command, "command");
|
|
19
19
|
|
|
20
|
+
// src/globs.ts
|
|
21
|
+
var GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
|
|
22
|
+
var GLOB_SRC = "**/*.?([cm])[jt]s?(x)";
|
|
23
|
+
var GLOB_TS = "**/*.?([cm])ts";
|
|
24
|
+
var GLOB_TSX = "**/*.tsx";
|
|
25
|
+
var GLOB_EXCLUDE = [
|
|
26
|
+
"**/node_modules",
|
|
27
|
+
"**/dist",
|
|
28
|
+
"**/coverage",
|
|
29
|
+
"**/out",
|
|
30
|
+
"**/temp",
|
|
31
|
+
"**/.idea",
|
|
32
|
+
"**/.next",
|
|
33
|
+
"**/.nuxt",
|
|
34
|
+
"**/.output",
|
|
35
|
+
"**/.svelte-kit",
|
|
36
|
+
"**/.tsup",
|
|
37
|
+
"**/.vercel",
|
|
38
|
+
"**/.vitepress/cache",
|
|
39
|
+
"**/.vite-inspect",
|
|
40
|
+
"**/.yarn",
|
|
41
|
+
"**/__snapshots__",
|
|
42
|
+
"**/test/fixtures",
|
|
43
|
+
"**/auto-import?(s).d.ts",
|
|
44
|
+
"**/.changeset/*.md",
|
|
45
|
+
"**/CHANGELOG*.md",
|
|
46
|
+
"**/changelog*.md",
|
|
47
|
+
"**/components.d.ts",
|
|
48
|
+
"**/devcontainer-lock.json",
|
|
49
|
+
"**/LICENSE*",
|
|
50
|
+
"**/license*",
|
|
51
|
+
"**/*.min.*",
|
|
52
|
+
"**/package-lock.json",
|
|
53
|
+
"**/pnpm-lock.yaml",
|
|
54
|
+
"**/typed-router.d.ts",
|
|
55
|
+
"**/yarn.lock",
|
|
56
|
+
"**/bun.lockb"
|
|
57
|
+
];
|
|
58
|
+
var GLOB_TESTS = [
|
|
59
|
+
`**/__tests__/**/*.${GLOB_SRC_EXT}`,
|
|
60
|
+
`**/*.spec.${GLOB_SRC_EXT}`,
|
|
61
|
+
`**/*.test.${GLOB_SRC_EXT}`,
|
|
62
|
+
`**/*.bench.${GLOB_SRC_EXT}`,
|
|
63
|
+
`**/*.benchmark.${GLOB_SRC_EXT}`
|
|
64
|
+
];
|
|
65
|
+
|
|
20
66
|
// src/configs/epilogue.ts
|
|
21
67
|
async function epilogue() {
|
|
22
68
|
return [
|
|
69
|
+
{
|
|
70
|
+
name: "@bfra.me/epilogue/commonjs",
|
|
71
|
+
files: [
|
|
72
|
+
"**/*.js",
|
|
73
|
+
"**/*.cjs"
|
|
74
|
+
],
|
|
75
|
+
rules: {
|
|
76
|
+
"@typescript-eslint/no-require-imports": "off"
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
name: "@bfra.me/epilogue/configs",
|
|
81
|
+
files: [
|
|
82
|
+
`**/*.config.${GLOB_SRC_EXT}`,
|
|
83
|
+
`**/*.config.*.${GLOB_SRC_EXT}`
|
|
84
|
+
],
|
|
85
|
+
rules: {
|
|
86
|
+
"@typescript-eslint/explicit-function-return-type": "off",
|
|
87
|
+
"no-console": "off"
|
|
88
|
+
}
|
|
89
|
+
},
|
|
23
90
|
{
|
|
24
91
|
name: "@bfra.me/epilogue/dts",
|
|
25
92
|
files: [
|
|
@@ -27,10 +94,20 @@ async function epilogue() {
|
|
|
27
94
|
],
|
|
28
95
|
rules: {
|
|
29
96
|
"eslint-comments/no-unlimited-disable": "off",
|
|
30
|
-
"import/no-duplicates": "off",
|
|
97
|
+
"import-x/no-duplicates": "off",
|
|
31
98
|
"no-restricted-syntax": "off",
|
|
32
99
|
"unused-imports/no-unused-vars": "off"
|
|
33
100
|
}
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
name: "@bfra.me/epilogue/scripts",
|
|
104
|
+
files: [
|
|
105
|
+
`**/scripts/${GLOB_SRC}`
|
|
106
|
+
],
|
|
107
|
+
rules: {
|
|
108
|
+
"@typescript-eslint/explicit-function-return-type": "off",
|
|
109
|
+
"no-console": "off"
|
|
110
|
+
}
|
|
34
111
|
}
|
|
35
112
|
];
|
|
36
113
|
}
|
|
@@ -75,52 +152,6 @@ async function eslintComments() {
|
|
|
75
152
|
}
|
|
76
153
|
__name(eslintComments, "eslintComments");
|
|
77
154
|
|
|
78
|
-
// src/globs.ts
|
|
79
|
-
var GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
|
|
80
|
-
var GLOB_SRC = "**/*.?([cm])[jt]s?(x)";
|
|
81
|
-
var GLOB_TS = "**/*.?([cm])ts";
|
|
82
|
-
var GLOB_TSX = "**/*.tsx";
|
|
83
|
-
var GLOB_EXCLUDE = [
|
|
84
|
-
"**/node_modules",
|
|
85
|
-
"**/dist",
|
|
86
|
-
"**/coverage",
|
|
87
|
-
"**/out",
|
|
88
|
-
"**/temp",
|
|
89
|
-
"**/.idea",
|
|
90
|
-
"**/.next",
|
|
91
|
-
"**/.nuxt",
|
|
92
|
-
"**/.output",
|
|
93
|
-
"**/.svelte-kit",
|
|
94
|
-
"**/.tsup",
|
|
95
|
-
"**/.vercel",
|
|
96
|
-
"**/.vitepress/cache",
|
|
97
|
-
"**/.vite-inspect",
|
|
98
|
-
"**/.yarn",
|
|
99
|
-
"**/__snapshots__",
|
|
100
|
-
"**/test/fixtures",
|
|
101
|
-
"**/auto-import?(s).d.ts",
|
|
102
|
-
"**/.changeset/*.md",
|
|
103
|
-
"**/CHANGELOG*.md",
|
|
104
|
-
"**/changelog*.md",
|
|
105
|
-
"**/components.d.ts",
|
|
106
|
-
"**/devcontainer-lock.json",
|
|
107
|
-
"**/LICENSE*",
|
|
108
|
-
"**/license*",
|
|
109
|
-
"**/*.min.*",
|
|
110
|
-
"**/package-lock.json",
|
|
111
|
-
"**/pnpm-lock.yaml",
|
|
112
|
-
"**/typed-router.d.ts",
|
|
113
|
-
"**/yarn.lock",
|
|
114
|
-
"**/bun.lockb"
|
|
115
|
-
];
|
|
116
|
-
var GLOB_TESTS = [
|
|
117
|
-
`**/__tests__/**/*.${GLOB_SRC_EXT}`,
|
|
118
|
-
`**/*.spec.${GLOB_SRC_EXT}`,
|
|
119
|
-
`**/*.test.${GLOB_SRC_EXT}`,
|
|
120
|
-
`**/*.bench.${GLOB_SRC_EXT}`,
|
|
121
|
-
`**/*.benchmark.${GLOB_SRC_EXT}`
|
|
122
|
-
];
|
|
123
|
-
|
|
124
155
|
// src/configs/ignores.ts
|
|
125
156
|
async function ignores(ignores1 = []) {
|
|
126
157
|
return [
|
|
@@ -449,7 +480,17 @@ var isInGitLifecycle = !!(env.GIT_PARAMS || env.VSCODE_GIT_COMMAND || env.npm_li
|
|
|
449
480
|
var isInEditor = !isInCI && !isInGitLifecycle && !!(env.VSCODE_PID || env.VSCODE_CWD || env.JETBRAINS_IDE || env.VIM || env.NVIM);
|
|
450
481
|
|
|
451
482
|
// src/define-config.ts
|
|
452
|
-
var AllowedConfigPropertiesForOptions =
|
|
483
|
+
var AllowedConfigPropertiesForOptions = [
|
|
484
|
+
"name",
|
|
485
|
+
"ignores",
|
|
486
|
+
"language",
|
|
487
|
+
"languageOptions",
|
|
488
|
+
"linterOptions",
|
|
489
|
+
"plugins",
|
|
490
|
+
"processor",
|
|
491
|
+
"rules",
|
|
492
|
+
"settings"
|
|
493
|
+
];
|
|
453
494
|
async function defineConfig(options = {}, ...userConfigs) {
|
|
454
495
|
const { gitignore: enableGitignore = true, typescript: enableTypeScript = isPackageExists("typescript") } = options;
|
|
455
496
|
const isInEditor2 = options.isInEditor ?? isInEditor;
|
|
@@ -483,12 +524,12 @@ async function defineConfig(options = {}, ...userConfigs) {
|
|
|
483
524
|
}));
|
|
484
525
|
}
|
|
485
526
|
configs.push(epilogue());
|
|
486
|
-
const optionsConfig = AllowedConfigPropertiesForOptions.reduce((config2, key) => {
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
}, {});
|
|
527
|
+
const optionsConfig = AllowedConfigPropertiesForOptions.reduce((config2, key) => ({
|
|
528
|
+
...config2,
|
|
529
|
+
...key in options ? {
|
|
530
|
+
[key]: options[key]
|
|
531
|
+
} : {}
|
|
532
|
+
}), {});
|
|
492
533
|
if (Object.keys(optionsConfig).length) {
|
|
493
534
|
configs.push([
|
|
494
535
|
optionsConfig
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bfra.me/eslint-config",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Shared ESLint configuration for bfra.me",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"bfra.me",
|
|
@@ -53,26 +53,25 @@
|
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
55
|
"@eslint/config-inspector": "0.5.4",
|
|
56
|
-
"@eslint/js": "9.
|
|
56
|
+
"@eslint/js": "9.12.0",
|
|
57
57
|
"@types/eslint__js": "8.42.3",
|
|
58
58
|
"@types/fs-extra": "11.0.4",
|
|
59
59
|
"@types/node": "20.16.1",
|
|
60
60
|
"@vitest/eslint-plugin": "1.1.4",
|
|
61
|
-
"eslint": "9.
|
|
61
|
+
"eslint": "9.12.0",
|
|
62
62
|
"eslint-plugin-no-only-tests": "3.3.0",
|
|
63
63
|
"eslint-typegen": "0.3.2",
|
|
64
64
|
"execa": "9.4.0",
|
|
65
65
|
"fast-glob": "3.3.2",
|
|
66
66
|
"fs-extra": "11.2.0",
|
|
67
|
-
"jiti": "1.
|
|
67
|
+
"jiti": "2.1.2",
|
|
68
68
|
"prettier": "3.3.3",
|
|
69
69
|
"tsup": "8.3.0",
|
|
70
70
|
"tsx": "4.19.1",
|
|
71
|
-
"type-fest": "4.26.0",
|
|
72
71
|
"vitest": "2.1.0",
|
|
73
|
-
"@bfra.me/
|
|
72
|
+
"@bfra.me/prettier-config": "0.7.4",
|
|
74
73
|
"@bfra.me/tsconfig": "0.8.1",
|
|
75
|
-
"@bfra.me/
|
|
74
|
+
"@bfra.me/eslint-config": "0.3.0"
|
|
76
75
|
},
|
|
77
76
|
"peerDependencies": {
|
|
78
77
|
"@vitest/eslint-plugin": "^1.1.4",
|
|
@@ -93,7 +92,8 @@
|
|
|
93
92
|
},
|
|
94
93
|
"scripts": {
|
|
95
94
|
"build": "pnpm run generate-types && tsup",
|
|
96
|
-
"
|
|
95
|
+
"build-inspector": "eslint-config-inspector build --config ./inspector/eslint.config.ts",
|
|
96
|
+
"dev": "eslint-config-inspector --config ./inspector/eslint.config.ts --open false",
|
|
97
97
|
"generate-types": "tsx ./scripts/generate-types.ts",
|
|
98
98
|
"test": "vitest"
|
|
99
99
|
}
|
package/src/configs/epilogue.ts
CHANGED
|
@@ -1,16 +1,41 @@
|
|
|
1
|
+
import {GLOB_SRC, GLOB_SRC_EXT} from '../globs'
|
|
1
2
|
import type {Config} from '../types'
|
|
2
3
|
|
|
3
4
|
export async function epilogue(): Promise<Config[]> {
|
|
5
|
+
// @keep-sorted {"keys":["name"]}
|
|
4
6
|
return [
|
|
7
|
+
{
|
|
8
|
+
name: '@bfra.me/epilogue/commonjs',
|
|
9
|
+
files: ['**/*.js', '**/*.cjs'],
|
|
10
|
+
rules: {
|
|
11
|
+
'@typescript-eslint/no-require-imports': 'off',
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
name: '@bfra.me/epilogue/configs',
|
|
16
|
+
files: [`**/*.config.${GLOB_SRC_EXT}`, `**/*.config.*.${GLOB_SRC_EXT}`],
|
|
17
|
+
rules: {
|
|
18
|
+
'@typescript-eslint/explicit-function-return-type': 'off',
|
|
19
|
+
'no-console': 'off',
|
|
20
|
+
},
|
|
21
|
+
},
|
|
5
22
|
{
|
|
6
23
|
name: '@bfra.me/epilogue/dts',
|
|
7
24
|
files: ['**/*.d.?([cm])ts'],
|
|
8
25
|
rules: {
|
|
9
26
|
'eslint-comments/no-unlimited-disable': 'off',
|
|
10
|
-
'import/no-duplicates': 'off',
|
|
27
|
+
'import-x/no-duplicates': 'off',
|
|
11
28
|
'no-restricted-syntax': 'off',
|
|
12
29
|
'unused-imports/no-unused-vars': 'off',
|
|
13
30
|
},
|
|
14
31
|
},
|
|
32
|
+
{
|
|
33
|
+
name: '@bfra.me/epilogue/scripts',
|
|
34
|
+
files: [`**/scripts/${GLOB_SRC}`],
|
|
35
|
+
rules: {
|
|
36
|
+
'@typescript-eslint/explicit-function-return-type': 'off',
|
|
37
|
+
'no-console': 'off',
|
|
38
|
+
},
|
|
39
|
+
},
|
|
15
40
|
]
|
|
16
41
|
}
|
package/src/define-config.ts
CHANGED
|
@@ -3,7 +3,6 @@ import type {Linter} from 'eslint'
|
|
|
3
3
|
import type {FlatGitignoreOptions} from 'eslint-config-flat-gitignore'
|
|
4
4
|
import {isPackageExists} from 'local-pkg'
|
|
5
5
|
import type {ParserOptions} from '@typescript-eslint/types'
|
|
6
|
-
import type {UnionToTuple} from 'type-fest'
|
|
7
6
|
import {
|
|
8
7
|
command,
|
|
9
8
|
epilogue,
|
|
@@ -23,9 +22,17 @@ import {interopDefault} from './plugins'
|
|
|
23
22
|
// These are merged into the Options interface
|
|
24
23
|
type AllowedConfigForOptions = Omit<Config, 'files'>
|
|
25
24
|
|
|
26
|
-
const AllowedConfigPropertiesForOptions =
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
const AllowedConfigPropertiesForOptions = [
|
|
26
|
+
'name',
|
|
27
|
+
'ignores',
|
|
28
|
+
'language',
|
|
29
|
+
'languageOptions',
|
|
30
|
+
'linterOptions',
|
|
31
|
+
'plugins',
|
|
32
|
+
'processor',
|
|
33
|
+
'rules',
|
|
34
|
+
'settings',
|
|
35
|
+
] satisfies (keyof AllowedConfigForOptions)[]
|
|
29
36
|
|
|
30
37
|
export interface OptionsFiles {
|
|
31
38
|
/**
|
|
@@ -193,12 +200,13 @@ export async function defineConfig(
|
|
|
193
200
|
// Epilogue config is always added last
|
|
194
201
|
configs.push(epilogue())
|
|
195
202
|
|
|
196
|
-
const optionsConfig = AllowedConfigPropertiesForOptions.reduce(
|
|
197
|
-
|
|
198
|
-
config
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
203
|
+
const optionsConfig = AllowedConfigPropertiesForOptions.reduce(
|
|
204
|
+
(config, key) => ({
|
|
205
|
+
...config,
|
|
206
|
+
...(key in options ? {[key]: options[key]} : {}),
|
|
207
|
+
}),
|
|
208
|
+
{} as Config,
|
|
209
|
+
)
|
|
202
210
|
|
|
203
211
|
if (Object.keys(optionsConfig).length) {
|
|
204
212
|
configs.push([optionsConfig])
|