@typescript-eslint/rule-tester 8.0.0-alpha.51 → 8.0.0-alpha.53
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/dist/RuleTester.d.ts +2 -2
- package/dist/RuleTester.d.ts.map +1 -1
- package/dist/RuleTester.js +138 -88
- package/dist/RuleTester.js.map +1 -1
- package/dist/types/RuleTesterConfig.d.ts +9 -15
- package/dist/types/RuleTesterConfig.d.ts.map +1 -1
- package/dist/types/ValidTestCase.d.ts +21 -15
- package/dist/types/ValidTestCase.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/utils/config-validator.d.ts.map +1 -1
- package/dist/utils/config-validator.js +2 -47
- package/dist/utils/config-validator.js.map +1 -1
- package/dist/utils/flat-config-schema.d.ts +66 -0
- package/dist/utils/flat-config-schema.d.ts.map +1 -0
- package/dist/utils/flat-config-schema.js +455 -0
- package/dist/utils/flat-config-schema.js.map +1 -0
- package/dist/utils/omitCustomConfigProperties.d.ts +3 -0
- package/dist/utils/omitCustomConfigProperties.d.ts.map +1 -0
- package/dist/utils/omitCustomConfigProperties.js +10 -0
- package/dist/utils/omitCustomConfigProperties.js.map +1 -0
- package/dist/utils/severity.d.ts +14 -0
- package/dist/utils/severity.d.ts.map +1 -0
- package/dist/utils/severity.js +40 -0
- package/dist/utils/severity.js.map +1 -0
- package/dist/utils/validationHelpers.d.ts +1 -13
- package/dist/utils/validationHelpers.d.ts.map +1 -1
- package/dist/utils/validationHelpers.js +3 -32
- package/dist/utils/validationHelpers.js.map +1 -1
- package/package.json +4 -4
- package/dist/utils/config-schema.d.ts +0 -3
- package/dist/utils/config-schema.d.ts.map +0 -1
- package/dist/utils/config-schema.js +0 -87
- package/dist/utils/config-schema.js.map +0 -1
package/dist/types/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import type { ValidTestCase } from './ValidTestCase';
|
|
|
4
4
|
type Mutable<T> = {
|
|
5
5
|
-readonly [P in keyof T]: T[P];
|
|
6
6
|
};
|
|
7
|
-
export type TesterConfigWithDefaults = Mutable<Required<Pick<RuleTesterConfig, 'defaultFilenames' | '
|
|
7
|
+
export type TesterConfigWithDefaults = Mutable<Required<Pick<RuleTesterConfig, 'defaultFilenames' | 'languageOptions' | 'rules'>> & RuleTesterConfig>;
|
|
8
8
|
export interface RunTests<MessageIds extends string, Options extends readonly unknown[]> {
|
|
9
9
|
readonly valid: readonly (ValidTestCase<Options> | string)[];
|
|
10
10
|
readonly invalid: readonly InvalidTestCase<MessageIds, Options>[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAErD,KAAK,OAAO,CAAC,CAAC,IAAI;IAChB,CAAC,UAAU,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAC/B,CAAC;AACF,MAAM,MAAM,wBAAwB,GAAG,OAAO,CAC5C,QAAQ,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAErD,KAAK,OAAO,CAAC,CAAC,IAAI;IAChB,CAAC,UAAU,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAC/B,CAAC;AACF,MAAM,MAAM,wBAAwB,GAAG,OAAO,CAC5C,QAAQ,CACN,IAAI,CAAC,gBAAgB,EAAE,kBAAkB,GAAG,iBAAiB,GAAG,OAAO,CAAC,CACzE,GACC,gBAAgB,CACnB,CAAC;AAEF,MAAM,WAAW,QAAQ,CACvB,UAAU,SAAS,MAAM,EACzB,OAAO,SAAS,SAAS,OAAO,EAAE;IAGlC,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC,aAAa,CAAC,OAAO,CAAC,GAAG,MAAM,CAAC,EAAE,CAAC;IAC7D,QAAQ,CAAC,OAAO,EAAE,SAAS,eAAe,CAAC,UAAU,EAAE,OAAO,CAAC,EAAE,CAAC;CACnE;AAED,MAAM,WAAW,kBAAkB,CACjC,UAAU,SAAS,MAAM,EACzB,OAAO,SAAS,SAAS,OAAO,EAAE;IAElC,QAAQ,CAAC,KAAK,EAAE,SAAS,aAAa,CAAC,OAAO,CAAC,EAAE,CAAC;IAClD,QAAQ,CAAC,OAAO,EAAE,SAAS,eAAe,CAAC,UAAU,EAAE,OAAO,CAAC,EAAE,CAAC;CACnE;AAED,YAAY,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACrD,YAAY,EACV,eAAe,EACf,gBAAgB,EAChB,aAAa,GACd,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-validator.d.ts","sourceRoot":"","sources":["../../src/utils/config-validator.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"config-validator.d.ts","sourceRoot":"","sources":["../../src/utils/config-validator.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,aAAa,EAAU,MAAM,oCAAoC,CAAC;AAQhF,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,UAAU,CAAC;AAOzD,KAAK,iBAAiB,GAAG,CAAC,MAAM,EAAE,MAAM,KAAK,aAAa,GAAG,IAAI,CAAC;AAoMlE;;;;;GAKG;AACH,wBAAgB,QAAQ,CACtB,MAAM,EAAE,wBAAwB,EAChC,MAAM,EAAE,MAAM,EACd,iBAAiB,EAAE,iBAAiB,GACnC,IAAI,CAGN"}
|
|
@@ -6,14 +6,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
exports.validate = validate;
|
|
8
8
|
const node_util_1 = __importDefault(require("node:util"));
|
|
9
|
-
const eslintrc_1 = require("@eslint/eslintrc");
|
|
10
9
|
const use_at_your_own_risk_1 = require("eslint/use-at-your-own-risk");
|
|
11
10
|
const ajv_1 = require("./ajv");
|
|
12
|
-
const config_schema_1 = require("./config-schema");
|
|
13
11
|
const deprecation_warnings_1 = require("./deprecation-warnings");
|
|
12
|
+
const flat_config_schema_1 = require("./flat-config-schema");
|
|
14
13
|
const getRuleOptionsSchema_1 = require("./getRuleOptionsSchema");
|
|
15
14
|
const hasOwnProperty_1 = require("./hasOwnProperty");
|
|
16
|
-
const { ConfigOps, environments: BuiltInEnvironments } = eslintrc_1.Legacy;
|
|
17
15
|
const ajv = (0, ajv_1.ajvBuilder)();
|
|
18
16
|
const ruleValidators = new WeakMap();
|
|
19
17
|
let validateSchema;
|
|
@@ -89,24 +87,6 @@ function validateRuleOptions(rule, ruleId, options, source = null) {
|
|
|
89
87
|
}
|
|
90
88
|
}
|
|
91
89
|
}
|
|
92
|
-
/**
|
|
93
|
-
* Validates an environment object
|
|
94
|
-
* @param environment The environment config object to validate.
|
|
95
|
-
* @param source The name of the configuration source to report in any errors.
|
|
96
|
-
*/
|
|
97
|
-
function validateEnvironment(environment, source) {
|
|
98
|
-
// not having an environment is ok
|
|
99
|
-
if (!environment) {
|
|
100
|
-
return;
|
|
101
|
-
}
|
|
102
|
-
Object.keys(environment).forEach(id => {
|
|
103
|
-
const env = BuiltInEnvironments.get(id) ?? null;
|
|
104
|
-
if (!env) {
|
|
105
|
-
const message = `${source}:\n\tEnvironment key "${id}" is unknown\n`;
|
|
106
|
-
throw new Error(message);
|
|
107
|
-
}
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
90
|
/**
|
|
111
91
|
* Validates a rules config object
|
|
112
92
|
* @param rulesConfig The rules config object to validate.
|
|
@@ -126,24 +106,6 @@ function validateRules(rulesConfig, source, getAdditionalRule) {
|
|
|
126
106
|
validateRuleOptions(rule, id, rulesConfig[id], source);
|
|
127
107
|
});
|
|
128
108
|
}
|
|
129
|
-
/**
|
|
130
|
-
* Validates a `globals` section of a config file
|
|
131
|
-
* @param globalsConfig The `globals` section
|
|
132
|
-
* @param source The name of the configuration source to report in the event of an error.
|
|
133
|
-
*/
|
|
134
|
-
function validateGlobals(globalsConfig, source = null) {
|
|
135
|
-
if (!globalsConfig) {
|
|
136
|
-
return;
|
|
137
|
-
}
|
|
138
|
-
Object.entries(globalsConfig).forEach(([configuredGlobal, configuredValue]) => {
|
|
139
|
-
try {
|
|
140
|
-
ConfigOps.normalizeConfigGlobal(configuredValue);
|
|
141
|
-
}
|
|
142
|
-
catch (err) {
|
|
143
|
-
throw new Error(`ESLint configuration of global '${configuredGlobal}' in ${source} is invalid:\n${err.message}`);
|
|
144
|
-
}
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
109
|
/**
|
|
148
110
|
* Formats an array of schema validation errors.
|
|
149
111
|
*/
|
|
@@ -179,7 +141,7 @@ function formatErrors(errors) {
|
|
|
179
141
|
* @throws {Error} For any config invalid per the schema.
|
|
180
142
|
*/
|
|
181
143
|
function validateConfigSchema(config, source) {
|
|
182
|
-
validateSchema ||= ajv.compile(
|
|
144
|
+
validateSchema ||= ajv.compile(flat_config_schema_1.flatConfigSchema);
|
|
183
145
|
if (!validateSchema(config)) {
|
|
184
146
|
throw new Error(`ESLint configuration in ${source} is invalid:\n${formatErrors(
|
|
185
147
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
@@ -199,12 +161,5 @@ function validateConfigSchema(config, source) {
|
|
|
199
161
|
function validate(config, source, getAdditionalRule) {
|
|
200
162
|
validateConfigSchema(config, source);
|
|
201
163
|
validateRules(config.rules, source, getAdditionalRule);
|
|
202
|
-
validateEnvironment(config.env, source);
|
|
203
|
-
validateGlobals(config.globals, source);
|
|
204
|
-
for (const override of config.overrides ?? []) {
|
|
205
|
-
validateRules(override.rules, source, getAdditionalRule);
|
|
206
|
-
validateEnvironment(override.env, source);
|
|
207
|
-
validateGlobals(config.globals, source);
|
|
208
|
-
}
|
|
209
164
|
}
|
|
210
165
|
//# sourceMappingURL=config-validator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-validator.js","sourceRoot":"","sources":["../../src/utils/config-validator.ts"],"names":[],"mappings":";AAAA,4HAA4H;;;;;
|
|
1
|
+
{"version":3,"file":"config-validator.js","sourceRoot":"","sources":["../../src/utils/config-validator.ts"],"names":[],"mappings":";AAAA,4HAA4H;;;;;AA6N5H,4BAOC;AAlOD,0DAA6B;AAQ7B,sEAA2D;AAG3D,+BAAmC;AACnC,iEAAgE;AAChE,6DAAwD;AACxD,iEAA8D;AAC9D,qDAAkD;AAIlD,MAAM,GAAG,GAAG,IAAA,gBAAU,GAAE,CAAC;AACzB,MAAM,cAAc,GAAG,IAAI,OAAO,EAAmC,CAAC;AAEtE,IAAI,cAA4C,CAAC;AACjD,MAAM,WAAW,GAAG;IAClB,KAAK,EAAE,CAAC;IACR,IAAI,EAAE,CAAC;IACP,GAAG,EAAE,CAAC;CACE,CAAC;AAEX;;;;GAIG;AACH,SAAS,oBAAoB,CAAC,OAAyB;IACrD,MAAM,QAAQ,GAAG,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;IAC/D,MAAM,YAAY,GAChB,OAAO,QAAQ,KAAK,QAAQ;QAC1B,CAAC,CAAE,WAAW,CAAC,QAAQ,CAAC,WAAW,EAA2B,CAE9C;QAChB,CAAC,CAAE,QAAmB,CAA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,IAAI,CAAC,EAAE,CAAC,CAAC;AACd,CAAC;AAED;;;;;GAKG;AACH,SAAS,oBAAoB,CAC3B,MAAgC,EAChC,MAAc;IAEd,cAAc,KAAK,GAAG,CAAC,OAAO,CAAC,qCAAgB,CAAC,CAAC;IAEjD,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,EAAE,CAAC;QAC5B,MAAM,IAAI,KAAK,CACb,2BAA2B,MAAM,iBAAiB,YAAY;QAC5D,oEAAoE;QACpE,cAAc,CAAC,MAAO,CACvB,EAAE,CACJ,CAAC;IACJ,CAAC;IAED,mDAAmD;IACnD,IAAI,IAAA,+BAAc,EAAC,MAAM,EAAE,cAAc,CAAC,EAAE,CAAC;QAC3C,IAAA,6CAAsB,EAAC,MAAM,EAAE,4BAA4B,CAAC,CAAC;IAC/D,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,SAAgB,QAAQ,CACtB,MAAgC,EAChC,MAAc,EACd,iBAAoC;IAEpC,oBAAoB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACrC,aAAa,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,iBAAiB,CAAC,CAAC;AACzD,CAAC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { Processor, SharedConfig } from '@typescript-eslint/utils/ts-eslint';
|
|
2
|
+
interface ObjectPropertySchema<T = unknown> {
|
|
3
|
+
merge: string | ((a: T, b: T) => T);
|
|
4
|
+
validate: string | ((value: unknown) => asserts value is T);
|
|
5
|
+
}
|
|
6
|
+
export type ObjectLike = Record<string, unknown>;
|
|
7
|
+
type ConfigRules = Record<string, SharedConfig.RuleLevelAndOptions>;
|
|
8
|
+
export declare const flatConfigSchema: {
|
|
9
|
+
settings: {
|
|
10
|
+
merge<First extends ObjectLike, Second extends ObjectLike>(first?: First, second?: Second): First & Second;
|
|
11
|
+
validate: string;
|
|
12
|
+
};
|
|
13
|
+
linterOptions: {
|
|
14
|
+
schema: {
|
|
15
|
+
noInlineConfig: {
|
|
16
|
+
merge: string;
|
|
17
|
+
validate: string;
|
|
18
|
+
};
|
|
19
|
+
reportUnusedDisableDirectives: ObjectPropertySchema<SharedConfig.RuleLevel>;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
language: ObjectPropertySchema<`${string}/${string}`>;
|
|
23
|
+
languageOptions: {
|
|
24
|
+
merge(first?: ObjectLike, second?: ObjectLike): object;
|
|
25
|
+
validate: string;
|
|
26
|
+
};
|
|
27
|
+
processor: ObjectPropertySchema<Processor.LooseProcessorModule>;
|
|
28
|
+
plugins: {
|
|
29
|
+
merge(first?: ObjectLike, second?: ObjectLike): object;
|
|
30
|
+
validate(value: unknown): void;
|
|
31
|
+
};
|
|
32
|
+
rules: {
|
|
33
|
+
merge(first?: ConfigRules, second?: ConfigRules): ConfigRules;
|
|
34
|
+
validate(value: ConfigRules): void;
|
|
35
|
+
};
|
|
36
|
+
files: {
|
|
37
|
+
type: string;
|
|
38
|
+
items: {
|
|
39
|
+
type: string;
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
defaultFilenames: {
|
|
43
|
+
type: string;
|
|
44
|
+
properties: {
|
|
45
|
+
ts: {
|
|
46
|
+
type: string;
|
|
47
|
+
};
|
|
48
|
+
tsx: {
|
|
49
|
+
type: string;
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
required: string[];
|
|
53
|
+
additionalProperties: boolean;
|
|
54
|
+
};
|
|
55
|
+
dependencyConstraints: {
|
|
56
|
+
type: string;
|
|
57
|
+
additionalProperties: {
|
|
58
|
+
type: string;
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
$schema: {
|
|
62
|
+
type: string;
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
export {};
|
|
66
|
+
//# sourceMappingURL=flat-config-schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flat-config-schema.d.ts","sourceRoot":"","sources":["../../src/utils/flat-config-schema.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,SAAS,EACT,YAAY,EACb,MAAM,oCAAoC,CAAC;AAM5C,UAAU,oBAAoB,CAAC,CAAC,GAAG,OAAO;IACxC,KAAK,EAAE,MAAM,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;IACpC,QAAQ,EAAE,MAAM,GAAG,CAAC,CAAC,KAAK,EAAE,OAAO,KAAK,OAAO,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC;CAC7D;AAkTD,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AA2GjD,KAAK,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,mBAAmB,CAAC,CAAC;AA+GpE,eAAO,MAAM,gBAAgB;;cAnOrB,KAAK,SAAS,UAAU,EAAE,MAAM,SAAS,UAAU,UACzC,KAAK,WACJ,MAAM,GACpB,KAAK,GAAG,MAAM;;;;;;;;;;;;;;sBASJ,UAAU,WAAe,UAAU,GAAQ,MAAM;;;;;sBAkCjD,UAAU,WAAe,UAAU,GAAQ,MAAM;wBAoB9C,OAAO,GAAG,IAAI;;;sBAqDjB,WAAW,WAAe,WAAW,GAAQ,WAAW;wBAqDrD,WAAW,GAAG,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmGnC,CAAC"}
|
|
@@ -0,0 +1,455 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Forked from https://github.com/eslint/eslint/blob/4b23ffd6454cfb1a269430f5fe28e7d1c37b9d3e/lib/config/flat-config-schema.js
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.flatConfigSchema = void 0;
|
|
5
|
+
const severity_1 = require("./severity");
|
|
6
|
+
const ruleSeverities = new Map([
|
|
7
|
+
[0, 0],
|
|
8
|
+
['off', 0],
|
|
9
|
+
[1, 1],
|
|
10
|
+
['warn', 1],
|
|
11
|
+
[2, 2],
|
|
12
|
+
['error', 2],
|
|
13
|
+
]);
|
|
14
|
+
/**
|
|
15
|
+
* Check if a value is a non-null object.
|
|
16
|
+
* @param value The value to check.
|
|
17
|
+
* @returns `true` if the value is a non-null object.
|
|
18
|
+
*/
|
|
19
|
+
function isNonNullObject(value) {
|
|
20
|
+
// eslint-disable-next-line eqeqeq
|
|
21
|
+
return typeof value === 'object' && value !== null;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Check if a value is a non-null non-array object.
|
|
25
|
+
* @param value The value to check.
|
|
26
|
+
* @returns `true` if the value is a non-null non-array object.
|
|
27
|
+
*/
|
|
28
|
+
function isNonArrayObject(value) {
|
|
29
|
+
return isNonNullObject(value) && !Array.isArray(value);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Deeply merges two non-array objects.
|
|
33
|
+
* @param first The base object.
|
|
34
|
+
* @param second The overrides object.
|
|
35
|
+
* @param mergeMap Maps the combination of first and second arguments to a merged result.
|
|
36
|
+
* @returns An object with properties from both first and second.
|
|
37
|
+
*/
|
|
38
|
+
function deepMerge(first, second, mergeMap = new Map()) {
|
|
39
|
+
let secondMergeMap = mergeMap.get(first);
|
|
40
|
+
if (secondMergeMap) {
|
|
41
|
+
const result = secondMergeMap.get(second);
|
|
42
|
+
if (result) {
|
|
43
|
+
// If this combination of first and second arguments has been already visited, return the previously created result.
|
|
44
|
+
return result;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
secondMergeMap = new Map();
|
|
49
|
+
mergeMap.set(first, secondMergeMap);
|
|
50
|
+
}
|
|
51
|
+
/*
|
|
52
|
+
* First create a result object where properties from the second object
|
|
53
|
+
* overwrite properties from the first. This sets up a baseline to use
|
|
54
|
+
* later rather than needing to inspect and change every property
|
|
55
|
+
* individually.
|
|
56
|
+
*/
|
|
57
|
+
const result = {
|
|
58
|
+
...first,
|
|
59
|
+
...second,
|
|
60
|
+
};
|
|
61
|
+
delete result.__proto__; // don't merge own property "__proto__"
|
|
62
|
+
// Store the pending result for this combination of first and second arguments.
|
|
63
|
+
secondMergeMap.set(second, result);
|
|
64
|
+
for (const key of Object.keys(second)) {
|
|
65
|
+
// avoid hairy edge case
|
|
66
|
+
if (key === '__proto__' ||
|
|
67
|
+
!Object.prototype.propertyIsEnumerable.call(first, key)) {
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
const firstValue = first[key];
|
|
71
|
+
const secondValue = second[key];
|
|
72
|
+
if (isNonArrayObject(firstValue) && isNonArrayObject(secondValue)) {
|
|
73
|
+
result[key] = deepMerge(
|
|
74
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
75
|
+
firstValue,
|
|
76
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
77
|
+
secondValue, mergeMap);
|
|
78
|
+
}
|
|
79
|
+
else if (secondValue === undefined) {
|
|
80
|
+
result[key] = firstValue;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return result;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Normalizes the rule options config for a given rule by ensuring that
|
|
87
|
+
* it is an array and that the first item is 0, 1, or 2.
|
|
88
|
+
* @param ruleOptions The rule options config.
|
|
89
|
+
* @returns An array of rule options.
|
|
90
|
+
*/
|
|
91
|
+
function normalizeRuleOptions(ruleOptions) {
|
|
92
|
+
const finalOptions = Array.isArray(ruleOptions)
|
|
93
|
+
? ruleOptions.slice(0)
|
|
94
|
+
: [ruleOptions];
|
|
95
|
+
finalOptions[0] = ruleSeverities.get(finalOptions[0]);
|
|
96
|
+
return structuredClone(finalOptions);
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Determines if an object has any methods.
|
|
100
|
+
* @param object The object to check.
|
|
101
|
+
* @returns `true` if the object has any methods.
|
|
102
|
+
*/
|
|
103
|
+
function hasMethod(object) {
|
|
104
|
+
for (const key of Object.keys(object)) {
|
|
105
|
+
if (typeof object[key] === 'function') {
|
|
106
|
+
return true;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return false;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* The error type when a rule's options are configured with an invalid type.
|
|
113
|
+
*/
|
|
114
|
+
class InvalidRuleOptionsError extends Error {
|
|
115
|
+
messageTemplate;
|
|
116
|
+
messageData;
|
|
117
|
+
constructor(ruleId, value) {
|
|
118
|
+
super(`Key "${ruleId}": Expected severity of "off", 0, "warn", 1, "error", or 2.`);
|
|
119
|
+
this.messageTemplate = 'invalid-rule-options';
|
|
120
|
+
this.messageData = { ruleId, value };
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Validates that a value is a valid rule options entry.
|
|
125
|
+
* @param ruleId Rule name being configured.
|
|
126
|
+
* @param value The value to check.
|
|
127
|
+
* @throws {InvalidRuleOptionsError} If the value isn't a valid rule options.
|
|
128
|
+
*/
|
|
129
|
+
function assertIsRuleOptions(ruleId, value) {
|
|
130
|
+
if (typeof value !== 'string' &&
|
|
131
|
+
typeof value !== 'number' &&
|
|
132
|
+
!Array.isArray(value)) {
|
|
133
|
+
throw new InvalidRuleOptionsError(ruleId, value);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* The error type when a rule's severity is invalid.
|
|
138
|
+
*/
|
|
139
|
+
class InvalidRuleSeverityError extends Error {
|
|
140
|
+
messageTemplate;
|
|
141
|
+
messageData;
|
|
142
|
+
constructor(ruleId, value) {
|
|
143
|
+
super(`Key "${ruleId}": Expected severity of "off", 0, "warn", 1, "error", or 2.`);
|
|
144
|
+
this.messageTemplate = 'invalid-rule-severity';
|
|
145
|
+
this.messageData = { ruleId, value };
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Validates that a value is valid rule severity.
|
|
150
|
+
* @param ruleId Rule name being configured.
|
|
151
|
+
* @param value The value to check.
|
|
152
|
+
* @throws {InvalidRuleSeverityError} If the value isn't a valid rule severity.
|
|
153
|
+
*/
|
|
154
|
+
function assertIsRuleSeverity(ruleId, value) {
|
|
155
|
+
const severity = ruleSeverities.get(value);
|
|
156
|
+
if (severity === undefined) {
|
|
157
|
+
throw new InvalidRuleSeverityError(ruleId, value);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Validates that a given string is the form pluginName/objectName.
|
|
162
|
+
* @param value The string to check.
|
|
163
|
+
*/
|
|
164
|
+
function assertIsPluginMemberName(value) {
|
|
165
|
+
if (typeof value !== 'string' ||
|
|
166
|
+
!/[@a-z0-9-_$]+(?:\/(?:[a-z0-9-_$]+))+$/iu.test(value)) {
|
|
167
|
+
throw new TypeError(
|
|
168
|
+
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
|
|
169
|
+
`Expected string in the form "pluginName/objectName" but found "${value}".`);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Validates that a value is an object.
|
|
174
|
+
* @param value The value to check.
|
|
175
|
+
*/
|
|
176
|
+
function assertIsObject(value) {
|
|
177
|
+
if (!isNonNullObject(value)) {
|
|
178
|
+
throw new TypeError('Expected an object.');
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* The error type when there's an eslintrc-style options in a flat config.
|
|
183
|
+
*/
|
|
184
|
+
class IncompatibleKeyError extends Error {
|
|
185
|
+
messageTemplate;
|
|
186
|
+
messageData;
|
|
187
|
+
/**
|
|
188
|
+
* @param key The invalid key.
|
|
189
|
+
*/
|
|
190
|
+
constructor(key) {
|
|
191
|
+
super('This appears to be in eslintrc format rather than flat config format.');
|
|
192
|
+
this.messageTemplate = 'eslintrc-incompat';
|
|
193
|
+
this.messageData = { key };
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* The error type when there's an eslintrc-style plugins array found.
|
|
198
|
+
*/
|
|
199
|
+
class IncompatiblePluginsError extends Error {
|
|
200
|
+
messageTemplate;
|
|
201
|
+
messageData;
|
|
202
|
+
constructor(plugins) {
|
|
203
|
+
super('This appears to be in eslintrc format (array of strings) rather than flat config format (object).');
|
|
204
|
+
this.messageTemplate = 'eslintrc-plugins';
|
|
205
|
+
this.messageData = { plugins };
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
const booleanSchema = {
|
|
209
|
+
merge: 'replace',
|
|
210
|
+
validate: 'boolean',
|
|
211
|
+
};
|
|
212
|
+
const ALLOWED_SEVERITIES = new Set(['error', 'warn', 'off', 2, 1, 0]);
|
|
213
|
+
const disableDirectiveSeveritySchema = {
|
|
214
|
+
merge(first, second) {
|
|
215
|
+
const value = second ?? first;
|
|
216
|
+
if (typeof value === 'boolean') {
|
|
217
|
+
return value ? 'warn' : 'off';
|
|
218
|
+
}
|
|
219
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
220
|
+
return (0, severity_1.normalizeSeverityToNumber)(value);
|
|
221
|
+
},
|
|
222
|
+
validate(value) {
|
|
223
|
+
if (!(ALLOWED_SEVERITIES.has(value) ||
|
|
224
|
+
typeof value === 'boolean')) {
|
|
225
|
+
throw new TypeError('Expected one of: "error", "warn", "off", 0, 1, 2, or a boolean.');
|
|
226
|
+
}
|
|
227
|
+
},
|
|
228
|
+
};
|
|
229
|
+
const deepObjectAssignSchema = {
|
|
230
|
+
merge(first = {}, second = {}) {
|
|
231
|
+
return deepMerge(first, second);
|
|
232
|
+
},
|
|
233
|
+
validate: 'object',
|
|
234
|
+
};
|
|
235
|
+
const languageOptionsSchema = {
|
|
236
|
+
merge(first = {}, second = {}) {
|
|
237
|
+
const result = deepMerge(first, second);
|
|
238
|
+
for (const [key, value] of Object.entries(result)) {
|
|
239
|
+
/*
|
|
240
|
+
* Special case: Because the `parser` property is an object, it should
|
|
241
|
+
* not be deep merged. Instead, it should be replaced if it exists in
|
|
242
|
+
* the second object. To make this more generic, we just check for
|
|
243
|
+
* objects with methods and replace them if they exist in the second
|
|
244
|
+
* object.
|
|
245
|
+
*/
|
|
246
|
+
if (isNonArrayObject(value)) {
|
|
247
|
+
if (hasMethod(value)) {
|
|
248
|
+
result[key] = second[key] ?? first[key];
|
|
249
|
+
continue;
|
|
250
|
+
}
|
|
251
|
+
// for other objects, make sure we aren't reusing the same object
|
|
252
|
+
result[key] = { ...result[key] };
|
|
253
|
+
continue;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
return result;
|
|
257
|
+
},
|
|
258
|
+
validate: 'object',
|
|
259
|
+
};
|
|
260
|
+
const languageSchema = {
|
|
261
|
+
merge: 'replace',
|
|
262
|
+
validate: assertIsPluginMemberName,
|
|
263
|
+
};
|
|
264
|
+
const pluginsSchema = {
|
|
265
|
+
merge(first = {}, second = {}) {
|
|
266
|
+
const keys = new Set([...Object.keys(first), ...Object.keys(second)]);
|
|
267
|
+
const result = {};
|
|
268
|
+
// manually validate that plugins are not redefined
|
|
269
|
+
for (const key of keys) {
|
|
270
|
+
// avoid hairy edge case
|
|
271
|
+
if (key === '__proto__') {
|
|
272
|
+
continue;
|
|
273
|
+
}
|
|
274
|
+
if (key in first && key in second && first[key] !== second[key]) {
|
|
275
|
+
throw new TypeError(`Cannot redefine plugin "${key}".`);
|
|
276
|
+
}
|
|
277
|
+
result[key] = second[key] || first[key];
|
|
278
|
+
}
|
|
279
|
+
return result;
|
|
280
|
+
},
|
|
281
|
+
validate(value) {
|
|
282
|
+
// first check the value to be sure it's an object
|
|
283
|
+
if (value == null || typeof value !== 'object') {
|
|
284
|
+
throw new TypeError('Expected an object.');
|
|
285
|
+
}
|
|
286
|
+
// make sure it's not an array, which would mean eslintrc-style is used
|
|
287
|
+
if (Array.isArray(value)) {
|
|
288
|
+
throw new IncompatiblePluginsError(value);
|
|
289
|
+
}
|
|
290
|
+
// second check the keys to make sure they are objects
|
|
291
|
+
for (const key of Object.keys(value)) {
|
|
292
|
+
// avoid hairy edge case
|
|
293
|
+
if (key === '__proto__') {
|
|
294
|
+
continue;
|
|
295
|
+
}
|
|
296
|
+
if (value[key] == null ||
|
|
297
|
+
typeof value[key] !== 'object') {
|
|
298
|
+
throw new TypeError(`Key "${key}": Expected an object.`);
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
},
|
|
302
|
+
};
|
|
303
|
+
const processorSchema = {
|
|
304
|
+
merge: 'replace',
|
|
305
|
+
validate(value) {
|
|
306
|
+
if (typeof value === 'string') {
|
|
307
|
+
assertIsPluginMemberName(value);
|
|
308
|
+
}
|
|
309
|
+
else if (value && typeof value === 'object') {
|
|
310
|
+
if (typeof value.preprocess !==
|
|
311
|
+
'function' ||
|
|
312
|
+
typeof value.postprocess !==
|
|
313
|
+
'function') {
|
|
314
|
+
throw new TypeError('Object must have a preprocess() and a postprocess() method.');
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
else {
|
|
318
|
+
throw new TypeError('Expected an object or a string.');
|
|
319
|
+
}
|
|
320
|
+
},
|
|
321
|
+
};
|
|
322
|
+
const rulesSchema = {
|
|
323
|
+
merge(first = {}, second = {}) {
|
|
324
|
+
const result = {
|
|
325
|
+
...first,
|
|
326
|
+
...second,
|
|
327
|
+
};
|
|
328
|
+
for (const ruleId of Object.keys(result)) {
|
|
329
|
+
try {
|
|
330
|
+
// avoid hairy edge case
|
|
331
|
+
if (ruleId === '__proto__') {
|
|
332
|
+
delete result.__proto__;
|
|
333
|
+
continue;
|
|
334
|
+
}
|
|
335
|
+
result[ruleId] = normalizeRuleOptions(result[ruleId]);
|
|
336
|
+
/*
|
|
337
|
+
* If either rule config is missing, then the correct
|
|
338
|
+
* config is already present and we just need to normalize
|
|
339
|
+
* the severity.
|
|
340
|
+
*/
|
|
341
|
+
if (!(ruleId in first) || !(ruleId in second)) {
|
|
342
|
+
continue;
|
|
343
|
+
}
|
|
344
|
+
const firstRuleOptions = normalizeRuleOptions(first[ruleId]);
|
|
345
|
+
const secondRuleOptions = normalizeRuleOptions(second[ruleId]);
|
|
346
|
+
/*
|
|
347
|
+
* If the second rule config only has a severity (length of 1),
|
|
348
|
+
* then use that severity and keep the rest of the options from
|
|
349
|
+
* the first rule config.
|
|
350
|
+
*/
|
|
351
|
+
if (secondRuleOptions.length === 1) {
|
|
352
|
+
result[ruleId] = [secondRuleOptions[0], ...firstRuleOptions.slice(1)];
|
|
353
|
+
continue;
|
|
354
|
+
}
|
|
355
|
+
/*
|
|
356
|
+
* In any other situation, then the second rule config takes
|
|
357
|
+
* precedence. That means the value at `result[ruleId]` is
|
|
358
|
+
* already correct and no further work is necessary.
|
|
359
|
+
*/
|
|
360
|
+
}
|
|
361
|
+
catch (ex) {
|
|
362
|
+
throw new Error(`Key "${ruleId}": ${ex.message}`, {
|
|
363
|
+
cause: ex,
|
|
364
|
+
});
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
return result;
|
|
368
|
+
},
|
|
369
|
+
validate(value) {
|
|
370
|
+
assertIsObject(value);
|
|
371
|
+
/*
|
|
372
|
+
* We are not checking the rule schema here because there is no
|
|
373
|
+
* guarantee that the rule definition is present at this point. Instead
|
|
374
|
+
* we wait and check the rule schema during the finalization step
|
|
375
|
+
* of calculating a config.
|
|
376
|
+
*/
|
|
377
|
+
for (const ruleId of Object.keys(value)) {
|
|
378
|
+
// avoid hairy edge case
|
|
379
|
+
if (ruleId === '__proto__') {
|
|
380
|
+
continue;
|
|
381
|
+
}
|
|
382
|
+
const ruleOptions = value[ruleId];
|
|
383
|
+
assertIsRuleOptions(ruleId, ruleOptions);
|
|
384
|
+
if (Array.isArray(ruleOptions)) {
|
|
385
|
+
assertIsRuleSeverity(ruleId, ruleOptions[0]);
|
|
386
|
+
}
|
|
387
|
+
else {
|
|
388
|
+
assertIsRuleSeverity(ruleId, ruleOptions);
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
},
|
|
392
|
+
};
|
|
393
|
+
/**
|
|
394
|
+
* Creates a schema that always throws an error. Useful for warning
|
|
395
|
+
* about eslintrc-style keys.
|
|
396
|
+
* @param key The eslintrc key to create a schema for.
|
|
397
|
+
*/
|
|
398
|
+
function createEslintrcErrorSchema(key) {
|
|
399
|
+
return {
|
|
400
|
+
merge: 'replace',
|
|
401
|
+
validate() {
|
|
402
|
+
throw new IncompatibleKeyError(key);
|
|
403
|
+
},
|
|
404
|
+
};
|
|
405
|
+
}
|
|
406
|
+
const eslintrcKeys = [
|
|
407
|
+
'env',
|
|
408
|
+
'extends',
|
|
409
|
+
'globals',
|
|
410
|
+
'ignorePatterns',
|
|
411
|
+
'noInlineConfig',
|
|
412
|
+
'overrides',
|
|
413
|
+
'parser',
|
|
414
|
+
'parserOptions',
|
|
415
|
+
'reportUnusedDisableDirectives',
|
|
416
|
+
'root',
|
|
417
|
+
];
|
|
418
|
+
exports.flatConfigSchema = {
|
|
419
|
+
$schema: { type: 'string' },
|
|
420
|
+
// Original ESLint schemas from flat-config-schema.js
|
|
421
|
+
// eslintrc-style keys that should always error
|
|
422
|
+
...Object.fromEntries(eslintrcKeys.map(key => [key, createEslintrcErrorSchema(key)])),
|
|
423
|
+
// flat config keys
|
|
424
|
+
settings: deepObjectAssignSchema,
|
|
425
|
+
linterOptions: {
|
|
426
|
+
schema: {
|
|
427
|
+
noInlineConfig: booleanSchema,
|
|
428
|
+
reportUnusedDisableDirectives: disableDirectiveSeveritySchema,
|
|
429
|
+
},
|
|
430
|
+
},
|
|
431
|
+
language: languageSchema,
|
|
432
|
+
languageOptions: languageOptionsSchema,
|
|
433
|
+
processor: processorSchema,
|
|
434
|
+
plugins: pluginsSchema,
|
|
435
|
+
rules: rulesSchema,
|
|
436
|
+
// not in ESLint source, but seemingly relevant?
|
|
437
|
+
files: { type: 'array', items: { type: 'string' } },
|
|
438
|
+
// @typescript-eslint/rule-tester extensions
|
|
439
|
+
defaultFilenames: {
|
|
440
|
+
type: 'object',
|
|
441
|
+
properties: {
|
|
442
|
+
ts: { type: 'string' },
|
|
443
|
+
tsx: { type: 'string' },
|
|
444
|
+
},
|
|
445
|
+
required: ['ts', 'tsx'],
|
|
446
|
+
additionalProperties: false,
|
|
447
|
+
},
|
|
448
|
+
dependencyConstraints: {
|
|
449
|
+
type: 'object',
|
|
450
|
+
additionalProperties: {
|
|
451
|
+
type: 'string',
|
|
452
|
+
},
|
|
453
|
+
},
|
|
454
|
+
};
|
|
455
|
+
//# sourceMappingURL=flat-config-schema.js.map
|