-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Upgrade: Reduce number of false-positive migrations of the important modifier #14737
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
Upgrade: Reduce number of false-positive migrations of the important modifier #14737
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. Join @philipp-spiess and the rest of your teammates on |
929dec1
to
7f5f83b
Compare
7f5f83b
to
efa812f
Compare
packages/@tailwindcss-upgrade/src/template/codemods/important.ts
Outdated
Show resolved
Hide resolved
) { | ||
continue | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we in theory scan backwards and forwards to look for quotes _on the same line? I feel like this logic may be too restrictive.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
liked that, implemented 😎
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that change disappeared — don't see it in the diff 😬
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@thecrypticace forgot to push it 🫠
b8bc6a9
to
0799c2d
Compare
dfc38cd
to
c1207c2
Compare
packages/@tailwindcss-upgrade/src/template/codemods/important.ts
Outdated
Show resolved
Hide resolved
Merge activity
|
…modifier (#14737) The important candidate migration is one of the most broad we have since it matches for any utility that are prefixed with an exclamation mark. When running the codemodes on our example projects, we noticed that this was instead creating false-positives with candidates used in code positions, e.g: ```ts export default { shouldNotUse: !border.shouldUse, } ``` To prevent false-positives, this PR adds a heuristics to detect wether or not a candidate is used in a non-code position. We do this by checking the character before and after the modifier and only allow quotes or spaces. This can cause candidates to not migrate that are valid Tailwind CSS classes, e.g.: ```ts let classNames = `!underline${isHovered ? ' font-bold' : ''}` ``` This, however, is not a big issue since v4 can parse the v3 important prefix too.
e1f0adf
to
34f708a
Compare
…modifier (#14737) The important candidate migration is one of the most broad we have since it matches for any utility that are prefixed with an exclamation mark. When running the codemodes on our example projects, we noticed that this was instead creating false-positives with candidates used in code positions, e.g: ```ts export default { shouldNotUse: !border.shouldUse, } ``` To prevent false-positives, this PR adds a heuristics to detect wether or not a candidate is used in a non-code position. We do this by checking the character before and after the modifier and only allow quotes or spaces. This can cause candidates to not migrate that are valid Tailwind CSS classes, e.g.: ```ts let classNames = `!underline${isHovered ? ' font-bold' : ''}` ``` This, however, is not a big issue since v4 can parse the v3 important prefix too.
34f708a
to
338a780
Compare
The important candidate migration is one of the most broad we have since it matches for any utility that are prefixed with an exclamation mark.
When running the codemodes on our example projects, we noticed that this was instead creating false-positives with candidates used in code positions, e.g:
To prevent false-positives, this PR adds a heuristics to detect wether or not a candidate is used in a non-code position. We do this by checking the character before and after the modifier and only allow quotes or spaces.
This can cause candidates to not migrate that are valid Tailwind CSS classes, e.g.:
This, however, is not a big issue since v4 can parse the v3 important prefix too.