简体   繁体   English

如何配置package.json在js和jsx文件上运行eslint

[英]How to configure package.json to run eslint on js and jsx files

This post works for linting all .js files in a project. 这篇文章适用于整理项目中的所有.js文件。

How do I lint all .jsx files in addition to all .js files? 除了所有.js文件之外,我该如何.jsx所有.jsx文件?

I've gotten this to work: 我已经做到这一点:

    "lint": "./node_modules/.bin/eslint \"./**/*.js\" \"./**/*.jsx\""

However, I think that there is a more succint way to match both .js and .jsx file extensions. 但是,我认为有一种更简洁的方式来匹配.js.jsx文件扩展名。

Eslint has an --ext flag which you can use to specify the file extensions you want eslint to look at. Eslint具有--ext标志,可用于指定您希望eslint查看的文件扩展名。 So you can do "lint: eslint --ext .js --ext .jsx" 因此,您可以执行"lint: eslint --ext .js --ext .jsx"

https://eslint.org/docs/user-guide/command-line-interface https://eslint.org/docs/user-guide/command-line-interface

您也可以尝试以下在我的机器上正常运行的方法:

"lint": "eslint \"**/*.{js,jsx}\""

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

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