So this is my index.tsx:
JavaScript
x
16
16
1
import React from 'react';
2
import { createRoot } from 'react-dom/client';
3
4
import App from './App';
5
6
7
const container = document.getElementById('root')!;
8
const root = createRoot(container);
9
root.render(
10
<React.StrictMode>
11
<App />
12
</React.StrictMode>
13
);
14
15
16
and this is my eslintrc.js:
JavaScript
1
25
25
1
module.exports = {
2
env: {
3
browser: true,
4
es2021: true
5
},
6
extends: ['plugin:react/recommended', 'prettier'],
7
overrides: [
8
{
9
files: ['*.ts', '*.tsx'],
10
parserOptions: {
11
project: ['./tsconfig.json']
12
}
13
}
14
],
15
parserOptions: {
16
parser: 'babel-eslint',
17
ecmaFeatures: {
18
jsx: true
19
},
20
ecmaVersion: 'latest',
21
sourceType: 'module'
22
},
23
plugins: ['react', '@typescript-eslint', 'prettier', 'simple-import-sort'],
24
25
i have tried to install babel-eslint, and add it like a parser? but it didin`t help
so here`s the question, how to solve the problem “error Parsing error: Unexpected token !”?
Advertisement
Answer
Set typescript-eslint
as your parser by adding "parser": "@typescript-eslint/parser",
.