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

Consider the use of sass modules in at-each-key-value-single-line rule #580

Merged
merged 4 commits into from
Dec 21, 2021
Merged

Consider the use of sass modules in at-each-key-value-single-line rule #580

merged 4 commits into from
Dec 21, 2021

Conversation

jhae-de
Copy link
Contributor

@jhae-de jhae-de commented Dec 5, 2021

The at-each-key-value-single-line rule does not report an error when set to true and using sass modules.

This should fail but it doesn't:

@use 'sass:map';

$font-weights: ("regular": 400, "medium": 500, "bold": 700);
@each $key in map.keys($font-weights) {
  $value: map.get($font-weights, $key);
}

This pull request changes the rule to take the use of sass modules into account.

@kristerkari
Copy link
Collaborator

Thanks! I'll try to review asap

@stof
Copy link
Contributor

stof commented Dec 8, 2021

This should support cases where the module is imported with a different namespace than the default map to be complete

@jhae-de jhae-de marked this pull request as draft December 8, 2021 20:48
@jhae-de jhae-de marked this pull request as ready for review December 8, 2021 22:14
@jhae-de
Copy link
Contributor Author

jhae-de commented Dec 8, 2021

Namespace support added. Thanks for your advice.

@kristerkari
Copy link
Collaborator

@jhae-de great job with adding so many test cases! I still need to go through the changes more in detail before I can approve.

src/rules/at-each-key-value-single-line/index.js Outdated Show resolved Hide resolved
src/utils/moduleNamespace.js Outdated Show resolved Hide resolved
@jhae-de
Copy link
Contributor Author

jhae-de commented Dec 9, 2021

Thank you for your review @stof. I added more test cases and hopefully solved all problems.

src/utils/moduleNamespace.js Outdated Show resolved Hide resolved
src/rules/at-each-key-value-single-line/index.js Outdated Show resolved Hide resolved
src/rules/at-each-key-value-single-line/index.js Outdated Show resolved Hide resolved
The `moduleNamespace` function now returns
- `null` if the namespace is removed with `as *`
- the custom namespace if it is set with `as ...`
- the default namespace in all other cases
@kristerkari
Copy link
Collaborator

I see that @stof has done a great job with the review here, so I trust that he can also say if he thinks that this is good to be merged now :) At least there are a lot of test cases!

@kristerkari
Copy link
Collaborator

@stof Could you please re-review this (as you have already reviewed the PR) to see if everything is ok now?

I could release a new minor version with this and the other PRs.

@kristerkari kristerkari merged commit 6712144 into stylelint-scss:master Dec 21, 2021
@kristerkari
Copy link
Collaborator

This was released in 4.1.0:
https://github.com/stylelint-scss/stylelint-scss/releases/tag/v4.1.0

Thank you @jhae-de and @stof !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants