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

Comments

@geoffreyyip
Copy link

commented Jun 24, 2017

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 label Jun 24, 2017

@ilyavolodin

This comment has been minimized.

Copy link
Member

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.

@geoffreyyip

This comment has been minimized.

Copy link
Author

commented Jun 24, 2017

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!

@jshado1

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link
Member

commented Mar 28, 2018

@jshado1 Please open a new issue, thanks!

@jshado1

This comment has been minimized.

Copy link

commented Mar 28, 2018

@nzakas

This comment has been minimized.

Copy link
Member

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 in a940cf4 Oct 23, 2018

@eslint eslint bot locked and limited conversation to collaborators Apr 22, 2019

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
6 participants
You can’t perform that action at this time.