Skip to content

Can't parse .tsx files when placed last in the plugin list #41

@xavdid

Description

@xavdid

I wrote this whole thing only to realize the order of the plugins matters: swapping preact to the start of the list cleared everything up. So I'll leave it up as a possible improvement for the docs / other searchers, but there's probably not much action needed on your part.


After adding the preact plugin to my eslint config, I started getting parser erorrs on .tsx files. I followed the super basic setup from tseslint, plus your readme:

// eslint.config.ts

import js from "@eslint/js";
import { defineConfig } from "eslint/config";
import tseslint from "typescript-eslint";
import preact from 'eslint-config-preact';

export default defineConfig([
  js.configs.recommended,
  tseslint.configs.recommended,
  ...preact 
]);

I've got a pretty standard .tsx file:

import { useState } from "preact/hooks";

const GRAPH: Record<string, Record<string, number>> = {};

export const Calculator = () => {
  const [nodes, setNodes] = useState<string[]>([]);

  return <p>cool</p>
};

Then, when running eslint, I get:

  4:11  error  Parsing error: Missing initializer in const declaration. (4:11)

I believe the plugin is this is caused by using the estree for TS files, which means typescript syntax fails to parse. It can't handle type declarations.

Versions

  • eslint @ v9.34.0
  • eslint-config-preact @ 2.0.0
  • eslint-config-preact @ 8.42.0
  • @eslint/js @ 9.34.0
  • node @ 22.19.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions