From c9cfbfd75da0f94235a63caa9a325bc3d8ae29e3 Mon Sep 17 00:00:00 2001 From: "Kent C. Dodds" Date: Fri, 14 Jun 2024 09:51:55 -0600 Subject: [PATCH] fix(eslint): parse jsx with typescript I do not know why this is required, but it does not work otherwise --- eslint.js | 9 +++------ fixture/app/components/swizzle.jsx | 7 +++++++ 2 files changed, 10 insertions(+), 6 deletions(-) create mode 100644 fixture/app/components/swizzle.jsx diff --git a/eslint.js b/eslint.js index 313d469..f0794aa 100644 --- a/eslint.js +++ b/eslint.js @@ -1,8 +1,4 @@ import globals from 'globals' -import { - parser as typescriptParser, - plugin as typescriptPlugin, -} from 'typescript-eslint' const ERROR = 'error' const WARN = 'warn' @@ -81,6 +77,7 @@ export const config = [ react: (await import('eslint-plugin-react')).default, }, languageOptions: { + parser: (await import('typescript-eslint')).parser, parserOptions: { jsx: true, }, @@ -131,13 +128,13 @@ export const config = [ ? { files: ['**/*.ts?(x)'], languageOptions: { - parser: typescriptParser, + parser: (await import('typescript-eslint')).parser, parserOptions: { projectService: true, }, }, plugins: { - '@typescript-eslint': typescriptPlugin, + '@typescript-eslint': (await import('typescript-eslint')).plugin, }, rules: { '@typescript-eslint/no-unused-vars': [ diff --git a/fixture/app/components/swizzle.jsx b/fixture/app/components/swizzle.jsx new file mode 100644 index 0000000..48a3d16 --- /dev/null +++ b/fixture/app/components/swizzle.jsx @@ -0,0 +1,7 @@ +import { useState } from 'react' + +export function Counter() { + const [count, setCount] = useState(0) + const increment = () => setCount((c) => c + 1) + return +}