[英]package.json and Eslint glob extension
My package.json is below. 我的package.json在下面。 How do I update it so that eslint runs on:
我如何更新它以便eslint可以运行在:
src and test directories src和测试目录
for 对于
.js and .jsx files only? 仅.js和.jsx文件? Right now the * wild card is including .json which I don't want.
现在,*通配符包括我不需要的.json。
package.json 的package.json
{ ... "lint": "eslint {src/**/*.js*,test/**/*.js*} ... }
I think you need to trade brevity for specificity here: 我认为您需要在此简化一下,以求具体:
{
...
"lint": "eslint {src/**/*.js,src/**/*.jsx,test/**/*.js,test/**/*.jsx}"
...
}
You can read in eslint documentation : 您可以阅读eslint文档 :
Please note that when passing a glob as a parameter, it will be expanded by your shell.
请注意,将glob作为参数传递时,它将由您的shell扩展。 The results of the expansion can vary depending on your shell, and its configuration.
扩展的结果可能会因您的外壳及其配置而异。 If you want to use node glob syntax, you have to quote your parameter (using double quotes if you need it to run in Windows), as follows:
如果要使用节点全局语法,则必须用引号引起来(如果需要在Windows中运行,请使用双引号):
So it would be advisable to use double quotes. 因此,建议使用双引号。 Once you use double quotes (which need to be escaped inside json string) you can slightly modify your pattern eg
一旦使用了双引号(需要在json字符串中转义),您就可以稍微修改模式,例如
{
...
"lint": "eslint \"{src,test}/**/*.{js,jsx}\""
...
}
Test using globster.xyz (globster.xyz require /
at the beginning but eslint doesn't, not sure why...) 使用globster.xyz进行测试(globster.xyz开头需要
/
,但eslint不需要,不确定原因...)
There is usually more than one way to achieve what you want but I think this would be the most concise. 通常,有多种方法可以实现您想要的目标,但是我认为这是最简洁的方法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.