Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JSX not allowed in files with extension '.tsx'eslint(react/jsx-filename-extension)

In .tsx file, why does eslint report:

JSX not allowed in files with extension '.tsx'eslint(react/jsx-filename-extension)

How can I update the eslint config can resolve this message:

enter image description here

like image 381
Baochang Li Avatar asked Apr 10 '19 14:04

Baochang Li


2 Answers

You probably want to configure the react/jsx-filename-extension rule in your .eslintrc.js so that ESLint is happy about JSX inside your TypeScript files:

rules:  {
  'react/jsx-filename-extension': [2, { 'extensions': ['.js', '.jsx', '.ts', '.tsx'] }],
},
like image 118
dmudro Avatar answered Nov 04 '22 02:11

dmudro


Add this rule under the rules section of your eslint configuration:

"rules": {
  "react/jsx-filename-extension": [1, { "extensions": [".tsx", ".ts"] }]
}
like image 44
Raymond Wachaga Avatar answered Nov 04 '22 02:11

Raymond Wachaga