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

fix: languageOptions.parser should be an object #220

Merged
merged 3 commits into from
Aug 4, 2023
Merged
Changes from 1 commit
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
Prev Previous commit
refactor: manually define ParserModule
  • Loading branch information
NotEvenANeko committed Aug 3, 2023
commit d44a4e5353453f06ad434817e7b1993008ba2f30
22 changes: 18 additions & 4 deletions src/flat-config/language-options.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
import type { Linter } from 'eslint';
import type { EcmaVersion, ParserOptions, SourceType } from '../parser-options';
import type {
EcmaVersion,
Parser,
ParserOptions,
SourceType,
} from '../parser-options';

export type ParserModule =
| {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
parse(text: string, options?: any): any;
}
| {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
parseForESLint(text: string, options?: any): any;
};

/**
* An object containing settings related to how JavaScript is configured for linting
Expand Down Expand Up @@ -33,13 +47,13 @@ export interface LanguageOptions {
>;

/**
* An object containing a parse() or parseForESLint() method.
* Either an object containing a `parse()` method or a string indicating the name of a parser inside of a plugin (i.e., `"pluginName/parserName"`).
*
* @default "@/espree"
*
* @see [Configuring a custom parser and its options](https://eslint.org/docs/latest/user-guide/configuring/configuration-files-new#configuring-a-custom-parser-and-its-options)
*/
parser?: Linter.ParserModule;
parser?: Parser | ParserModule;

/**
* An object specifying additional options that are passed directly to the `parser()` method on the parser. The available options are parser-dependent.
Expand Down