mirror of
https://github.com/chenasraf/DefinitelyTyped.git
synced 2026-05-18 01:49:01 +00:00
Update eslint.FlatConfig to remove string alternatives from files and ignores and expand type to cover all accepted values (functions and nested arrays) (#65530)
This commit is contained in:
@@ -1007,4 +1007,32 @@ ruleTester.run('simple-valid-test', rule, {
|
||||
}
|
||||
});
|
||||
|
||||
(): Linter.FlatConfig => ({ files: ["abc"] });
|
||||
(): Linter.FlatConfig => ({ files: [(path) => false] });
|
||||
(): Linter.FlatConfig => ({ files: [["abc"]]});
|
||||
(): Linter.FlatConfig => ({ files: [[(path) => false]] });
|
||||
(): Linter.FlatConfig => ({ files: [["abc", (path) => false]] });
|
||||
(): Linter.FlatConfig => ({ files: ["abc", (path) => false, ["abc"], [(path) => false], ["abc", (path) => false]] });
|
||||
|
||||
// @ts-expect-error // Second level of nesting is not allowed
|
||||
(): Linter.FlatConfig => ({ files: ["abc", (path) => false, ["abc"], [(path) => false], ["abc", (path) => false], [["abc"], [(path) => false]]] });
|
||||
|
||||
(): Linter.FlatConfig => ({ ignores: ["abc"] });
|
||||
(): Linter.FlatConfig => ({ ignores: [(path) => false] });
|
||||
(): Linter.FlatConfig => ({ ignores: ["abc", (path) => false] });
|
||||
|
||||
// @ts-expect-error // No nesting
|
||||
(): Linter.FlatConfig => ({ ignores: ["abc", (path) => false, ["abc"], [(path) => false], ["abc", (path) => false]] });
|
||||
|
||||
// @ts-expect-error // Must be an array
|
||||
(): Linter.FlatConfig => ({ files: "abc" });
|
||||
|
||||
// @ts-expect-error // Must be an array
|
||||
(): Linter.FlatConfig => ({ ignores: "abc" });
|
||||
|
||||
// The following _should_ be an error, but we can't enforce on consumers
|
||||
// as it requires exactOptionalPropertyTypes: true
|
||||
// (): Linter.FlatConfig => ({ files: undefined });
|
||||
// (): Linter.FlatConfig => ({ ignores: undefined });
|
||||
|
||||
//#endregion
|
||||
|
||||
7
types/eslint/index.d.ts
vendored
7
types/eslint/index.d.ts
vendored
@@ -933,19 +933,22 @@ export namespace Linter {
|
||||
preprocess?(text: string, filename: string): T[];
|
||||
postprocess?(messages: LintMessage[][], filename: string): LintMessage[];
|
||||
}
|
||||
|
||||
type FlatConfigFileSpec = string | ((filePath: string) => boolean);
|
||||
|
||||
interface FlatConfig {
|
||||
/**
|
||||
* An array of glob patterns indicating the files that the configuration
|
||||
* object should apply to. If not specified, the configuration object applies
|
||||
* to all files
|
||||
*/
|
||||
files?: string | string[];
|
||||
files?: Array<FlatConfigFileSpec | FlatConfigFileSpec[]>;
|
||||
/**
|
||||
* An array of glob patterns indicating the files that the configuration
|
||||
* object should not apply to. If not specified, the configuration object
|
||||
* applies to all files matched by files
|
||||
*/
|
||||
ignores?: string | string[];
|
||||
ignores?: FlatConfigFileSpec[];
|
||||
/**
|
||||
* An object containing settings related to how JavaScript is configured for
|
||||
* linting.
|
||||
|
||||
Reference in New Issue
Block a user