我的问题是,当我编码vscode的编辑器时,会自动将项目中所有文件的相对路径自动替换为绝对路径。
例如: 当我这样导入时:
import { login } from '../logic.redux/action'
稍后五分钟(可能会执行某些操作,例如保存或导入另一个文件),它将转换为:
import { login } from '@module/login/logic.redux/action'
严重的是它将所有文件覆盖为绝对文件。告诉我我在做什么错
我的项目包括:Typescript + react-native(project)
这是我的tsconfig.json
{
"compilerOptions": {
"module": "es6",
"target": "es6",
"lib": ["es6", "dom"],
"sourceMap": true,
"allowJs": true,
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"jsx": "react-native",
"moduleResolution": "node",
"noEmit": true,
"experimentalDecorators": true,
"forceConsistentCasingInFileNames": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"noImplicitAny": true,
"strictNullChecks": true,
"suppressImplicitAnyIndexErrors": true,
"noUnusedLocals": false,
"baseUrl": "./src",
"paths": {
"@conf/*": ["./conf/*"],
"@i18n/*": ["./i18n/*"],
"@module/*": ["./module/*"],
"@router/*": ["./router/*"],
"@theme/*": ["./theme/*"],
"@tpl/*": ["./tpl/*"],
"@util/*": ["./util/*"]
}
},
"exclude": ["node_modules"]
}
这是我的tslint.json
{
"defaultSeverity": "error",
"extends": [
"tslint-config-airbnb"
],
"jsRules": {},
"rules": {
"indent": [
true,
"tabs", 4
],
"ter-indent": [
false
],
"semicolon": [
true,
"never"
],
"object-literal-sort-keys": false,
"quotemark": [
true,
"single",
"jsx-double"
],
"ordered-imports": true,
"interface-name": [
false
],
"max-line-length": [
true,
140
],
"no-console": [
false
],
"no-empty-interface": false,
"no-var-requires": false,
"import-name": false,
"no-consecutive-blank-lines": [
true,
0
],
"no-increment-decrement": false,
"variable-name": [
true,
"ban-keywords",
"check-format",
"allow-pascal-case"
],
"no-unused-variable": false
},
"rulesDirectory": []
}
vscode中的用户设置
{
"workbench.colorTheme": "Bimbo Theme",
"sublimeTextKeymap.promptV3Features": true,
"editor.renderWhitespace": "boundary",
"editor.rulers": [100],
"editor.cursorBlinking": "solid",
"editor.fontFamily": "Fira Code",
"editor.fontLigatures": true,
"window.zoomLevel": 0,
"todohighlight.isEnable": true,
"javascript.implicitProjectConfig.experimentalDecorators": true,
"gitlens.advanced.messages": {
"suppressShowKeyBindingsNotice": true
},
"files.autoSave": "off",
"eslint.autoFixOnSave":true,
"tslint.autoFixOnSave": true,
"tslint.configFile": "./tslint.ide.json",
"typescript.updateImportsOnFileMove.enabled": "always",
"javascript.implicitProjectConfig.experimentalDecorators": true,
"editor.detectIndentation": false,
"editor.insertSpaces": false,
"editor.tabSize": 4,
}
这是
的列表扩展名
PeterJausovec.vscode-docker
abotteram.typescript-react-snippets
ajhyndman.jslint
anseki.vscode-color
azemoh.one-monokai
bierner.markdown-preview-github-styles
chenxsan.vscode-standardjs
chong.vscode-typescript-react-redux-snippets
christian-kohler.path-intellisense
cmstead.jsrefactor
Compulim.compulim-vscode-closetag
cssho.vscode-svgviewer
Dart-Code.dart-code
dbaeumer.vscode-eslint
DotJoshJohnson.xml
dracula-theme.theme-dracula
dsznajder.es7-react-js-snippets
eamodio.gitlens
EditorConfig.EditorConfig
eg2.tslint
emmanuelbeziat.vscode-great-icons
esbenp.prettier-vscode
formulahendry.auto-close-tag
formulahendry.auto-complete-tag
formulahendry.auto-rename-tag
HookyQR.beautify
infeng.vscode-react-typescript
jundat95.react-native-snippet
karyfoundation.comment
kevinkyang.auto-comment-blocks
mgmcdermott.vscode-language-babel
miclo.sort-typescript-imports
mohsen1.prettify-json
monokai.theme-monokai-pro-vscode
ms-python.python
ms-vscode.node-debug2
ms-vscode.sublime-keybindings
naumovs.color-highlight
patrys.vscode-code-outline
pawelgrzybek.bimbo-theme
pmneo.tsimporter
pnp.polacode
richie5um2.vscode-sort-json
santosh.react-native-snippet
shd101wyy.markdown-preview-enhanced
stevencl.addDocComments
teabyii.ayu
vsmobile.vscode-react-native
waderyan.gitblame
wayou.vscode-todo-highlight
wix.vscode-import-cost
xabikos.JavaScriptSnippets
yzhang.markdown-all-in-one
zengxingxin.sort-js-object-keys
答案 0 :(得分:2)
打开vscode用户设置:File -> Preferences -> Settings
设置"javascript.updateImportsOnFileMove.enabled": "prompt",
prompt
always
自动更新路径
never
重命名路径,不要提示我
您可能是在always
上设置的
答案 1 :(得分:1)
尝试重新安装vscode。 并在更改名称文件时选择“否,从不”按钮,它将显示弹出窗口,例如“为移动文件自动更新导入”