8000 Docs: Mention sourceType in parser/parserOptions · Issue #11016 · typescript-eslint/typescript-eslint · GitHub
[go: up one dir, main page]

Skip to content

Docs: Mention sourceType in parser/parserOptions #11016

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

Open
2 tasks done
JoshuaKGoldberg opened this issue Mar 31, 2025 · 2 comments
Open
2 tasks done

Docs: Mention sourceType in parser/parserOptions #11016

JoshuaKGoldberg opened this issue Mar 31, 2025 · 2 comments
Labels
documentation Documentation ("docs") that needs adding/updating team assigned A member of the typescript-eslint team should work on this.

Comments

@JoshuaKGoldberg
Copy link
Member

Before You File a Documentation Request Please Confirm You Have Done The Following...

Suggested Changes

Coming over from eslint/eslint#19563 (comment) -> #11012: sourceType is an optional property for the parser's parserOptions:

sourceType?: SourceType | undefined;

It's not mentioned anywhere on https://typescript-eslint.io/packages/parser. The page's https://typescript-eslint.io/packages/parser#configuration docs mention:

The following additional configuration options are available by specifying them in [`parserOptions`](https://eslint.org/docs/user-guide/configuring/language-options#specifying-parser-options) in your ESLint configuration file.

...which seems to imply these options are a superset of ESLint core's in https://eslint.org/docs/latest/use/configure/language-options#specifying-parser-options, maybe? But I don't think that's extremely clear. I think it'd be good to explicitly mention at least sourceType in the docs.

Affected URL(s)

https://typescript-eslint.io/packages/parser

Additional Info

Question: are there other properties end users / rule testers might need?

💖

@JoshuaKGoldberg JoshuaKGoldberg added documentation Documentation ("docs") that needs adding/updating triage Waiting for team members to take a look labels Mar 31, 2025
@bradzacher
Copy link
Member

The reason we don't mention it is because broadly speaking it doesn't do anything for us.
For ESLint it matters deeply because the espree parser will reject ESM if you don't set sourceType: module.

But TS will automatically handle it all so it doesn't matter.
It does tweak some stuff in the scope analyser but IIRC this shouldn't impact many rules, if any -- really.


The docs page isn't the source of truth for what can be configured -- they're a summarised subset that covers the majority of usecases.

For example whilst technically /parser accepts tokens?: boolean and range?: boolean we do not include them in the docs because (a) the parser isn't intended to be called programmatically and (b) a user doesn't set these in their ESLint config as ESLint passes them automatically.

Similarly errorOnTypeScriptSyntacticAndSemanticIssues and errorOnUnknownASTType aren't documented because we don't really want people to use them except for super rare edge cases -- so for 99.999% of users they're just cruft.

@JoshuaKGoldberg
Copy link
Member Author

The docs page isn't the source of truth for what can be configured -- they're a summarised subset that covers the majority of usecases.

Shall we mention this in the docs page, then? I've written docs on that page myself and wasn't clear on this 😄

@JoshuaKGoldberg JoshuaKGoldberg added team assigned A member of the typescript-eslint team should work on this. and removed triage Waiting for team members to take a look labels May 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Documentation ("docs") that needs adding/updating team assigned A member of the typescript-eslint team should work on this.
Projects
None yet
Development

No branches or pull requests

2 participants
0