Я хочу включить правило no-unpublished-import из eslint-plugin-node , однако оно конфликтует с моим текущим .eslintrc
, потому что я использую typescript-eslint и eslint-import-resolver-typescript .
Это моя текущая конфигурация:
{
"parser": "@typescript-eslint/parser", // Specifies the ESLint parser
"extends": [
"airbnb-base",
"plugin:@typescript-eslint/recommended", // Uses the recommended rules from the @typescript-eslint/eslint-plugin
"prettier", // Enables eslint-plugin-prettier and displays prettier errors as ESLint errors. Make sure this is always the last configuration in the extends array
"prettier/@typescript-eslint" // Uses eslint-config-prettier to disable ESLint rules from @typescript-eslint/eslint-plugin that would conflict with prettier
],
"parserOptions": {
"project": "./tsconfig.json",
"ecmaVersion": 6, // Allows for the parsing of modern ECMAScript features
"sourceType": "module" // Allows for the use of imports
},
"rules": {
},
"settings": {
"import/resolver": {
"node": {
"extensions": [".js", ".ts"]
},
// use <root>/tsconfig.json
"typescript": {
"alwaysTryTypes": true // always try to resolve types under `<root>@types` directory even it doesn't contain any source code, like `@types/unist`
}
}
},
"root": true
}
Однако код компилируется правильно, если я добавлю к опции extends plugin:node/recommended
, процесс компиляции завершится неудачно:
1:1 error Import and export declarations are not supported yet node/no-unsupported-features/es-syntax
1:43 error "express" is not found node/no-missing-import
2:1 error Import and export declarations are not supported yet node/no-unsupported-features/es-syntax
My package.json
включает node": ">=12.0.0
. Кроме того, это правило следует игнорировать, потому что я использую машинопись. С другой стороны, я просто экспортирую типы из express
, потому что модуль не использует его.
В соответствии с этой проблемой конфликт должен быть разрешен с помощью eslint-plugin-node
.
Как мне выполнить sh объединение обоих плагинов? Нужно ли go отключать правила по одному?
ОБНОВЛЕНО: Кажется, это было задано в этой проблеме в репозитории eslint-plugin-node
. Он работает для no-unsupported-features
и no-missing-import
, однако все еще не работает с определением импорта express
с no-extraneous-import
.
ОБНОВЛЕНО 2: Кажется eslint-plugin-node
работает над улучшением до 1050 * it. Выпуск здесь