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

Overrides not working as intended #11934

Closed
tHBp opened this issue Jul 3, 2019 · 4 comments
Closed

Overrides not working as intended #11934

tHBp opened this issue Jul 3, 2019 · 4 comments
Labels
archived due to age This issue has been archived; please open a new issue for any further discussion bug ESLint is working incorrectly evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion

Comments

@tHBp
Copy link

tHBp commented Jul 3, 2019

Tell us about your environment

  • ESLint Version: 5.16.0
  • Node Version: 10.2.0
  • npm Version: 6.6.0

What parser (default, Babel-ESLint, etc.) are you using? default

Please show your full configuration:

Configuration
{
    "rules": {
        "quote-props": ["error", "as-needed"]
    },
    "overrides": [{
        "files": ["**/someDirectoryName/**"],
        "rules": {
            "quote-props": 0
        }
    }]
}

What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.

// someDirectoryName/dummy-file.js
var a = {
  "dummyString": "Dummy String value"
}

Command:

eslint -c .eslintrc.json someDirectoryName/

Overrides are not applied. Tried "files": ["**/someDirectoryName/dummy-file.js"] and "files": ["someDirectoryName/dummy-file.js"] too. Both didn't work.

However, it works if I specify the file name only, like below:

"overrides": [{
        "files": ["dummy-file.js"]

Let me know if more information is needed.

@tHBp tHBp added bug ESLint is working incorrectly triage An ESLint team member will look at this issue soon labels Jul 3, 2019
@mysticatea
Copy link
Member

Thank you for your report.

However, I couldn't reproduce it.

~\dev\sandbox> cat .\.eslintrc.js
module.exports = {
    "root": true,
    "rules": {
        "quote-props": ["error", "as-needed"]
    },
    "overrides": [{
        "files": ["**/someDirectoryName/**"],
        "rules": {
            "quote-props": 1
        }
    }]
}
~\dev\sandbox> cat .\someDirectoryName\dummy-file.js
var a = {
    "dummyString": "Dummy String value"
  }
~\dev\sandbox> eslint .\someDirectoryName\

C:\Users\t-nagashima.AD\dev\sandbox\someDirectoryName\dummy-file.js
  2:5  warning  Unnecessarily quoted property 'dummyString' found  quote-props

✖ 1 problem (0 errors, 1 warning)
  0 errors and 1 warning potentially fixable with the `--fix` option.

~\dev\sandbox>

(I just tweaked the overrides setting as a warning to clarify the result. The result is a warning instead of an error, so the overrides setting was applied.)

Would you check your case again or would you provide a repro repository?

@mysticatea mysticatea added evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion and removed triage An ESLint team member will look at this issue soon labels Jul 3, 2019
@tHBp
Copy link
Author

tHBp commented Jul 3, 2019

Hi @mysticatea

Thanks for quick revert.

Can you try putting configuration file in some other directory as below:

eslint -c someOtherDirectory/.eslintrc.json someDirectoryName/

@mysticatea
Copy link
Member

Ah, I got it.

So this is a duplicate of #11558.
File paths in config files are relative from the config file.

@tHBp
Copy link
Author

tHBp commented Jul 3, 2019

@mysticatea I couldn't find the above marked issue in the first go. My bad. Sorry for creating a separate issue for this.

If this is the intended behavior, how can I go about fixing this issue since passing "../" in override pattern breaks things by throwing the following error: Error: Invalid override pattern (expected relative path not containing '..')

Also, this behavior is erratic at best. I have a couple of custom rules for which overrides seem to work as expected.

@tHBp tHBp closed this as completed Jul 3, 2019
@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Dec 31, 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 Dec 31, 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 bug ESLint is working incorrectly evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion
Projects
None yet
Development

No branches or pull requests

2 participants