Description
Describe the bug
This is a problem someone reported on the Vue Land Discord.
When creating a project with TypeScript, JSX and ESLint, the default ESLint configuration doesn't seem to support using TSX in .vue
files.
Encountered with create-vue
3.13.0.
Expected behavior
Either these options should work together, or a warning should be shown when creating the project indicating that this isn't supported.
How to reproduce
- Create a new project with
npm create vue@latest
. - Select TypeScript, JSX and ESlint. Other options can be left as 'No'.
- Edit the
<script>
tag inApp.vue
to use TSX. e.g.:
<script setup lang="tsx">
import HelloWorld from './components/HelloWorld.vue'
import TheWelcome from './components/TheWelcome.vue'
const A = <div>Hello</div>
</script>
This works fine for npm run dev
and npm run build
, but npm run lint
reports an error:
error Parsing error: Unterminated regular expression literal
Just setting lang="tsx"
, without any actual TSX code, reports a different error:
error Only "ts" can be used for the 'lang' attribute of '<script>' vue/block-lang
The person who reported this on Vue Land was totally new to Vue and (quite reasonably, I think) hadn't expected to need to make any manual config changes to get this to work.