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

In Docs, "Configuration Based on Glob Patterns" should specify it's a v4.1 feature. Fails silently on earlier versions. #8793

Closed
geoffreyyip opened this issue Jun 24, 2017 · 6 comments
Assignees
Labels
archived due to age This issue has been archived; please open a new issue for any further discussion documentation Relates to ESLint's documentation enhancement This change enhances an existing feature of ESLint evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion

Comments

@geoffreyyip
Copy link

Tell us about your environment

  • ESLint Version: 3.x
  • Node Version: 7.x
  • npm Version: 5.x

Problem:

I had a default configuration for my **/*.js files and I was trying to set linting rules differently for my **/*.test.js files. Mostly, I wanted to use describe, it, and other global testing variables in my testing files. I was trying to avoid messages like error 'describe' is not defined no-undef

On the Configuring ESLint's "Configuration Based on Glob Patterns" section, I found out I could specify glob-based overrides, and so I specified my configuration to something like this.

eslintrc.js

{
  "env": { "node": true },
  "overrides": [
    {
      "files": [ "**/*.test.js" ],
      "env": { "mocha": true }
    }
  ]
}

What did you expect to happen?

I expected my *.test.js files to be linted differently. I expected to get rid of the error 'describe' is not defined no-undef message. Instead, it persisted. And I had no idea why. I spent a hour checking my globs and configuration before realizing that I was still on v3.19.0 and the glob-based overrides were only added 2 days ago, according to #3611.

Once I upgraded to v4.1.0, the overrides syntax worked as normal.

Two things that could help future developers avoid my mistake:

  • A note in the docs saying users should upgrade to v4.1.0 to use the glob-based configuration feature and that it will have no effect in earlier versions.
  • A CLI warning for v3.x telling users that overrides syntax is unavailable for them.
@eslintbot eslintbot added the triage An ESLint team member will look at this issue soon label Jun 24, 2017
@ilyavolodin
Copy link
Member

ilyavolodin commented Jun 24, 2017

That's a good point, although we've never done that for other global features. Not sure how to best handle this. Also, we don't normally make changes in older versions of ESLint.

@ilyavolodin ilyavolodin added documentation Relates to ESLint's documentation enhancement This change enhances an existing feature of ESLint 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 Jun 24, 2017
@geoffreyyip
Copy link
Author

Vue.js docs handles this pretty nicely.

version

It could be a good practice going forward. eslint has a crazy amount of configurations, feature, and partner libraries. It's not always easy to pinpoint the bug.

Thanks for hearing me out!

@JakobJingleheimer
Copy link

JakobJingleheimer commented Mar 28, 2018

I'm experiencing this on v4.18.2

"overrides": [
  {
    "env": {
      "mocha": true,
    },
    "files": [
      "**/*.spec.js"
    ],
    "rules": {
      "func-names": "off",
      "no-unused-expressions": "off",
      "prefer-arrow-callback": [
        "error",
        "never"
      ]
    }
  }
],

Nothing from this override block is getting applied to my spec files.

@platinumazure
Copy link
Member

@jshado1 Please open a new issue, thanks!

@JakobJingleheimer
Copy link

@platinumazure #10136

@nzakas
Copy link
Member

nzakas commented Oct 22, 2018

It seems simple enough to add this note in the docs. I'll add it.

@nzakas nzakas self-assigned this Oct 22, 2018
@nzakas nzakas closed this as completed in a940cf4 Oct 23, 2018
@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Apr 22, 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 Apr 22, 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 documentation Relates to ESLint's documentation enhancement This change enhances an existing feature of ESLint 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

6 participants