我试图设置我的eslint配置与react,typescript和astro,但似乎我不能摆脱这个错误:
下面是我的.eslintrc.cjs
,它看起来像:
module.exports = {
env: {
browser: true,
es2021: true
},
extends: [
'standard-with-typescript',
'plugin:astro/recommended'
],
overrides: [
{
files: ['*.astro'],
parser: 'astro-eslint-parser',
parserOptions: {
parser: '@typescript-eslint/parser',
extraFileExtensions: ['.astro']
},
rules: {
}
},
{
files: ['.jsx', '.tsx'],
extends: [
'plugin:react/recommended'
],
plugins: [
'react'
],
rules: {
'react/jsx-wrap-multilines': [2, {
declaration: 'parens-new-line',
assignment: 'parens-new-line',
return: 'parens-new-line',
arrow: 'parens-new-line',
condition: 'ignore',
logical: 'ignore',
prop: 'ignore'
}],
'react/react-in-jsx-scope': 'off',
'react/jsx-indent': [1, 2]
}
}
],
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
project: './tsconfig.json'
},
rules: {
indent: 'off',
'@typescript-eslint/indent': [1, 2],
'no-tabs': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/no-unused-vars': 'warn',
'@typescript-eslint/consistent-type-definitions': ['error', 'type'],
'@typescript-eslint/naming-convention': 'off',
'@typescript-eslint/no-floating-promises': 'off',
'@typescript-eslint/triple-slash-reference': 'off'
}
}
这是我的tsconfig.json
{
"extends": "astro/tsconfigs/strictest",
"compilerOptions": {
"target": "ESNext",
"useDefineForClassFields": true,
"lib": ["DOM", "DOM.Iterable", "ESNext"],
"allowJs": false,
"skipLibCheck": true,
"esModuleInterop": false,
"baseUrl": "./src/",
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"module": "ESNext",
"moduleResolution": "Node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx"
},
"include": ["src"]
}
任何帮助都是感激不尽的。
我尝试按照astro-eslint设置指南这个https://github.com/ota-meshi/eslint-plugin-astro,但仍然得到这些错误。
1条答案
按热度按时间jxct1oxe1#
您还需要在tsconfig.json中添加/更新
"include": ["**/*.ts", "**/*.tsx", "**/*.astro"]