Skip to content

ESLint configuration and TSX seem incompatible #663

Closed
@skirtles-code

Description

@skirtles-code

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

  1. Create a new project with npm create vue@latest.
  2. Select TypeScript, JSX and ESlint. Other options can be left as 'No'.
  3. Edit the <script> tag in App.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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions