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 block-no-redundant-nesting rule #872

Merged
merged 4 commits into from
Oct 24, 2023
Merged

Add block-no-redundant-nesting rule #872

merged 4 commits into from
Oct 24, 2023

Conversation

FloEdelmann
Copy link
Contributor

Fixes #679.

.foo .bar {
}
.foo-bar-baz {
color: red
Copy link
Collaborator

Choose a reason for hiding this comment

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

Small thing, but it would nice if the autofix would indent the properties correctly :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't know if/how that's possible. Could you give me a hint?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Well, actually, the core stylelint package has removed all styling related rules, so maybe the indentation is something that we want to leave to tools like prettier instead (check https://github.com/stylelint/stylelint/blob/main/docs/migration-guide/to-15.md#deprecated-stylistic-rules)

@kristerkari
Copy link
Collaborator

Thanks! Looks good, just a couple of small things that I commented on :)

@kristerkari kristerkari changed the title Add block-no-unnecessary-nesting rule Add block-no-redundant-nesting rule Oct 24, 2023
@kristerkari
Copy link
Collaborator

One probablem that I noticed when reviewing this rule is that the rule does not seem to take into account that Sass supports nesting CSS properties.

This accepted test should pass:

    {
      code: `
        .foo {
          font: {
            size: 16px;
          }
        }
      `,
      description: "Sass' nested properties"
    }

...as it compiles to:

.foo {
  font-size: 16px;
}

Copy link
Collaborator

@kristerkari kristerkari left a comment

Choose a reason for hiding this comment

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

Thanks! Looks really good now 👍

I'll release this in the next release (currently missing only #867)

@kristerkari kristerkari merged commit 7ba3a96 into stylelint-scss:master Oct 24, 2023
11 checks passed
@FloEdelmann FloEdelmann deleted the block-no-unnecessary-nesting branch October 24, 2023 19:51
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.

Rule suggestion: block-no-unnecessary-child-block
2 participants