Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork2.8k
What's up with the twoparserOptions?#6830
-
I'm new to ESLint. There appear to be two If I set As a side note, |
BetaWas this translation helpful?Give feedback.
All reactions
👍 1
Replies: 4 comments 3 replies
-
Some context:@Jutanium and I paired on Twitch to set up a new Astro+Solid+TypeScript project with linting. The typescript-eslint setup steps were mostly smooth untilTyped Linting (#6826,#6828). This was another issue we had that I asked Dan to start as a discussion here: the two config values weren't intuitive in our pair, and I think it'd be good to discuss if we can make it simpler and/or more obvious what things do. For example, if the user specifies |
BetaWas this translation helpful?Give feedback.
All reactions
-
Both of these options are described in the getting started guide and the above docs sections are linked as well (though the links are at different points in the guide)
What would be the preferred way to document them aside from what's already in the guide? |
BetaWas this translation helpful?Give feedback.
All reactions
-
@bradzacher I think the direction here is more: just reading a config, they're not very intuitive. So no matter how much we document them, it's not ideal. A goal beyond documenting them could be ideating a way to set up the options that makes more sense on the surface. |
BetaWas this translation helpful?Give feedback.
All reactions
-
I guess my question would be "why does it matter if a config option is meaningless without the docs?" - config is an inherently complex thing - so it's kind of expected that either "you know what you're doing" or that you're referencing the docs. As an example - TS project references are configured via the Not saying we can't improve at all! I'm just trying to gauge the scope and thinking. |
BetaWas this translation helpful?Give feedback.
All reactions
👍 1
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
Why are there two? Well until a month or so ago you had no option but to tell us the explicit paths to your tsconfig(s). Unfortunately ESLint doesn't tell the parser the path to the config file for various reasons[1] so the only paths we explicitly know about are (1) the CWD and (2) the path to the file currently being linted. (2) is obviously useless as a marker to resolve a relative path against so we have to leverage (1) the CWD. The problem you run into is that the CWD is dynamic! It's not uncommon to Why do we allow relative paths at all? A few reasons reasons:
With the new Worth noting that you may not realise it but there's actually THREE parser options for type-aware linting - the third being I don't think there's many (if any) people that change this from its default of "ignore [1] reasons ESLint doesn't tell the parser about the config file path:
The cascading and overriding means that ultimately ESLint does not keep track of where the final value for each property came from - it just knows the final value. So knowing one of the possible config paths is technically meaningless in the world of ESLint! |
BetaWas this translation helpful?Give feedback.
All reactions
-
Some fun facts on the history of the names - you can trace the names
|
BetaWas this translation helpful?Give feedback.
All reactions
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
In regards to the best path forwards...
Personally I don't think we should make such a change - I think people shouldalways provide We do have If I had to specify a "north star" - I would probably want to introduce a state like this to group the config: typePath=RelativePath|AbsolutePath|GlobPath;interfaceExplicitProjectConfig{/** Paths to the tsconfigs to explicitly load for type information */tsconfigPaths:Path[];/** Paths to ignore when resolving globs from `tsconfigPaths` */globIgnoreList?:Path[];/** Absolute path to the project root to use when resolving relative paths */relativeRootDir?:AbsolutePath;}interfaceAutomaticProjectConfig{/** Explicitly opt-in to the automatic resolution and also a disjoin union field??? */automatic:true;/** Absolute path to the project root to stop traversing at when looking for tsconfigs */traversalRootDir:AbsolutePath;}interfaceParserOptions{/** * `null` allows people to explicitly opt folders out of type-aware linting * for specific paths. It allows users to write configs as "type-aware-first" and * have non-type-aware linting being the edge case applied via `overrides` by * the config `plugin:@typescript-eslint/disable-type-checked` */project:ExplicitProjectConfig|AutomaticProjectConfig|null;} |
BetaWas this translation helpful?Give feedback.
