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

Add --ext to eslintrc or other config files #11223

Closed
UriConMur opened this issue Dec 30, 2018 · 3 comments
Closed

Add --ext to eslintrc or other config files #11223

UriConMur opened this issue Dec 30, 2018 · 3 comments
Labels
archived due to age This issue has been archived; please open a new issue for any further discussion core Relates to ESLint's core APIs and features enhancement This change enhances an existing feature of ESLint triage An ESLint team member will look at this issue soon

Comments

@UriConMur
Copy link

The version of ESLint you are using.
5.6.0

The problem you want to solve.
Add extensions to eslintrc

Main problem is that I would like to lint js and jsx.

I saw that there was a pull request closed nd it seems to be solved, but I think it is not.

Pull Request
#8515

Mysterious line only adding js as default :$
https://github.com/eslint/eslint/blob/master/conf/default-cli-options.js#L15

Your take on the correct solution to problem.
Yes,

I as was checking we just need to make some small changes but I would like to check with you first.

  1. Add new cli parameter to config-schema
const baseConfigProperties = {
    env: { type: "object" },
    ext: { type: "array" }, // ++ This one
    globals: { type: "object" },
    parser: { type: ["string", "null"] },
    parserOptions: { type: "object" },
    plugins: { type: "array" },
    rules: { type: "object" },
    settings: { type: "object" },

    ecmaFeatures: { type: "object" } // deprecated; logs a warning when used
};

after that we need to add this to the CLI-Engine constructor

this.config = new Config(this.options, this.linter);

if (this.config.options.useEslintrc) {
      const fileConfig = this.getConfigForFile();
      this.options.extensions = fileConfig.ext;
}

Inside of this.getConfigForFile() we call getConfig() from config.js file, we might need to add this conditional so we can have this parameter ext available in the config

if(config.ext) {
     this.options = {
        ...this.options,
        'extensions': config.ext 
     }
}

This way now we can have a correct list of files to execute according to this param.
executeOnFiles() in file cli.engine.js

I think this was the best way possible, but please let me know if there is an easier way to do it.

Are you willing to submit a pull request to implement this change?
sure! without problem ;)

@UriConMur UriConMur added core Relates to ESLint's core APIs and features enhancement This change enhances an existing feature of ESLint triage An ESLint team member will look at this issue soon labels Dec 30, 2018
@mysticatea
Copy link
Member

Thank you for this proposal.

However, I don't think it's possible.

  1. ESLint finds target files.
  2. It determines config files for each target file. This starts with the directory the target file exists, then traverses ancestor directories. It merges all eslintrc files which were found.

ESLint reads eslintrc files after the target files found. Therefore, we cannot write settings which change target files into eslintrc files.

@UriConMur
Copy link
Author

I see, great to know! Thank you so much for the follow up ;)

@ilyavolodin
Copy link
Member

This request came up multiple times before. Unfortunately, as @mysticatea explained, it's not really possible to do, especially, when you add complexity of shareable configs and cascading into the picture. So I'm going to close this issue, sine we can't address this.

@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Jun 29, 2019
@eslint-deprecated eslint-deprecated bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Jun 29, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
archived due to age This issue has been archived; please open a new issue for any further discussion core Relates to ESLint's core APIs and features enhancement This change enhances an existing feature of ESLint triage An ESLint team member will look at this issue soon
Projects
None yet
Development

No branches or pull requests

3 participants