我在编译我的App.tsx时自动创建的App.js文件中出现ESLint错误,其中包含一个简单的组件。如何解决这个问题?有一个错误示例:
[eslint]
src/App.js
第1行:1:在模块中不需要“use strict”
第1行:1:字符串必须使用单引号
App.tsx:
export default function App() { return <div>it works!</div> }
字符串
tsconfig.json:
{
"compilerOptions": {
"target": "es2016",
"module": "commonjs",
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"skipLibCheck": true,
"jsx": "react-jsx"
},
"include": ["src", "src/@types"]
}
型
package.json:
{
"name": "my_gallery",
"version": "0.1.0",
"private": true,
"dependencies": {
"@fortawesome/fontawesome-svg-core": "^6.4.2",
"@fortawesome/free-brands-svg-icons": "^6.4.2",
"@fortawesome/free-regular-svg-icons": "^6.4.2",
"@fortawesome/free-solid-svg-icons": "^6.4.2",
"@fortawesome/react-fontawesome": "^0.2.0",
"@reduxjs/toolkit": "^1.9.7",
"@tanstack/react-query": "^4.36.1",
"@testing-library/jest-dom": "^5.17.0",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
"axios": "^1.5.1",
"eslint-config-airbnb-typescript": "^17.1.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-paginate": "^8.2.0",
"react-redux": "^8.1.3",
"react-router-dom": "^6.16.0",
"react-scripts": "5.0.1",
"react-select": "^5.7.7",
"web-vitals": "^2.1.4"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"@babel/eslint-parser": "^7.22.15",
"@types/jest": "^29.5.6",
"@types/node": "^20.8.8",
"@types/react": "^18.2.31",
"@types/react-dom": "^18.2.14",
"eslint": "^8.52.0",
"eslint-config-airbnb": "^19.0.4",
"eslint-plugin-import": "^2.29.0",
"eslint-plugin-jsx-a11y": "^6.7.1",
"eslint-plugin-react": "^7.33.2",
"typescript": "^5.2.2"
}
}
型
1条答案
按热度按时间yfjy0ee71#
设置你的
tsconfig.json
到这个,它应该解决你的问题字符串