Eslint glob (**) is not considering all directories recursively

Viewed 10226

I am using OSX, in my package.json file I have the script entry:

"lint": "eslint ./src/**/*.js"

However, when I run npm lint only the 1st level of directories are being considered for linting, eg. ./src/dir/* not ./src/dir/nested_dir/*.

I was under the impression that ** glob indicated recursive search?

Does anyone know how I can make this behave as expected?

4 Answers

Some Googling turned up this thread on Github:

Before (not working): "lint": "eslint ./src/**/*.js"

After (working): "lint": "eslint './src/**/*.js'"

Try this instead:

"lint": "eslint src --ext .js"

Or for more than one extension:

"lint": "eslint src --ext .js,.jsx,.ts,.tsx"

See more info on eslint's docs

This command is working recursively in monorepos (first glob is for all subfolders in packages, second one, is for any subfolder in src). Without second glob, the command does not work.

"lint": "eslint 'packages/**/src/**' --ext .ts,.tsx"

This also occurs when linting using vue-cli-service so you will need quotes with it as well:

"lint": "vue-cli-service lint './src/main/app/**/*.ts' './src/main/app/**/*.vue'"
Related