[英]React typescript eslint error Parsing error: Unexpected token ! How to fix this?
So this is my index.tsx:所以这是我的 index.tsx:
import React from 'react';
import { createRoot } from 'react-dom/client';
import App from './App';
const container = document.getElementById('root')!;
const root = createRoot(container);
root.render(
<React.StrictMode>
<App />
</React.StrictMode>
);
and this is my eslintrc.js:这是我的 eslintrc.js:
module.exports = {
env: {
browser: true,
es2021: true
},
extends: ['plugin:react/recommended', 'prettier'],
overrides: [
{
files: ['*.ts', '*.tsx'],
parserOptions: {
project: ['./tsconfig.json']
}
}
],
parserOptions: {
parser: 'babel-eslint',
ecmaFeatures: {
jsx: true
},
ecmaVersion: 'latest',
sourceType: 'module'
},
plugins: ['react', '@typescript-eslint', 'prettier', 'simple-import-sort'],
i have tried to install babel-eslint, and add it like a parser?我试过安装 babel-eslint,并像解析器一样添加它? but it didin`t help
但它没有帮助
so here`s the question, how to solve the problem "error Parsing error: Unexpected token?"?所以问题来了,如何解决“error Parsing error: Unexpected token?”的问题?
Set typescript-eslint
as your parser by adding "parser": "@typescript-eslint/parser",
.通过添加
"parser": "@typescript-eslint/parser",
将typescript-eslint
设置为您的解析器。
https://typescript-eslint.io/docs/ https://typescript-eslint.io/docs/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.