Tay*_*tin 5 typescript eslint eslintrc
在浏览完这篇文章并尝试了这里的所有内容之后。似乎什么都不起作用。
我们尝试将节点部分添加到导入/解析器中,但这似乎不起作用。我们也在使用 monorepo,这会产生什么影响吗?尝试过的其他方法是将 a 添加project
到打字稿解析器,但这也不起作用。
尝试将路径切换到 tsconfig.json 内的直接路径,但这也不起作用。
这是我的文件:
导入示例:import { colors } from "@styles"
tsconfig.json
:
{
"compilerOptions": {
"target": "es5",
"outDir": "lib",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"declaration": true,
"declarationDir": "lib",
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react",
"baseUrl": ".",
"paths": {
"@styles/*": ["src/styles/*"],
"@styles": ["src/styles/index.ts"],
"@utils/*": ["src/utils/*"]
}
},
"include": [
"src/*",
"stories/*",
],
"exclude": [
"node_modules",
"lib"
]
}
Run Code Online (Sandbox Code Playgroud)
.eslintrc.js
:
const vars = ["const", "let", "var"]
module.exports = {
plugins: ["graphql"],
extends: [
"eslint:recommended",
"plugin:react/recommended",
"plugin:react-hooks/recommended",
"plugin:import/recommended",
"plugin:import/typescript",
"plugin:@typescript-eslint/recommended",
"plugin:prettier/recommended"
],
settings: {
react: {
version: "detect"
},
"import/parsers": {
"@typescript-eslint/parser": [".ts", ".tsx"]
},
"import/extensions": [".js", ".jsx", ".ts", ".tsx"],
"import/resolvers": {
typescript: {}
}
},
env: {
browser: true,
jest: true,
node: true,
es6: true
},
rules: {
"import/newline-after-import": "error",
"import/order": [
"error",
{
"newlines-between": "never"
}
],
"@typescript-eslint/camelcase": "off",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/no-non-null-asserted-optional-chain": "off",
"padding-line-between-statements": [
"error",
{
blankLine: "always",
prev: vars,
next: "*"
},
{
blankLine: "any",
prev: vars,
next: vars
},
{
blankLine: "always",
prev: "*",
next: "return"
},
{
blankLine: "always",
prev: "*",
next: "block-like"
},
{
blankLine: "always",
prev: "block-like",
next: "*"
}
],
"react/prop-types": "off",
"no-irregular-whitespace": "off"
},
overrides: [
{
files: ["*.js", "*.ts", "*.tsx"],
rules: {
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/no-var-requires": "off",
"@typescript-eslint/explicit-module-boundary-types": "off"
}
}
]
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
819 次 |
最近记录: |