我在节点项目中使用eslint配置了babel-plugin-module-resolver。这是我的eslintrc。
{
"env": {
"es6": true,
"node": true
},
"extends": [
"airbnb-base"
],
"globals": {
"Atomics": "readonly",
"SharedArrayBuffer": "readonly"
},
"parserOptions": {
"ecmaVersion": 2018,
"sourceType": "module"
},
"settings": {
"import/resolver": {
"babel-module": {}
}
},
"rules": {
"class-methods-use-this": "off",
"newline-per-chained-call": "off",
"indent": ["warn", 2],
"quotes": ["warn", "single"],
"no-unused-vars": ["error", {"warn": "none"}],
"max-len": ["warn", 150],
"no-console": 1,
"object-curly-newline": ["warn", {
"ObjectPattern": { "multiline": true },
"ExportDeclaration": { "multiline": true, "minProperties": 4 }
}]
}
}
这是我的babelrc文件。
{
"presets": ["@babel/preset-env"],
"plugins": [
[
"module-resolver",
{
"alias": {
"constants": "./constants",
"database": "./database",
"library": "./library",
"mappers": "./mappers",
"middleware": "./middleware",
"models": "./models",
"repositories": "./repositories",
"routes": "./routes",
"services": "./services",
"utils": "./utils"
}
}
]
]
}
现在在我的项目中,路径可以像这样正常工作。
import User from 'models/user.model';
import UserRepository from 'repositories/user.repository';
但是我有以下问题。 当我单击导入时,它不会转到定义。 IntelliSense无法正常工作。
我在这里用这些插件做什么?我想让它具有智能感知并转到定义(导航)功能。