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

Can't lint files with square brackets in the name #11940

Closed
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion bug ESLint is working incorrectly core Relates to ESLint's core APIs and features

Comments

@staab
Copy link

staab commented Jul 3, 2019

Tell us about your environment

MacOS 10.14.5 (18F132)
zsh 5.3 (x86_64-apple-darwin18.0)

  • ESLint Version: v6.0.1
  • Node Version: v8.15.0
  • npm Version: 6.9.0

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

Please show your full configuration:

Configuration
module.exports = {
  "env": {
    "browser": true,
    "node": true,
    "es6": true,
  },
  "extends": [
    "eslint:recommended",
    "plugin:prettier/recommended",
  ],
  "globals": {
    "Atomics": "readonly",
    "SharedArrayBuffer": "readonly",
  },
  "parserOptions": {
    "ecmaVersion": 2018,
    "sourceType": "module",
  },
  "rules": {
    "no-unused-vars": ["error", {args: "none"}],
  },
}

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

No source, the bug happens even if the file is empty.

$ cat src/routes/blog/\[slug\].svelte
console.log('x',)
$ npx eslint src/routes/blog/\[slug\].svelte
No files matching 'src/routes/blog/[slug].svelte' were found.
$ npx eslint src/routes/blog/[slug].svelte
No files matching 'src/routes/blog/[slug].svelte' were found.
$ npx eslint src/routes/blog/\\[slug\\].svelte
No files matching 'src/routes/blog/\[slug\].svelte' were found.

What did you expect to happen?

That eslint would lint the file.

What actually happened? Please include the actual, raw output from ESLint.

Eslint was unable to find the file.

Are you willing to submit a pull request to fix this bug?

I could give it a shot, but I'm probably not the best person to solve it.

@staab staab 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

mysticatea commented Jul 4, 2019

Thank you for your report.

I confirmed it on a Linux VM.

The cause is the following step in ESLint's file enumerator:

  • \[abc\].js ... ESLint received it as [abc].js.
    1. isGlob("[abc].js") is true then it's handled as a glob; it matches any of a.js, b.js, and c.js.
  • \\[abc\\].js ... ESLint received it as \[abc\].js.
    1. isGlob("\\[abc\\].js") is false then it's handled as a filename; it matches \[abc\].js rather than [abc].js on Linux. Also, it matches C:\[abc\].js on Windows (because \ is the path separator).

Hmm. I'm considering how we should do.

@mysticatea mysticatea added core Relates to ESLint's core APIs and features 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 4, 2019
@mysticatea mysticatea added accepted There is consensus among the team that this change meets the criteria for inclusion and removed evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion labels Jul 12, 2019
@mysticatea
Copy link
Member

ESLint cannot distinguish [abc].js, \[abc\].js, and "[abc].js" because ESLint receives all of those as the same string "[abc].js". It's...

mysticatea added a commit that referenced this issue Jul 14, 2019
@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Jan 18, 2020
@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 Jan 18, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.