admin管理员组文章数量:1417425
I was working on a new react project and had set up my ESlint which was running fine before I changed code in another file and now it's giving me an error:
Error: Unexpected token 'export'
I'm new to eslint and so I'm using all the default settings that are remended however I'm hesitant to post this just because I feel like this may be a formatting error on my part. Any help would be greatly appreciated.
Here is my ESlint file:
export default{
"env": {
"browser": true,
"es2021": true
},
"extends": [
"eslint:remended",
"plugin:react/remended"
],
"parserOptions": {
"ecmaFeatures": {
"jsx": true
},
"ecmaVersion": 12,
"sourceType": "module"
},
"plugins": [
"react"
],
"rules": {
"no-extra-semi":"error"
}
};
and here is the Package's json:
{
"name": "testapp",
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^5.12.0",
"@testing-library/react": "^11.2.6",
"@testing-library/user-event": "^12.8.3",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-scripts": "4.0.3",
"web-vitals": "^1.1.1"
},
"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": {
"eslint": "^7.25.0",
"eslint-plugin-react": "^7.23.2"
}
}
any help is very appreciated
I was working on a new react project and had set up my ESlint which was running fine before I changed code in another file and now it's giving me an error:
Error: Unexpected token 'export'
I'm new to eslint and so I'm using all the default settings that are remended however I'm hesitant to post this just because I feel like this may be a formatting error on my part. Any help would be greatly appreciated.
Here is my ESlint file:
export default{
"env": {
"browser": true,
"es2021": true
},
"extends": [
"eslint:remended",
"plugin:react/remended"
],
"parserOptions": {
"ecmaFeatures": {
"jsx": true
},
"ecmaVersion": 12,
"sourceType": "module"
},
"plugins": [
"react"
],
"rules": {
"no-extra-semi":"error"
}
};
and here is the Package's json:
{
"name": "testapp",
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^5.12.0",
"@testing-library/react": "^11.2.6",
"@testing-library/user-event": "^12.8.3",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-scripts": "4.0.3",
"web-vitals": "^1.1.1"
},
"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": {
"eslint": "^7.25.0",
"eslint-plugin-react": "^7.23.2"
}
}
any help is very appreciated
Share Improve this question asked May 8, 2021 at 14:23 William AddisonWilliam Addison 911 silver badge4 bronze badges2 Answers
Reset to default 1fix mine by replacing
export default {}
with
module.exports = {}
An error may occur due to the format of the ESLint configuration file.
To export CommonJS:
//eslint.config.cjs
module.exports = {}
For modular (ES6+) export:
//.eslintrc.js
export default []
Example for JSX-modules:
//eslint.config.js
export default [{
languageOptions: {
parserOptions: {
ecmaFeatures: {
jsx: true,
modules: true,
},
},
},
}]
本文标签: javascriptReact Project ESlint error quotUnexpected Token ExportquotStack Overflow
版权声明:本文标题:javascript - React Project ESlint error "Unexpected Token Export" - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745259829a2650305.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论