Skip to content

Change Request: Support JSX references #645

Open
@nzakas

Description

Which packages would you like to change?

  • espree
  • eslint-scope
  • eslint-visitor-keys

What problem do you want to solve?

Currently, eslint-scope does not recognize JSX tag as references to imported bindings, such as:

import { Foo } from "./components/foo.js";

export function render() {
    return <Foo />
}

This means any rule that wants to work with JSX needs to track references themselves.

Initially we didn't track JSX references because we weren't sure if JSX would stick around, and if so, whether the semantics would remain the same. At this point, all of the frameworks using JSX treat it the same, so I think it's time to update this behavior.

What do you think is the correct solution?

We could add a new option, jsx (not married to that name) that, when set to true, will add JSX tags as references for imported symbols.

Implementing as an option means it's not a breaking change, and we could choose to turn it on in ESLint whenever we want (first with a flag, then with a major release).

Participation

  • I am willing to submit a pull request for this change.

Additional comments

No response

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    • Status

      Ready to Implement

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions