This is my directory structure.

I want to config some eslint rule to detect my code.
In .eslintrc, I write these configuration items.
{
  "extends": "airbnb",
  "rules": {
    "valid-jsdoc": 2,
    // Disable until Flow supports let and const
    "no-var": 0,
    "react/jsx-uses-react": 1,
    "react/jsx-no-undef": 2,
    "react/wrap-multilines": 2,
    "func-names": 0,
    "new-cap": 0,
    "no-undef": 0,
  },
  "plugins": [
    "react"
  ]
}
I have used npm script to run eslint.
  "scripts": {
    "lint": "eslint src"
  },
Normally, when I run npm run lint, it will detect all the files in src directory.
But, unfortunately, nothing output.

I don't know why. I guess maybe I have writed wrong configuration items. But after I write npm scripts "lint": "eslint src/component/App.jsx", eslint works.
So where is the problems? Eslint can detect single file well, but it can't detect all the files in some directory.

By default, ESLint lints *.js files and the files that match the overrides entries of your configuration. Note: --ext is only used when the arguments are directories. If you use glob patterns or file names, then --ext is ignored.
when you run eslint src, by default its looking for all the files with .js extension. I think in your case you want to change command to eslint src --ext .js,.jsx. This will look for all the files inside src with .js and/or .jsx  extensions. (personally recommend)
If you want to use glob to solve this issue then you can change your cmd to eslint src/**/*.jsx
CLI docs: http://eslint.org/docs/user-guide/command-line-interface
Glob patterns help: http://eslint.org/docs/user-guide/configuring#ignoring-files-and-directories
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With