Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@types/eslint allow non-ESTree AST for parsers in flat configs #68232

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 13 additions & 1 deletion types/eslint/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1179,6 +1179,18 @@ export namespace Linter {
messages: LintMessage[];
}

// Temporarily loosen type for just flat config files (see #68232)
type FlatConfigParserModule =
& Omit<ParserModule, "parseForESLint">
& ({
parse(text: string, options?: any): unknown;
} | {
parseForESLint(text: string, options?: any): Omit<ESLintParseResult, "ast" | "scopeManager"> & {
Logicer16 marked this conversation as resolved.
Show resolved Hide resolved
ast: unknown;
scopeManager?: unknown;
};
});

type ParserModule =
& ESLint.ObjectMetaProperties
& (
Expand Down Expand Up @@ -1252,7 +1264,7 @@ export namespace Linter {
* An object containing a parse() or parseForESLint() method.
* If not configured, the default ESLint parser (Espree) will be used.
*/
parser?: ParserModule;
parser?: FlatConfigParserModule;

/**
* An object specifying additional options that are passed directly to the
Expand Down