eslint / eslint

Find and fix problems in your JavaScript code.
https://eslint.org
MIT License
24.57k stars 4.44k forks source link

V5 cannot find eslintrc #10332

Closed Rukeith closed 6 years ago

Rukeith commented 6 years ago

Tell us about your environment

What parser (default, Babel-ESLint, etc.) are you using? babel-eslint Please show your full configuration:

Configuration ```js { "parserOptions": { "ecmaVersion": 8, "sourceType": "module", "ecmaFeatures": { "globalReturn": true, // allow return statements in the global scope "impliedStrict": true, // enable global strict mode (if ecmaVersion is 5 or greater) "jsx": true, // enable JSX "experimentalObjectRestSpread": true, // enable support for the experimental object rest/spread properties "allowImportExportEverywhere": true } }, "parser": "babel-eslint", "env": { "browser": true, "node": true, "jest": true, "commonjs": true, "shared-node-browser": true, "es6": true, "worker": false, "amd": true }, "rules": { "semi": [ 2, "always" ], "no-underscore-dangle": "off", "no-useless-escape": "off", "max-len": ["error", { "code": 150 }] }, "extends": "airbnb-base" } ```

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

./node_modules/.bin/eslint --quiet ./

What did you expect to happen? Run the lint check What actually happened? Please include the actual, raw output from ESLint. It look like didn't find the my eslintrc. I just upgrade to v5 and got this error. It work fine at v4. My .eslintrc is at top of my project folder

Oops! Something went wrong! :(

ESLint: 5.0.0-alpha.2.
No files matching the pattern "./config" were found.
Please check for typing mistakes in the pattern.

error Command failed with exit code 2
platinumazure commented 6 years ago

Hi @Rukeith, thanks for the issue.

This logic isn't actually trying to find your config file (.eslintrc.*), but rather it is trying to find files (for linting) that are in ./config. We recently introduced this logic to help users catch typos (e.g., they meant to lint ./src but they typed ./scr; this used to lint nothing with no error, but now we want to raise an error in case they mistyped the directory name).

I'm a bit confused as to what is going on, because your lint command says you are linting ./. Does the airbnb-base configuration have a glob-based configuration override which tries to apply different rules for a ./config directory? If so, that's really weird-- shareable configs as generalized/popular as airbnb shouldn't guess at a consuming project's folder structure.

Could you please double check your configuration and lint command one more time? Thanks!

Rukeith commented 6 years ago

I lint ./ that is just because I want to lint all files in my project. I didn't apply different rules for config. Here is my project https://github.com/Rukeith/blog-server, you could try it. I upgrade to v5 latest version and got that error. I downgrade to v4 it work fine.

not-an-aardvark commented 6 years ago

Based on this line, it seems like you're linting ./* from an npm script. That glob pattern is getting expanded in your shell to a list of files and folders, including ./config. So this is equivalent to running something like eslint ./config ./controller ./locales ...

To fix the issue, you can quote the glob so that your shell doesn't expand it: eslint "./*"

Rukeith commented 6 years ago

@not-an-aardvark But when I add config to .eslintignore I still got the error, so I didn't thinks that is the reason. And the point is v4 works, but v5 got error. If there is nothing big change for this. It should works too. BTW, I just fix the error by change ./* to .

not-an-aardvark commented 6 years ago

It's caused by this change.

Rukeith commented 6 years ago

That makes sense. Thank you for your explanation.