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

Fix function-calc-no-unspaced-operator false negatives #7655

Merged
merged 14 commits into from May 8, 2024

Conversation

ybiquitous
Copy link
Member

@ybiquitous ybiquitous commented Apr 26, 2024

Which issue, if any, is this issue related to?

Closes #7181
Closes #7618

This also fixes a bug reported on #7646 (comment).

Is there anything in the PR that needs further explanation?

This significantly changes the implementation by switching postcss-value-parser to @csstools/css-parser-algorithms. Because postcss-value-parser is inactive and leaves bugs for a while, and we've used already @csstools/css-parser-algorithms for some rules.

In addition, this updates tsconfig.json to support ES2023 libraries. This change uses Array.prototype.findLast(), which has been supported since Node.js 18.0.0.

Copy link

changeset-bot bot commented Apr 26, 2024

🦋 Changeset detected

Latest commit: c8d7979

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
stylelint Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@ybiquitous ybiquitous force-pushed the function-calc-no-unspaced-operator-bugfix branch from b8713a9 to 417458c Compare April 26, 2024 09:01
This significantly changes the implementation by switching `postcss-value-parser` to `@csstools/css-parser-algorithms`.
Because `postcss-value-parser` is inactive and leaves bugs for a while,
and we've used already `@csstools/css-parser-algorithms` for some rules.

In addition, this updates `tsconfig.json` to support ES2023 libraries.
This change uses `Array.prototype.findLast()`, which has been supported since Node.js 18.0.0.
See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findLast
@ybiquitous ybiquitous force-pushed the function-calc-no-unspaced-operator-bugfix branch from 417458c to b673910 Compare April 26, 2024 09:16
@ybiquitous ybiquitous marked this pull request as ready for review April 26, 2024 09:19
@ybiquitous
Copy link
Member Author

@romainmenke If I have done something wrong with @csstools/css-parser-algorithms, please feel free to point it out. 🙏🏼

@Mouvedia
Copy link
Contributor

support ES2023 libraries

🎉

@romainmenke
Copy link
Member

quick heads up, I will review this by Monday at the latest :)

@ybiquitous ybiquitous mentioned this pull request Apr 27, 2024
4 tasks
Copy link
Member

@romainmenke romainmenke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks really good @ybiquitous, thank you for this!

I've left a few notes here and also took a deep dive into this rule to see how I would approach it : #7670

There aren't any major issues with this change as far as I can tell 🎉

lib/reference/keywords.mjs Outdated Show resolved Hide resolved
lib/rules/function-calc-no-unspaced-operator/index.mjs Outdated Show resolved Hide resolved
lib/rules/function-calc-no-unspaced-operator/index.mjs Outdated Show resolved Hide resolved
lib/rules/function-calc-no-unspaced-operator/index.mjs Outdated Show resolved Hide resolved
lib/rules/function-calc-no-unspaced-operator/index.mjs Outdated Show resolved Hide resolved
lib/rules/function-calc-no-unspaced-operator/index.mjs Outdated Show resolved Hide resolved
lib/rules/function-calc-no-unspaced-operator/index.mjs Outdated Show resolved Hide resolved
lib/rules/function-calc-no-unspaced-operator/index.mjs Outdated Show resolved Hide resolved
@Mouvedia
Copy link
Contributor

Mouvedia commented May 1, 2024

Can you update this line?

@ybiquitous
Copy link
Member Author

Can you update this line?

Done! a4c2707

endColumn: 24,
},
{
code: 'a { padding: calc(1px+2px+3px); }',
Copy link
Contributor

@Mouvedia Mouvedia May 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one should be 'a { padding: calc(1px+2px + 3px); }' to catch #7181 regression.
i.e. invalid followed by valid

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But, autofixing to calc(1px + 2px + 3px) is better than calc(1px+2px + 3px), isn't it?

Copy link
Contributor

@Mouvedia Mouvedia May 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Look at the demo linked in the issue; as you can see it's not detected as invalid right now but calc(1px+2px+3px) is.
Hence we want calc(1px+2px + 3px) way more because it is/was a bug.
i.e. we want to pick an eventual regression

minor
non-blocking

lib/utils/typeGuards.cjs Outdated Show resolved Hide resolved
lib/rules/function-calc-no-unspaced-operator/index.mjs Outdated Show resolved Hide resolved
@Mouvedia
Copy link
Contributor

Mouvedia commented May 8, 2024

Thanks @romainmenke, having such a proactive member adapting our dependencies that fast is invaluable.

Copy link
Member

@romainmenke romainmenke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Thank you @ybiquitous for this update 🙇

@ybiquitous
Copy link
Member Author

Thanks for the review, all!

@ybiquitous ybiquitous merged commit 87ed665 into main May 8, 2024
17 checks passed
@ybiquitous ybiquitous deleted the function-calc-no-unspaced-operator-bugfix branch May 8, 2024 12:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants