user762579
user762579

Reputation:

eslint: ignore-pattern rule is not working

I have the following structure

myproject
    src
        indxe.js

In my package.json I have also :

"scripts": {
    "build": "babel src -d dist --source-maps",
    "serve": "node dist/index.js",
    "start": "babel-node src/index.js",
    "start:dev": "nodemon src/index.js --exec babel-node",
    "test": "jest --runInBand --verbose",
    "coverage": "jest --coverage --runInBand --verbose",
    "eslint": "eslint src/**/.js --ignore-pattern \"node_modules/\""
  },

but running

yarn eslint

I get an error

"eslint": "eslint src/**/.js --ignore-pattern \"node_modules/\""

$ eslint src/**/.js --ignore-pattern "node_modules/"

Oops! Something went wrong! :(

ESLint: 5.10.0.
No files matching the pattern "src/**/.js" were found.
Please check for typing mistakes in the pattern.

error Command failed with exit code 2.

I don't understand why as it should be OK...

feedback welcome

Upvotes: 2

Views: 11306

Answers (1)

Patrick Hund
Patrick Hund

Reputation: 20236

You specified the glob pattern incorrectly:

eslint src/**/.js

With this, you are specifying: “In any directory below src, find me any files with the exact name .js

What you actually want is: “In any directory below src, find me any files with the name ending in .js

You can achieve this by adding another asterisk, which serves as placeholder for the beginning of each JS file name, like this:

eslint src/**/*.js

You can find more information on how to use glob patterns here: https://github.com/isaacs/node-glob#readme

Upvotes: 8

Related Questions