Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CI] Feature: Add a fixer for the no-imports-from-self lint #7284

Merged
merged 1 commit into from
Mar 4, 2025

Conversation

etrepum
Copy link
Collaborator

@etrepum etrepum commented Mar 4, 2025

Description

When an invalid import is generated (usually by vscode heuristics) we generally know what the import should be so we might as well provide a fixer at the same time.

Test plan

Before

Get a lint error when circularly importing a module

After

Also get a lint error, but make it fixable by replacing the package name with ., e.g. in

packages/lexical/src/LexicalNodeState.ts

import {NODE_STATE_KEY} from 'lexical';

Error: Exported module 'lexical' should not import from itself. Use a relative import instead.
Suggestion: Rename import 'lexical' to '.' (lexical/no-imports-from-self)

An also correct fix (and what is actually in that particular module right now) would be to do the import directly from the module that defines it:

import {NODE_STATE_KEY} from './LexicalConstants';

But given the toolchains we use either should work and produce the same build artifact. Worst case the user then gets a different error and they can track down which file actually exports that name.

Copy link

vercel bot commented Mar 4, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
lexical ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 4, 2025 6:25am
lexical-playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 4, 2025 6:25am

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Mar 4, 2025
@etrepum etrepum added this pull request to the merge queue Mar 4, 2025
Merged via the queue into facebook:main with commit 1cfa654 Mar 4, 2025
40 checks passed
@etrepum etrepum mentioned this pull request Mar 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants