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

Add a check for interpolated variables to node-sass workflow and fix wrong variables #38283

Merged
merged 13 commits into from Mar 27, 2023

Conversation

julien-deramond
Copy link
Member

@julien-deramond julien-deramond commented Mar 20, 2023

Description

This PR closes #38278:

Type of changes

  • Bug fix (non-breaking change which fixes an issue)

Checklist

  • I have read the contributing guidelines
  • My code follows the code style of the project (using npm run lint)
  • (N/A) My change introduces changes to the documentation
  • (N/A) I have updated the documentation accordingly
  • (N/A) I have added tests to cover my changes
  • All new and existing tests passed

Related issues

Closes #38278

@danny007in
Copy link

better to implement stylelint

@julien-deramond
Copy link
Member Author

better to implement stylelint

Do you mean to check our Sass files to avoid to forget any interpolations, or in the GitHub workflow that tries the compilation with node-sass (which isn't the default one)? Or both?

@danny007in
Copy link

better to implement stylelint

Do you mean to check our Sass files to avoid to forget any interpolations, or in the GitHub workflow that tries the compilation with node-sass (which isn't the default one)? Or both?

Yes, Check https://github.com/stylelint-scss/stylelint-scss/tree/master/src/rules/dollar-variable-no-missing-interpolation

@julien-deramond
Copy link
Member Author

Yes, Check https://github.com/stylelint-scss/stylelint-scss/tree/master/src/rules/dollar-variable-no-missing-interpolation

Just tried it.

The following use case generates an error like explained in the example:

.class {
  $var: "my-anim";
  animation-name: $var;
//
// This variable needs to be interpolated
// because its value is a string
}

But margin-left: calc($btn-border-width * -1); isn't. Unless I'm missing something which is possible, this solution doesn't seem to help in this use case.

@julien-deramond julien-deramond mentioned this pull request Mar 22, 2023
3 tasks
@XhmikosR
Copy link
Member

@julien-deramond maybe we should split the fixes to a new PR so that we merge it and then merge the CI change?

@XhmikosR XhmikosR changed the title Add check to node-sass workflow Add a check for interpolation variables to node-sass workflow Mar 22, 2023
@julien-deramond
Copy link
Member Author

Having everything in the same place, for now, is easier for me right to have a global view.
Once everything is checked on my side (check that there is no regression with these interpolation fixes), I can of course split the PR, no problem.

@kristerkari
Copy link

But margin-left: calc($btn-border-width * -1); isn't. Unless I'm missing something which is possible, this solution doesn't seem to help in this use case.

@julien-deramond @danny007in dollar-variable-no-missing-interpolation does not to handle calc, and the rule could be fixed to do that, but it probably is not able to report the need for interpolation unless the variable is defined in the same file as the calc.

@danny007in
Copy link

danny007in commented Mar 22, 2023

Check stylelint-scss/stylelint-scss#786

Copy link
Member

@mdo mdo 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 great to me, @julien-deramond! Feel free to merge whenever.

@julien-deramond julien-deramond marked this pull request as ready for review March 27, 2023 15:32
@julien-deramond julien-deramond requested a review from a team as a code owner March 27, 2023 15:32
@julien-deramond
Copy link
Member Author

I've double-checked a part of the use cases. Interpolation is working well. Since @mdo has already reviewed it, let's :shipit:

@julien-deramond julien-deramond merged commit 92f9dda into main Mar 27, 2023
13 of 14 checks passed
@julien-deramond julien-deramond deleted the main-jd-fix-node-sass-compilation branch March 27, 2023 15:34
@XhmikosR
Copy link
Member

It should have been split into separate PRs... Anyway, keep it on mind for the future.

Because the Sass changes were real bugs and unrelated to the CI addition.

@XhmikosR XhmikosR changed the title Add a check for interpolation variables to node-sass workflow Add a check for interpolation variables to node-sass workflow and fix wrong variables Mar 31, 2023
@XhmikosR XhmikosR changed the title Add a check for interpolation variables to node-sass workflow and fix wrong variables Add a check for interpolated variables to node-sass workflow and fix wrong variables Mar 31, 2023
@mahilanmjd mahilanmjd mentioned this pull request Apr 16, 2023
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
No open projects
Status: Ready to merge
Development

Successfully merging this pull request may close these issues.

node-sass calc($val) issue
5 participants