一、问题
react typescript项目下执行eslint --init
后报错:
1 |
JSX not allowed in files with extension '.tsx' react/jsx-filename-extension |
二、解决
在.eslintrc.json
中添加rules
设置
1 |
'react/jsx-filename-extension': 'off', |
或者
1 2 3 4 5 6 |
"react/jsx-filename-extension": [ "error", { "extensions": [".js", ".jsx", ".tsx", ".ts"] } ] |
参考文章:
JSX not allowed in files with extension ‘.tsx’eslint(react/jsx-filename-extension) #58