eslint-plugin-import使用方法
时间: 2023-12-29 15:02:18 浏览: 166
可以通过以下步骤使用 eslint-plugin-import:
1. 在你的项目中安装 eslint-plugin-import:
```
npm install eslint-plugin-import --save-dev
```
2. 在 .eslintrc 文件中配置插件:
```
{
"plugins": [
"import"
],
"rules": {
"import/no-unresolved": "error",
"import/named": "error",
"import/namespace": "error",
"import/default": "error",
"import/export": "error",
"import/no-named-as-default": "error",
"import/no-named-as-default-member": "error",
"import/no-deprecated": "warn",
"import/no-extraneous-dependencies": "error",
"import/no-mutable-exports": "error",
"import/no-commonjs": "off",
"import/no-amd": "error",
"import/no-nodejs-modules": "off",
"import/first": "error",
"import/imports-first": "off",
"import/no-duplicates": "error",
"import/no-namespace": "off",
"import/extensions": "off",
"import/order": "off"
}
}
```
3. 运行 eslint 检查你的代码。
你可以在 eslint-plugin-import 的官方文档中查看更多配置选项和规则。
阅读全文