最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to configure package.json to run eslint on js and jsx files - Stack Overflow

programmeradmin2浏览0评论

This post works for linting all .js files in a project.

How do I lint all .jsx files in addition to all .js files?

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.

This post works for linting all .js files in a project.

How do I lint all .jsx files in addition to all .js files?

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.

Share Improve this question asked Jun 18, 2018 at 17:15 SeanPlusPlusSeanPlusPlus 9,03318 gold badges62 silver badges84 bronze badges 1
  • There's no need to include ./node_modules/.bin/ in the scripts section of package.json. – devius Commented Jun 18, 2018 at 17:41
Add a comment  | 

2 Answers 2

Reset to default 10

You could also try the following which is working fine on my machine:

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

Eslint has an --ext flag which you can use to specify the file extensions you want eslint to look at. So you can do "lint: eslint --ext .js --ext .jsx"

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

发布评论

评论列表(0)

  1. 暂无评论