简体   繁体   English

Eslint glob (**) 没有递归地考虑所有目录

[英]Eslint glob (**) is not considering all directories recursively

I am using OSX, in my package.json file I have the script entry:我正在使用 OSX,在我的package.json文件中我有脚本条目:

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

However, when I run npm lint only the 1st level of directories are being considered for linting, eg.但是,当我运行npm lint时,仅考虑对第一级目录进行 linting,例如。 ./src/dir/* not ./src/dir/nested_dir/* . ./src/dir/*不是./src/dir/nested_dir/*

I was under the impression that ** glob indicated recursive search?我的印象是** glob 表示递归搜索?

Does anyone know how I can make this behave as expected?有谁知道我怎样才能使它按预期运行?

Some Googling turned up this thread on Github:一些谷歌搜索在 Github 上出现了这个线程

Before (not working): "lint": "eslint ./src/**/*.js"之前(不工作): "lint": "eslint ./src/**/*.js"

After (working): "lint": "eslint './src/**/*.js'"之后(工作): "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查看更多关于eslint 文档的信息

This command is working recursively in monorepos (first glob is for all subfolders in packages, second one, is for any subfolder in src).此命令在 monorepos 中递归工作(第一个 glob 用于包中的所有子文件夹,第二个用于 src 中的任何子文件夹)。 Without second glob, the command does not work.如果没有第二个 glob,该命令将不起作用。

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

使用vue-cli-service进行 linting 时也会发生这种情况,因此您也需要使用引号:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM