简体   繁体   English

如何让 eslint-plugin-import 为我的 npm 项目 (create-react-app) 工作?

[英]How to get eslint-plugin-import working for my npm project (create-react-app)?

I just did npm install eslint-plugin-import --save-dev .我刚刚做了npm install eslint-plugin-import --save-dev

I expect react-app NOT to compile because it should flag an import misspelling.我希望 react-app 不会编译,因为它应该标记导入拼写错误。 The app is compiling fine.该应用程序编译正常。

How do I start using the linter?我如何开始使用 linter?

I don't understand the instructions ( https://www.npmjs.com/package/eslint-plugin-import ) when it says:当它说

1) "if you manage ESLint as a dev dependency" 1) “如果你将 ESLint 作为开发依赖来管理”

2) Manual configuring the .eslintrc.(yml|json|js) ... how does this work? 2) 手动配置.eslintrc.(yml|json|js) ...这是如何工作的?

1) "if you manage ESLint as a dev dependency" 1) “如果你将 ESLint 作为开发依赖来管理”

it means that you need to install the module as a development dependency , in contrast to production dependencies .这意味着您需要将模块安装为开发依赖项,而不是生产依赖项

the installation of development\production dependencies can be controlled using npm install --production可以使用npm install --production控制开发\生产依赖项的安装

With the --production flag (or when the NODE_ENV environment variable is set to production), npm will not install modules listed in devDependencies .使用--production标志(或当NODE_ENV环境变量设置为生产时),npm 将不会安装devDependencies中列出的模块。

now for your second question现在回答你的第二个问题

2) Manual configuring the.eslintrc.(yml|json|js)... how does this work? 2) 手动配置 the.eslintrc.(yml|json|js)...这是如何工作的?

.eslintrc.js (or eslintrc.yml , or eslintrc.json ) file is used to control and configure how eslint behaves in your project. .eslintrc.js (或eslintrc.ymleslintrc.json文件用于控制和配置 eslint 在项目中的行为方式。

for instance, you can use eslintrc.js file to enable and disable eslint rules.例如,您可以使用eslintrc.js文件来启用和禁用 eslint 规则。

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

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