@bfra.me/eslint-config 0.25.2 → 0.26.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 +48 -50
- package/lib/index.js +156 -66
- package/lib/{missing-module-for-config-TJVZJJU6.js → missing-module-for-config-YSY2AGPQ.js} +10 -10
- package/package.json +8 -13
- package/src/configs/command.ts +1 -1
- package/src/configs/eslint-comments.ts +15 -27
- package/src/configs/fallback.ts +2 -2
- package/src/configs/imports.ts +2 -2
- package/src/configs/javascript.ts +2 -2
- package/src/configs/jsdoc.ts +1 -1
- package/src/configs/json-schema.ts +2 -2
- package/src/configs/jsonc.ts +2 -2
- package/src/configs/markdown.ts +1 -1
- package/src/configs/node.ts +1 -1
- package/src/configs/package-json.ts +2 -2
- package/src/configs/perfectionist.ts +2 -2
- package/src/configs/pnpm.ts +1 -1
- package/src/configs/prettier.ts +1 -1
- package/src/configs/regexp.ts +1 -1
- package/src/configs/toml.ts +2 -2
- package/src/configs/typescript.ts +108 -6
- package/src/configs/unicorn.ts +1 -1
- package/src/configs/vitest.ts +17 -23
- package/src/configs/yaml.ts +2 -2
- package/src/define-config.ts +1 -1
- package/src/env.ts +9 -3
- package/src/index.ts +1 -0
- package/src/options.ts +3 -2
- package/src/package-utils.ts +7 -7
- package/src/plugins.d.ts +29 -0
- package/src/require-of.ts +1 -1
- package/src/rules/missing-module-for-config.ts +4 -3
- package/src/rules.d.ts +12 -14
- package/src/{plugins.ts → utils.ts} +1 -1
package/lib/index.d.ts
CHANGED
|
@@ -4781,11 +4781,6 @@ interface Rules {
|
|
|
4781
4781
|
* @see https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/no-mocks-import.md
|
|
4782
4782
|
*/
|
|
4783
4783
|
'vitest/no-mocks-import'?: Linter.RuleEntry<[]>
|
|
4784
|
-
/**
|
|
4785
|
-
* disallow .only blocks in tests
|
|
4786
|
-
* @see https://github.com/levibuzolic/eslint-plugin-no-only-tests
|
|
4787
|
-
*/
|
|
4788
|
-
'vitest/no-only-tests'?: Linter.RuleEntry<VitestNoOnlyTests>
|
|
4789
4784
|
/**
|
|
4790
4785
|
* disallow the use of certain matchers
|
|
4791
4786
|
* @see https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/no-restricted-matchers.md
|
|
@@ -8453,10 +8448,18 @@ type NoRestrictedExports = []|[({
|
|
|
8453
8448
|
}
|
|
8454
8449
|
})]
|
|
8455
8450
|
// ----- no-restricted-globals -----
|
|
8456
|
-
type NoRestrictedGlobals = (string | {
|
|
8451
|
+
type NoRestrictedGlobals = ((string | {
|
|
8457
8452
|
name: string
|
|
8458
8453
|
message?: string
|
|
8459
|
-
})[]
|
|
8454
|
+
})[] | []|[{
|
|
8455
|
+
|
|
8456
|
+
globals: (string | {
|
|
8457
|
+
name: string
|
|
8458
|
+
message?: string
|
|
8459
|
+
})[]
|
|
8460
|
+
checkGlobalObject?: boolean
|
|
8461
|
+
globalObjects?: string[]
|
|
8462
|
+
}])
|
|
8460
8463
|
// ----- no-restricted-imports -----
|
|
8461
8464
|
type NoRestrictedImports = ((string | {
|
|
8462
8465
|
name: string
|
|
@@ -9029,6 +9032,8 @@ type OneVar = []|[(("always" | "never" | "consecutive") | {
|
|
|
9029
9032
|
var?: ("always" | "never" | "consecutive")
|
|
9030
9033
|
let?: ("always" | "never" | "consecutive")
|
|
9031
9034
|
const?: ("always" | "never" | "consecutive")
|
|
9035
|
+
using?: ("always" | "never" | "consecutive")
|
|
9036
|
+
awaitUsing?: ("always" | "never" | "consecutive")
|
|
9032
9037
|
} | {
|
|
9033
9038
|
initialized?: ("always" | "never" | "consecutive")
|
|
9034
9039
|
uninitialized?: ("always" | "never" | "consecutive")
|
|
@@ -12680,13 +12685,6 @@ type VitestNoLargeSnapshots = []|[{
|
|
|
12680
12685
|
[k: string]: unknown[] | undefined
|
|
12681
12686
|
}
|
|
12682
12687
|
}]
|
|
12683
|
-
// ----- vitest/no-only-tests -----
|
|
12684
|
-
type VitestNoOnlyTests = []|[{
|
|
12685
|
-
block?: string[]
|
|
12686
|
-
focus?: string[]
|
|
12687
|
-
functions?: string[]
|
|
12688
|
-
fix?: boolean
|
|
12689
|
-
}]
|
|
12690
12688
|
// ----- vitest/no-restricted-matchers -----
|
|
12691
12689
|
type VitestNoRestrictedMatchers = []|[{
|
|
12692
12690
|
[k: string]: (string | null) | undefined
|
|
@@ -13048,31 +13046,6 @@ type ConfigNames =
|
|
|
13048
13046
|
| '@bfra.me/epilogue/dts'
|
|
13049
13047
|
| '@bfra.me/epilogue'
|
|
13050
13048
|
|
|
13051
|
-
/**
|
|
13052
|
-
* Composes an ESLint configuration object from the provided flat configurations.
|
|
13053
|
-
*
|
|
13054
|
-
* @param configs - The configuration names to compose.
|
|
13055
|
-
* @returns The composed ESLint configuration object.
|
|
13056
|
-
*/
|
|
13057
|
-
declare const composeConfig: <C extends Config = Config, CN extends ConfigNames = ConfigNames>(...configs: ResolvableFlatConfig<Config extends C ? C : Config>[]) => FlatConfigComposer<Config extends C ? C : Config, CN>;
|
|
13058
|
-
|
|
13059
|
-
declare function command(): Promise<Config[]>;
|
|
13060
|
-
|
|
13061
|
-
declare function epilogue(): Promise<Config[]>;
|
|
13062
|
-
|
|
13063
|
-
declare function eslintComments(): Promise<Config[]>;
|
|
13064
|
-
|
|
13065
|
-
type FallbackOptions = {
|
|
13066
|
-
files?: Config['files'];
|
|
13067
|
-
languageOptions?: Config['languageOptions'];
|
|
13068
|
-
name?: Config['name'];
|
|
13069
|
-
};
|
|
13070
|
-
declare function fallback(missingList: string[], options?: FallbackOptions): Promise<Config[]>;
|
|
13071
|
-
|
|
13072
|
-
declare function ignores(ignores?: string[]): Promise<Config[]>;
|
|
13073
|
-
|
|
13074
|
-
declare function imports(): Promise<Config[]>;
|
|
13075
|
-
|
|
13076
13049
|
/**
|
|
13077
13050
|
Flattens an object type to a mapped type with the same keys and values.
|
|
13078
13051
|
*/
|
|
@@ -13159,12 +13132,12 @@ interface OptionsTypeScriptParserOptions {
|
|
|
13159
13132
|
* Glob patterns for files that should be type aware.
|
|
13160
13133
|
* @default ['**\/*.{ts,tsx}']
|
|
13161
13134
|
*/
|
|
13162
|
-
files?:
|
|
13135
|
+
files?: string[];
|
|
13163
13136
|
/**
|
|
13164
13137
|
* Glob patterns for files that should not be type aware.
|
|
13165
13138
|
* @default ['**\/*.md\/**', '**\/*.astro/*.ts']
|
|
13166
13139
|
*/
|
|
13167
|
-
ignores?:
|
|
13140
|
+
ignores?: string[];
|
|
13168
13141
|
};
|
|
13169
13142
|
}
|
|
13170
13143
|
/**
|
|
@@ -13297,6 +13270,40 @@ type Options = Flatten<{
|
|
|
13297
13270
|
yaml?: boolean | OptionsOverrides;
|
|
13298
13271
|
} & Omit<Config, 'files'>>;
|
|
13299
13272
|
|
|
13273
|
+
/**
|
|
13274
|
+
* Define a new ESLint config.
|
|
13275
|
+
*
|
|
13276
|
+
* @param options - Options to configure the ESLint config.
|
|
13277
|
+
* @param userConfigs - Additional ESLint configs to include.
|
|
13278
|
+
* @returns A composable ESLint config.
|
|
13279
|
+
*/
|
|
13280
|
+
declare function defineConfig<C extends Config = Config, CN extends ConfigNames = ConfigNames>(options?: Options, ...userConfigs: ResolvableFlatConfig<Config extends C ? C : Config>[]): FlatConfigComposer<Config extends C ? C : Config, CN>;
|
|
13281
|
+
|
|
13282
|
+
/**
|
|
13283
|
+
* Composes an ESLint configuration object from the provided flat configurations.
|
|
13284
|
+
*
|
|
13285
|
+
* @param configs - The configuration names to compose.
|
|
13286
|
+
* @returns The composed ESLint configuration object.
|
|
13287
|
+
*/
|
|
13288
|
+
declare const composeConfig: <C extends Config = Config, CN extends ConfigNames = ConfigNames>(...configs: ResolvableFlatConfig<Config extends C ? C : Config>[]) => FlatConfigComposer<Config extends C ? C : Config, CN>;
|
|
13289
|
+
|
|
13290
|
+
declare function command(): Promise<Config[]>;
|
|
13291
|
+
|
|
13292
|
+
declare function epilogue(): Promise<Config[]>;
|
|
13293
|
+
|
|
13294
|
+
declare function eslintComments(): Config[];
|
|
13295
|
+
|
|
13296
|
+
interface FallbackOptions {
|
|
13297
|
+
files?: Config['files'];
|
|
13298
|
+
languageOptions?: Config['languageOptions'];
|
|
13299
|
+
name?: Config['name'];
|
|
13300
|
+
}
|
|
13301
|
+
declare function fallback(missingList: string[], options?: FallbackOptions): Promise<Config[]>;
|
|
13302
|
+
|
|
13303
|
+
declare function ignores(ignores?: string[]): Promise<Config[]>;
|
|
13304
|
+
|
|
13305
|
+
declare function imports(): Promise<Config[]>;
|
|
13306
|
+
|
|
13300
13307
|
/**
|
|
13301
13308
|
* Represents the options for configuring the JavaScript ESLint configuration.
|
|
13302
13309
|
*/
|
|
@@ -13451,15 +13458,6 @@ declare const yamlFiles: string[];
|
|
|
13451
13458
|
*/
|
|
13452
13459
|
declare function yaml(options?: YamlOptions): Promise<Config[]>;
|
|
13453
13460
|
|
|
13454
|
-
/**
|
|
13455
|
-
* Define a new ESLint config.
|
|
13456
|
-
*
|
|
13457
|
-
* @param options - Options to configure the ESLint config.
|
|
13458
|
-
* @param userConfigs - Additional ESLint configs to include.
|
|
13459
|
-
* @returns A composable ESLint config.
|
|
13460
|
-
*/
|
|
13461
|
-
declare function defineConfig<C extends Config = Config, CN extends ConfigNames = ConfigNames>(options?: Options, ...userConfigs: ResolvableFlatConfig<Config extends C ? C : Config>[]): FlatConfigComposer<Config extends C ? C : Config, CN>;
|
|
13462
|
-
|
|
13463
13461
|
/**
|
|
13464
13462
|
* Check if the process is running in a Git hook or under lint-staged.
|
|
13465
13463
|
*
|
package/lib/index.js
CHANGED
|
@@ -7,13 +7,6 @@ import { isPackageExists as isPackageExists3 } from "local-pkg";
|
|
|
7
7
|
import { composer } from "eslint-flat-config-utils";
|
|
8
8
|
var composeConfig = (...configs) => composer(...configs);
|
|
9
9
|
|
|
10
|
-
// src/plugins.ts
|
|
11
|
-
// @__NO_SIDE_EFFECTS__
|
|
12
|
-
async function interopDefault(m) {
|
|
13
|
-
const resolved = await m;
|
|
14
|
-
return typeof resolved === "object" && resolved !== null && "default" in resolved ? /* @__PURE__ */ interopDefault(resolved.default) : resolved;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
10
|
// src/require-of.ts
|
|
18
11
|
import { isPackageExists } from "local-pkg";
|
|
19
12
|
var packageExistsCache = /* @__PURE__ */ new Map();
|
|
@@ -24,16 +17,23 @@ var has = (name) => {
|
|
|
24
17
|
return packageExistsCache.get(name);
|
|
25
18
|
};
|
|
26
19
|
async function requireOf(names, getConfig, fallback2) {
|
|
27
|
-
const missingList = names.filter((n) => n && !has(n));
|
|
20
|
+
const missingList = names.filter((n) => n !== "" && !has(n));
|
|
28
21
|
if (missingList.length) {
|
|
29
22
|
return fallback2(missingList);
|
|
30
23
|
}
|
|
31
24
|
return getConfig();
|
|
32
25
|
}
|
|
33
26
|
|
|
27
|
+
// src/utils.ts
|
|
28
|
+
// @__NO_SIDE_EFFECTS__
|
|
29
|
+
async function interopDefault(m) {
|
|
30
|
+
const resolved = await m;
|
|
31
|
+
return typeof resolved === "object" && resolved !== null && "default" in resolved ? /* @__PURE__ */ interopDefault(resolved.default) : resolved;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
34
|
// src/configs/fallback.ts
|
|
35
35
|
async function fallback(missingList, options) {
|
|
36
|
-
const rules = await interopDefault(import("./missing-module-for-config-
|
|
36
|
+
const rules = await interopDefault(import("./missing-module-for-config-YSY2AGPQ.js"));
|
|
37
37
|
const pluginName = `@bfra.me${missingList.length > 0 ? `/missing-modules-${missingList.map((m) => m.replaceAll(/[^a-z0-9]/gi, "-").toLowerCase()).join("-")}` : ""}`;
|
|
38
38
|
return [
|
|
39
39
|
{
|
|
@@ -175,31 +175,22 @@ async function epilogue() {
|
|
|
175
175
|
}
|
|
176
176
|
|
|
177
177
|
// src/configs/eslint-comments.ts
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
"eslint-comments/no-unlimited-disable": "error",
|
|
195
|
-
"eslint-comments/no-unused-disable": "error",
|
|
196
|
-
"eslint-comments/no-unused-enable": "error"
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
];
|
|
200
|
-
},
|
|
201
|
-
fallback
|
|
202
|
-
);
|
|
178
|
+
import pluginEslintComments from "@eslint-community/eslint-plugin-eslint-comments";
|
|
179
|
+
function eslintComments() {
|
|
180
|
+
return [
|
|
181
|
+
{
|
|
182
|
+
name: "@bfra.me/eslint-comments/rules",
|
|
183
|
+
plugins: { "eslint-comments": pluginEslintComments },
|
|
184
|
+
rules: {
|
|
185
|
+
"eslint-comments/disable-enable-pair": ["error", { allowWholeFile: true }],
|
|
186
|
+
"eslint-comments/no-aggregating-enable": "error",
|
|
187
|
+
"eslint-comments/no-duplicate-disable": "error",
|
|
188
|
+
"eslint-comments/no-unlimited-disable": "error",
|
|
189
|
+
"eslint-comments/no-unused-disable": "error",
|
|
190
|
+
"eslint-comments/no-unused-enable": "error"
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
];
|
|
203
194
|
}
|
|
204
195
|
|
|
205
196
|
// src/configs/ignores.ts
|
|
@@ -304,7 +295,7 @@ async function javascript(options = {}) {
|
|
|
304
295
|
"no-dupe-class-members": "error",
|
|
305
296
|
"no-dupe-keys": "error",
|
|
306
297
|
"no-duplicate-case": "error",
|
|
307
|
-
"no-duplicate-imports": "error",
|
|
298
|
+
"no-duplicate-imports": ["error", { allowSeparateTypeImports: true }],
|
|
308
299
|
"no-empty": ["error", { allowEmptyCatch: true }],
|
|
309
300
|
"no-empty-character-class": "error",
|
|
310
301
|
"no-empty-pattern": "error",
|
|
@@ -506,7 +497,7 @@ async function jsdoc() {
|
|
|
506
497
|
import { fileURLToPath } from "url";
|
|
507
498
|
|
|
508
499
|
// package.json
|
|
509
|
-
var version = "0.
|
|
500
|
+
var version = "0.26.0";
|
|
510
501
|
|
|
511
502
|
// src/parsers/any-parser.ts
|
|
512
503
|
var lineBreakPattern = /\r\n|[\n\r\u2028\u2029]/u;
|
|
@@ -558,7 +549,7 @@ async function jsonSchema(name, files) {
|
|
|
558
549
|
return {};
|
|
559
550
|
}).filter((o) => Object.keys(o).length > 0).map((config2, index) => ({
|
|
560
551
|
...config2,
|
|
561
|
-
name: config2.plugins ? `@bfra.me/${name}/json-schema/plugins` : `@bfra.me/${name}/json-schema/${config2.name || `unnamed${index}`}`
|
|
552
|
+
name: config2.plugins ? `@bfra.me/${name}/json-schema/plugins` : `@bfra.me/${name}/json-schema/${(config2.name ?? "") || `unnamed${index}`}`
|
|
562
553
|
})),
|
|
563
554
|
{
|
|
564
555
|
name: `@bfra.me/${name}/json-schema`,
|
|
@@ -613,7 +604,7 @@ async function jsonc(options = {}) {
|
|
|
613
604
|
...pluginJsonc.configs["flat/base"].map(
|
|
614
605
|
(config2, index) => ({
|
|
615
606
|
...config2,
|
|
616
|
-
name: config2.plugins ? `@bfra.me/jsonc/plugins` : `@bfra.me/${config2.name || `jsonc/unnamed${index}`}`
|
|
607
|
+
name: config2.plugins ? `@bfra.me/jsonc/plugins` : `@bfra.me/${(config2.name ?? "") || `jsonc/unnamed${index}`}`
|
|
617
608
|
})
|
|
618
609
|
),
|
|
619
610
|
...await jsonSchema("jsonc", files),
|
|
@@ -813,7 +804,7 @@ async function packageJson(options = {}) {
|
|
|
813
804
|
...pluginNodeDependencies.configs["flat/recommended"].map(
|
|
814
805
|
(config2, index) => ({
|
|
815
806
|
...config2,
|
|
816
|
-
name: config2.plugins ? `@bfra.me/package-json/plugins` : `@bfra.me/${config2.name || `package-json/unnamed${index}`}`,
|
|
807
|
+
name: config2.plugins ? `@bfra.me/package-json/plugins` : `@bfra.me/${(config2.name ?? "") || `package-json/unnamed${index}`}`,
|
|
817
808
|
files
|
|
818
809
|
})
|
|
819
810
|
),
|
|
@@ -951,7 +942,7 @@ async function toml(options = {}) {
|
|
|
951
942
|
return [
|
|
952
943
|
...pluginToml.configs["flat/standard"].map((config2, index) => ({
|
|
953
944
|
...config2,
|
|
954
|
-
name: config2.plugins ? `@bfra.me/toml/plugins` : `@bfra.me/${config2.name || `toml/unnamed${index}`}`
|
|
945
|
+
name: config2.plugins ? `@bfra.me/toml/plugins` : `@bfra.me/${(config2.name ?? "") || `toml/unnamed${index}`}`
|
|
955
946
|
})),
|
|
956
947
|
...await jsonSchema("toml", files),
|
|
957
948
|
{
|
|
@@ -1065,17 +1056,35 @@ async function regexp(options = {}) {
|
|
|
1065
1056
|
import process2 from "process";
|
|
1066
1057
|
var TypeAwareRules = {
|
|
1067
1058
|
"@typescript-eslint/await-thenable": "error",
|
|
1068
|
-
"dot-notation": "
|
|
1069
|
-
"@typescript-eslint/
|
|
1059
|
+
"@typescript-eslint/dot-notation": ["error", { allowKeywords: true }],
|
|
1060
|
+
"@typescript-eslint/no-floating-promises": "error",
|
|
1070
1061
|
"@typescript-eslint/no-for-in-array": "error",
|
|
1062
|
+
"@typescript-eslint/no-implied-eval": "error",
|
|
1063
|
+
"@typescript-eslint/no-misused-promises": "error",
|
|
1071
1064
|
"@typescript-eslint/no-unnecessary-qualifier": "error",
|
|
1072
1065
|
"@typescript-eslint/no-unnecessary-type-assertion": "error",
|
|
1066
|
+
"@typescript-eslint/no-unsafe-argument": "error",
|
|
1067
|
+
"@typescript-eslint/no-unsafe-assignment": "error",
|
|
1068
|
+
"@typescript-eslint/no-unsafe-call": "error",
|
|
1069
|
+
"@typescript-eslint/no-unsafe-member-access": "error",
|
|
1070
|
+
"@typescript-eslint/no-unsafe-return": "error",
|
|
1073
1071
|
"@typescript-eslint/prefer-includes": "error",
|
|
1072
|
+
"@typescript-eslint/prefer-readonly": "error",
|
|
1073
|
+
"@typescript-eslint/prefer-readonly-parameter-types": "off",
|
|
1074
1074
|
"@typescript-eslint/prefer-string-starts-ends-with": "error",
|
|
1075
1075
|
"@typescript-eslint/promise-function-async": "error",
|
|
1076
1076
|
"@typescript-eslint/require-array-sort-compare": "error",
|
|
1077
1077
|
"@typescript-eslint/restrict-plus-operands": "error",
|
|
1078
|
-
"@typescript-eslint/
|
|
1078
|
+
"@typescript-eslint/restrict-template-expressions": "error",
|
|
1079
|
+
"@typescript-eslint/return-await": ["error", "in-try-catch"],
|
|
1080
|
+
"@typescript-eslint/strict-boolean-expressions": [
|
|
1081
|
+
"error",
|
|
1082
|
+
{ allowNullableBoolean: true, allowNullableObject: true }
|
|
1083
|
+
],
|
|
1084
|
+
"@typescript-eslint/switch-exhaustiveness-check": "error",
|
|
1085
|
+
"@typescript-eslint/unbound-method": "error",
|
|
1086
|
+
"dot-notation": "off",
|
|
1087
|
+
"no-implied-eval": "off"
|
|
1079
1088
|
};
|
|
1080
1089
|
async function typescript(options = {}) {
|
|
1081
1090
|
const { overrides = {}, parserOptions = {}, typeAware = { overrides: {} } } = options;
|
|
@@ -1093,6 +1102,7 @@ async function typescript(options = {}) {
|
|
|
1093
1102
|
files: files2,
|
|
1094
1103
|
...ignores2 ? { ignores: ignores2 } : {},
|
|
1095
1104
|
languageOptions: {
|
|
1105
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
1096
1106
|
parser: tselint.parser,
|
|
1097
1107
|
parserOptions: {
|
|
1098
1108
|
sourceType: "module",
|
|
@@ -1110,10 +1120,11 @@ async function typescript(options = {}) {
|
|
|
1110
1120
|
return [
|
|
1111
1121
|
{
|
|
1112
1122
|
name: "@bfra.me/typescript/plugins",
|
|
1123
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
1113
1124
|
plugins: { "@typescript-eslint": tselint.plugin }
|
|
1114
1125
|
},
|
|
1115
1126
|
...isTypeAware ? [
|
|
1116
|
-
generateTsConfig("default", files),
|
|
1127
|
+
generateTsConfig("default", files, typeAwareFiles),
|
|
1117
1128
|
generateTsConfig("type-aware", typeAwareFiles, typeAwareIgnores)
|
|
1118
1129
|
] : [generateTsConfig("default", files)],
|
|
1119
1130
|
{
|
|
@@ -1121,6 +1132,7 @@ async function typescript(options = {}) {
|
|
|
1121
1132
|
files,
|
|
1122
1133
|
rules: {
|
|
1123
1134
|
...tselint.configs.eslintRecommended.rules,
|
|
1135
|
+
...tselint.configs.strict.map((config2) => config2.rules).reduce((acc, rules) => ({ ...acc, ...rules }), {}),
|
|
1124
1136
|
"@typescript-eslint/no-namespace": "error",
|
|
1125
1137
|
"@typescript-eslint/array-type": "error",
|
|
1126
1138
|
"@typescript-eslint/ban-ts-comment": [
|
|
@@ -1128,6 +1140,7 @@ async function typescript(options = {}) {
|
|
|
1128
1140
|
{ "ts-expect-error": "allow-with-description" }
|
|
1129
1141
|
],
|
|
1130
1142
|
"@typescript-eslint/consistent-type-assertions": "error",
|
|
1143
|
+
"@typescript-eslint/consistent-type-definitions": ["error", "interface"],
|
|
1131
1144
|
"@typescript-eslint/consistent-type-imports": [
|
|
1132
1145
|
"error",
|
|
1133
1146
|
{ disallowTypeAnnotations: false, fixStyle: "inline-type-imports" }
|
|
@@ -1147,19 +1160,97 @@ async function typescript(options = {}) {
|
|
|
1147
1160
|
accessibility: "no-public"
|
|
1148
1161
|
}
|
|
1149
1162
|
],
|
|
1163
|
+
"@typescript-eslint/member-ordering": [
|
|
1164
|
+
"error",
|
|
1165
|
+
{
|
|
1166
|
+
default: [
|
|
1167
|
+
"signature",
|
|
1168
|
+
"public-static-field",
|
|
1169
|
+
"protected-static-field",
|
|
1170
|
+
"private-static-field",
|
|
1171
|
+
"public-instance-field",
|
|
1172
|
+
"protected-instance-field",
|
|
1173
|
+
"private-instance-field",
|
|
1174
|
+
"public-constructor",
|
|
1175
|
+
"protected-constructor",
|
|
1176
|
+
"private-constructor",
|
|
1177
|
+
"public-static-method",
|
|
1178
|
+
"protected-static-method",
|
|
1179
|
+
"private-static-method",
|
|
1180
|
+
"public-instance-method",
|
|
1181
|
+
"protected-instance-method",
|
|
1182
|
+
"private-instance-method"
|
|
1183
|
+
]
|
|
1184
|
+
}
|
|
1185
|
+
],
|
|
1186
|
+
"@typescript-eslint/method-signature-style": ["error", "property"],
|
|
1187
|
+
"@typescript-eslint/naming-convention": [
|
|
1188
|
+
"error",
|
|
1189
|
+
{
|
|
1190
|
+
format: ["camelCase", "PascalCase", "UPPER_CASE"],
|
|
1191
|
+
selector: "variableLike"
|
|
1192
|
+
},
|
|
1193
|
+
{
|
|
1194
|
+
format: ["PascalCase"],
|
|
1195
|
+
selector: "typeLike"
|
|
1196
|
+
},
|
|
1197
|
+
{
|
|
1198
|
+
format: ["camelCase"],
|
|
1199
|
+
leadingUnderscore: "allow",
|
|
1200
|
+
selector: "parameter"
|
|
1201
|
+
},
|
|
1202
|
+
{
|
|
1203
|
+
format: ["PascalCase"],
|
|
1204
|
+
selector: "class"
|
|
1205
|
+
},
|
|
1206
|
+
{
|
|
1207
|
+
custom: {
|
|
1208
|
+
match: false,
|
|
1209
|
+
regex: "^I[A-Z]"
|
|
1210
|
+
},
|
|
1211
|
+
format: ["PascalCase"],
|
|
1212
|
+
selector: "interface"
|
|
1213
|
+
}
|
|
1214
|
+
],
|
|
1150
1215
|
"@typescript-eslint/no-array-constructor": "error",
|
|
1216
|
+
"@typescript-eslint/no-dupe-class-members": "error",
|
|
1217
|
+
"@typescript-eslint/no-dynamic-delete": "off",
|
|
1151
1218
|
"@typescript-eslint/no-empty-object-type": ["error", { allowInterfaces: "always" }],
|
|
1152
1219
|
"@typescript-eslint/no-explicit-any": "off",
|
|
1153
1220
|
"@typescript-eslint/no-extraneous-class": "error",
|
|
1221
|
+
"@typescript-eslint/no-import-type-side-effects": "error",
|
|
1154
1222
|
"@typescript-eslint/no-inferrable-types": "error",
|
|
1223
|
+
"@typescript-eslint/no-invalid-this": "error",
|
|
1224
|
+
"@typescript-eslint/no-invalid-void-type": "off",
|
|
1155
1225
|
"@typescript-eslint/no-misused-new": "error",
|
|
1156
1226
|
"@typescript-eslint/no-non-null-assertion": "warn",
|
|
1227
|
+
"@typescript-eslint/no-redeclare": ["error", { builtinGlobals: false }],
|
|
1157
1228
|
"@typescript-eslint/no-require-imports": "error",
|
|
1229
|
+
"@typescript-eslint/no-unused-expressions": [
|
|
1230
|
+
"error",
|
|
1231
|
+
{
|
|
1232
|
+
allowShortCircuit: true,
|
|
1233
|
+
allowTaggedTemplates: true,
|
|
1234
|
+
allowTernary: true
|
|
1235
|
+
}
|
|
1236
|
+
],
|
|
1158
1237
|
// This is reported by `unused-imports/no-unused-vars`
|
|
1159
1238
|
"@typescript-eslint/no-unused-vars": "off",
|
|
1160
|
-
"@typescript-eslint/no-
|
|
1239
|
+
"@typescript-eslint/no-use-before-define": [
|
|
1240
|
+
"error",
|
|
1241
|
+
{ classes: false, functions: false, variables: true }
|
|
1242
|
+
],
|
|
1243
|
+
"@typescript-eslint/no-useless-constructor": "off",
|
|
1244
|
+
"@typescript-eslint/no-wrapper-object-types": "error",
|
|
1161
1245
|
"@typescript-eslint/prefer-for-of": "warn",
|
|
1162
1246
|
"@typescript-eslint/prefer-function-type": "warn",
|
|
1247
|
+
"@typescript-eslint/triple-slash-reference": "off",
|
|
1248
|
+
"@typescript-eslint/unified-signatures": "off",
|
|
1249
|
+
"no-dupe-class-members": "off",
|
|
1250
|
+
"no-invalid-this": "off",
|
|
1251
|
+
"no-redeclare": "off",
|
|
1252
|
+
"no-use-before-define": "off",
|
|
1253
|
+
"no-useless-constructor": "off",
|
|
1163
1254
|
...overrides
|
|
1164
1255
|
}
|
|
1165
1256
|
},
|
|
@@ -1272,29 +1363,18 @@ async function unicorn(options = {}) {
|
|
|
1272
1363
|
}
|
|
1273
1364
|
|
|
1274
1365
|
// src/configs/vitest.ts
|
|
1275
|
-
var _pluginTest;
|
|
1276
1366
|
async function vitest(options = {}) {
|
|
1277
1367
|
const { files = GLOB_TESTS, isInEditor: isInEditor2 = false, overrides = {} } = options;
|
|
1278
1368
|
return requireOf(
|
|
1279
|
-
["@vitest/eslint-plugin"
|
|
1369
|
+
["@vitest/eslint-plugin"],
|
|
1280
1370
|
async () => {
|
|
1281
|
-
const
|
|
1282
|
-
interopDefault(import("@vitest/eslint-plugin")),
|
|
1283
|
-
// @ts-expect-error - No types
|
|
1284
|
-
interopDefault(import("eslint-plugin-no-only-tests"))
|
|
1285
|
-
]);
|
|
1286
|
-
_pluginTest ??= {
|
|
1287
|
-
...vitest2,
|
|
1288
|
-
rules: {
|
|
1289
|
-
...vitest2.rules,
|
|
1290
|
-
...noOnlyTests.rules
|
|
1291
|
-
}
|
|
1292
|
-
};
|
|
1371
|
+
const vitest2 = await interopDefault(import("@vitest/eslint-plugin"));
|
|
1293
1372
|
return [
|
|
1294
1373
|
{
|
|
1295
1374
|
name: "@bfra.me/vitest/plugins",
|
|
1296
1375
|
plugins: {
|
|
1297
|
-
|
|
1376
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
1377
|
+
vitest: vitest2
|
|
1298
1378
|
},
|
|
1299
1379
|
settings: {
|
|
1300
1380
|
vitest: {
|
|
@@ -1308,11 +1388,19 @@ async function vitest(options = {}) {
|
|
|
1308
1388
|
files,
|
|
1309
1389
|
rules: {
|
|
1310
1390
|
...vitest2.configs?.recommended.rules ?? {},
|
|
1311
|
-
"
|
|
1312
|
-
"no-
|
|
1313
|
-
"vitest/no-
|
|
1391
|
+
"vitest/consistent-test-it": ["error", { fn: "it", withinDescribe: "it" }],
|
|
1392
|
+
"vitest/no-focused-tests": isInEditor2 ? "off" : ["error", { fixable: true }],
|
|
1393
|
+
"vitest/no-import-node-test": "error",
|
|
1394
|
+
"vitest/prefer-hooks-in-order": "error",
|
|
1395
|
+
"vitest/prefer-lowercase-title": "error",
|
|
1314
1396
|
// @ts-expect-error - @vitest/eslint-plugin types are incorrect
|
|
1315
1397
|
"vitest/valid-title": ["error", { allowArguments: true }],
|
|
1398
|
+
// Disabled rules
|
|
1399
|
+
...{
|
|
1400
|
+
"@typescript-eslint/explicit-function-return-type": "off",
|
|
1401
|
+
"no-unused-expressions": "off",
|
|
1402
|
+
"node/prefer-global/process": "off"
|
|
1403
|
+
},
|
|
1316
1404
|
...overrides
|
|
1317
1405
|
}
|
|
1318
1406
|
}
|
|
@@ -1338,7 +1426,7 @@ async function yaml(options = {}) {
|
|
|
1338
1426
|
return [
|
|
1339
1427
|
...pluginYaml.configs["flat/standard"].map((config2, index) => ({
|
|
1340
1428
|
...config2,
|
|
1341
|
-
name: config2.plugins ? `@bfra.me/yaml/plugins` : `@bfra.me/${config2.name || `yaml/unnamed${index}`}`
|
|
1429
|
+
name: config2.plugins ? `@bfra.me/yaml/plugins` : `@bfra.me/${(config2.name ?? "") || `yaml/unnamed${index}`}`
|
|
1342
1430
|
})),
|
|
1343
1431
|
...await jsonSchema("yaml", files),
|
|
1344
1432
|
{
|
|
@@ -1361,8 +1449,10 @@ async function yaml(options = {}) {
|
|
|
1361
1449
|
// src/env.ts
|
|
1362
1450
|
import { env } from "process";
|
|
1363
1451
|
import isInCI from "is-in-ci";
|
|
1364
|
-
var isInGitLifecycle = !!(env.GIT_PARAMS || env.VSCODE_GIT_COMMAND || env.npm_lifecycle_script?.startsWith("lint-staged"));
|
|
1365
|
-
var isInEditor = !isInCI && !isInGitLifecycle &&
|
|
1452
|
+
var isInGitLifecycle = !!(typeof env.GIT_PARAMS === "string" && env.GIT_PARAMS.length > 0 || typeof env.VSCODE_GIT_COMMAND === "string" && env.VSCODE_GIT_COMMAND.length > 0 || env.npm_lifecycle_script?.startsWith("lint-staged"));
|
|
1453
|
+
var isInEditor = !isInCI && !isInGitLifecycle && Boolean(
|
|
1454
|
+
typeof env.VSCODE_PID === "string" && env.VSCODE_PID.length > 0 || typeof env.VSCODE_CWD === "string" && env.VSCODE_CWD.length > 0 || typeof env.JETBRAINS_IDE === "string" && env.JETBRAINS_IDE.length > 0 || typeof env.VIM === "string" && env.VIM.length > 0 || typeof env.NVIM === "string" && env.NVIM.length > 0
|
|
1455
|
+
);
|
|
1366
1456
|
|
|
1367
1457
|
// src/define-config.ts
|
|
1368
1458
|
var AllowedConfigPropertiesForOptions = [
|
|
@@ -15,10 +15,10 @@ function tryInstall(module, targetFile = process.cwd()) {
|
|
|
15
15
|
if (installedModules.has(module)) {
|
|
16
16
|
return null;
|
|
17
17
|
}
|
|
18
|
-
const cwd = packageDirectorySync({ cwd: targetFile });
|
|
18
|
+
const cwd = packageDirectorySync({ cwd: targetFile }) ?? "";
|
|
19
19
|
if (cwd) {
|
|
20
20
|
installedModules.add(module);
|
|
21
|
-
const { moduleName, version } = parseModule(module);
|
|
21
|
+
const { moduleName, version = "" } = parseModule(module);
|
|
22
22
|
const result = installPackageSync(moduleName + (version ? `@^${version}` : ""), {
|
|
23
23
|
cwd,
|
|
24
24
|
dev: true
|
|
@@ -28,7 +28,7 @@ function tryInstall(module, targetFile = process.cwd()) {
|
|
|
28
28
|
return null;
|
|
29
29
|
}
|
|
30
30
|
function getPackageInstallCommand(module, targetFile = process.cwd()) {
|
|
31
|
-
const cwd = packageDirectorySync({ cwd: targetFile });
|
|
31
|
+
const cwd = packageDirectorySync({ cwd: targetFile }) ?? "";
|
|
32
32
|
if (!cwd) {
|
|
33
33
|
return null;
|
|
34
34
|
}
|
|
@@ -47,10 +47,10 @@ function parseModule(name) {
|
|
|
47
47
|
version: parts.at(-1)
|
|
48
48
|
};
|
|
49
49
|
}
|
|
50
|
-
return { moduleName: name
|
|
50
|
+
return { moduleName: name };
|
|
51
51
|
}
|
|
52
52
|
function installPackageSync(packages, options) {
|
|
53
|
-
const manager = detectPackageManagerSync(options.cwd)?.split("@")[0] || "npm";
|
|
53
|
+
const manager = (detectPackageManagerSync(options.cwd)?.split("@")[0] ?? "") || "npm";
|
|
54
54
|
if (!Array.isArray(packages)) {
|
|
55
55
|
packages = [packages];
|
|
56
56
|
}
|
|
@@ -73,10 +73,10 @@ function installPackageSync(packages, options) {
|
|
|
73
73
|
{ cwd: options.cwd, maxBuffer: Infinity, stdio: "inherit", windowsHide: true }
|
|
74
74
|
);
|
|
75
75
|
if (result.error || result.status !== 0) {
|
|
76
|
-
const errorMessage = result.error?.message || `Package installation failed with status ${result.status}`;
|
|
76
|
+
const errorMessage = (result.error?.message ?? "") || `Package installation failed with status ${result.status}`;
|
|
77
77
|
throw new Error(errorMessage);
|
|
78
78
|
}
|
|
79
|
-
return `${result.output}`;
|
|
79
|
+
return `${result.output?.toString() ?? ""}`;
|
|
80
80
|
}
|
|
81
81
|
function detectPackageManagerSync(cwd = process.cwd()) {
|
|
82
82
|
try {
|
|
@@ -128,11 +128,11 @@ function create(context) {
|
|
|
128
128
|
for (const module of modules) {
|
|
129
129
|
let output = "";
|
|
130
130
|
if (shouldFix) {
|
|
131
|
-
const result = tryInstall(module, context.filename || context.getFilename());
|
|
131
|
+
const result = tryInstall(module, context.filename || context.getFilename()) ?? "";
|
|
132
132
|
output = result ? `
|
|
133
133
|
${result}` : "";
|
|
134
134
|
}
|
|
135
|
-
const command = getPackageInstallCommand(module, context.filename || context.getFilename());
|
|
135
|
+
const command = getPackageInstallCommand(module, context.filename || context.getFilename()) ?? "";
|
|
136
136
|
context.report({
|
|
137
137
|
loc: { column: 0, line: 1 },
|
|
138
138
|
message: `Missing module for config: ${module}. Run: \`${command || `npm i -D ${module}`}\`${output}`
|
|
@@ -144,4 +144,4 @@ export {
|
|
|
144
144
|
create,
|
|
145
145
|
meta
|
|
146
146
|
};
|
|
147
|
-
//# sourceMappingURL=missing-module-for-config-
|
|
147
|
+
//# sourceMappingURL=missing-module-for-config-YSY2AGPQ.js.map
|