Skip to content

linter: isSpaceBetweenTokens falsely returns true for react/jsx-equals-spacing via jsPlugin #21306

Description

@RioShopfront

What version of Oxlint are you using?

1.59.0

What command did you run?

oxlint

What does your .oxlintrc.json (or oxlint.config.ts) config file look like?

import { defineConfig, type OxlintConfig } from "oxlint";

export default defineConfig<OxlintConfig>({
    jsPlugins: [{
        name     : "react-js",
        specifier: "eslint-plugin-react",
    }],
    rules: {
        "react-js/jsx-equals-spacing"          : [ "error", "never" ],
    },
});

What happened?

I am wanting to use the rule react/jsx-equals-spacing via a jsPlugin, however it is producing false reports in code such as below.

const myElement = (subject = "Hello World") => {
    return (
        <span className="email-compose-field-label main">
                      ^^^
            Subject: {subject}
        </span>
    );
};

The rule reports that a space is found after the className=.

The rule makes use of isSpaceBetweenTokens to find a space between the "=" Punctuator and "email-compose-field-label main" Literal.

Within isSpaceBetweenTokens the getTokenOrComment returns a JSXText for this string literal ""email-compose-field-label main"" and the regex considers this to contain a whitespace.

getTokenOrComment at an index within a string literal shouldn't be returning a JSXText. Both the ESTree AST and Rust AST consider it as a string literal.

If it helps with testing, I found that replacing isSpaceBetweenTokens in this rule with isSpaceBetween allows it to behave as expected.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Fields

    Priority

    None yet

    Effort

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions