Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Recommended settings set sourceType to module #118

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

Closed
marekdedic opened this issue Jan 22, 2019 · 5 comments
Closed

Recommended settings set sourceType to module #118

marekdedic opened this issue Jan 22, 2019 · 5 comments
Labels
enhancement New feature or request package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin

Comments

@marekdedic
Copy link
Contributor

The plugin:@typescript-eslint/recommended config sets

"parserOptions": {
  "sourceType": "module"
}

Might I ask why override the eslint default? I've stumbled upon this while trying to find out why no-unused-vars was throwing false positives for functions exported with /* exported fnName */ - given this override in the recommended config, it makes sense of course, but I had to go through all the settings to find out why it works fine if I enable only the rule and throws false positives if I extend the whole recommended config...

I get that modules are The Right Way™ now, but not everybody uses them - overriding the eslint default seems like a poor choice to me, because it silently changes the behaviour of eslint without the user knowing why if they don't actually go into the recommended config file.

Versions

package version
@typescript-eslint/eslint-plugin 1.0.0
@typescript-eslint/parser 1.0.0
TypeScript 3.2.4
ESLint 5.12.1
node 11.7.0
npm 6.6.0
@marekdedic marekdedic added package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for team members to take a look labels Jan 22, 2019
@bradzacher bradzacher added question Questions! (i.e. not a bug / enhancment / documentation) and removed triage Waiting for team members to take a look labels Jan 22, 2019
@bradzacher
Copy link
Member

bradzacher commented Jan 22, 2019

When we put the recommended config up for debate we erred on the side of what's the most common / correct use case - creating minimal config for the majority with overrides for the minority.

The majority use case is for sourceType: module, so if we don't set that in our recommended settings, then the majority of recommended users would have to manually add that setting.

TBH it's the first time that I have seen a case that doesn't work with sourceType: module (I've always set it on every single project I've worked on), so my preference would be to keep it.

It's certainly up for discussion though!
If enough people feel strongly against this setting, we can remove it.

@platinumazure
Copy link
Contributor

We could also export multiple configs that are "recommended", one for scripts and one for modules (or just one with the module override and one without). As it is, having one recommended config be opinionated feels a little weird (to me).

@bradzacher
Copy link
Member

What's recommended is always going to be subjective to some degree 😄

The recommended ruleset we eventually landed on was based on two things:

  1. amalgamating several existing configs from the community
  2. what the TS team does within their documentation

bradzacher/eslint-plugin-typescript#144

Definitely not opposed to exporting more configs though.
I think there is real value in having a number of default configs to make adoption easier.

@marekdedic
Copy link
Contributor Author

marekdedic commented Jan 22, 2019

Hi, thanks for the responses.

yes, this is definitely subjective. My point of view is that I thought of the recommended settings as a parallel to the recommended settings from eslint itself - just a set of rules to be enabled, that most people would agree are useful, with some of the more obscure onea left out. Therefore, I was also surprised that it set the parser, but that's obviously useful for everyone using the plugin.

Anyway, I think it is without question that if it is left this way, it should be documented somewhere (maybe it is and I'm just blind...)

@bradzacher
Copy link
Member

you're not blind - It's not documented because it's a rare case that hasn't been considered before.

@bradzacher bradzacher added enhancement New feature or request and removed question Questions! (i.e. not a bug / enhancment / documentation) labels Jan 23, 2019
armanio123 pushed a commit to armanio123/typescript-eslint that referenced this issue Jan 24, 2019
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 9, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin
Projects
None yet
Development

No branches or pull requests

3 participants