MLy*_*yck 6 typescript eslint tsconfig visual-studio-code
VSCode linting 似乎不尊重我在 tsconfig.json 文件中定义的路径。
从 tsconfig.json 中定义的“别名”导入任何内容时,出现以下错误。
tsconfig.json:
{
"compilerOptions": {
"outDir": "./dist/",
"module": "esNext",
"strictNullChecks": true,
"moduleResolution": "node",
"esModuleInterop": true,
"experimentalDecorators": true,
"allowJs": true,
"jsx": "preserve",
"skipLibCheck": true,
"noUnusedParameters": true,
"noUnusedLocals": true,
"noImplicitAny": true,
"noImplicitThis": true,
"declaration": true,
"allowSyntheticDefaultImports": true,
"emitDecoratorMetadata": true,
"target": "es5",
"lib": ["es5", "es6", "es7", "es2017", "dom"],
"types": ["react", "jest", "node"],
"baseUrl": ".",
"paths": {
"~*": ["./src/*"],
"common/*": ["src/common/*"],
"test/*": ["test/*"],
"test-utils": ["test/test-utils.tsx"],
"static/*": ["static/*"],
"storybook/*": [".storybook/*"]
},
"strict": false,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"resolveJsonModule": true,
"isolatedModules": true
},
"include": ["__root/src/**/*", "src/typings.d.ts", "./@types", ".storybook/decorators/**/*"],
"exclude": ["./node_modules", "dist"]
}
Run Code Online (Sandbox Code Playgroud)
.eslintrc
{
"extends": ["react-app"],
"plugins": ["prettier"],
"parser": "@typescript-eslint/parser",
"rules": {
"prettier/prettier": "error"
},
"settings": {
"react": {
"version": "detect"
}
}
}
Run Code Online (Sandbox Code Playgroud)
软件包版本:
"@typescript-eslint/parser": "^4.3.0",
"babel-eslint": "10.1.0",
"eslint": "7.10.0",
"eslint-config-react-app": "^5.2.1",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-jsx-a11y": "6.3.1",
"eslint-plugin-prettier": "3.1.4",
"eslint-plugin-react": "7.21.2",
Run Code Online (Sandbox Code Playgroud)
.prettierrc
{
"printWidth": 100,
"tabWidth": 2,
"useTabs": false,
"semi": true,
"singleQuote": true,
"trailingComma": "none",
"bracketSpacing": true,
"jsxBracketSameLine": false,
"arrowParens": "avoid"
}
Run Code Online (Sandbox Code Playgroud)
我一直在寻找一个我几个小时都没有尝试过的解决方案,但我没有找到与本地模块和 tsconfig 路径别名特别相关的任何内容。
(代码工作和构建得很好,这只是我在 VScode 中看到的一个 linting 问题)
我已经tslint在 VSCode 中安装了该包。我尝试删除它并用它替换它,eslint但这没有任何区别。
| 归档时间: |
|
| 查看次数: |
3873 次 |
| 最近记录: |