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
staab opened this issue Jul 3, 2019 · 2 comments

Comments

@staab
Copy link

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.

@mysticatea

This comment has been minimized.

Copy link
Member

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

This comment has been minimized.

Copy link
Member

commented Jul 14, 2019

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

mysticatea added a commit that referenced this issue Jul 21, 2019

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