Skip to content

feat: Add use-layers rule#27

Merged
mdjermanovic merged 10 commits into
mainfrom
issue18
Jan 15, 2025
Merged

feat: Add use-layers rule#27
mdjermanovic merged 10 commits into
mainfrom
issue18

Conversation

@nzakas

@nzakas nzakas commented Dec 4, 2024

Copy link
Copy Markdown
Member

Prerequisites checklist

What is the purpose of this pull request?

Add a new use-layers rule

What changes did you make? (Give an overview)

  • Added use-layers rule
  • Added tests
  • Added docs
  • Ensured the rule is exported from the plugin

Note: This rule is not recommended because it will likely only be useful on a subset of CSS files in any given project.

Related Issues

fixes #18

Is there anything you'd like reviewers to focus on?

@jeddy3

jeddy3 commented Dec 4, 2024

Copy link
Copy Markdown

Looks great!

Should @import require a layer by default? Right now it doesn't, but I feel like maybe it should.

I think so. I had the same thought before seeing this PR.

@nzakas

nzakas commented Dec 4, 2024

Copy link
Copy Markdown
Member Author

@fasttime I can't quite figure out why the type tests are failing now. Can you take a look?

@nzakas

nzakas commented Dec 4, 2024

Copy link
Copy Markdown
Member Author

@jeddy3 thanks, updated!

@nzakas

nzakas commented Dec 4, 2024

Copy link
Copy Markdown
Member Author

I think I figured out the types issue: #28

Comment thread src/rules/use-layers.js Outdated
@nzakas nzakas marked this pull request as ready for review December 5, 2024 19:09
@nzakas

nzakas commented Dec 5, 2024

Copy link
Copy Markdown
Member Author

I fixed the bug in CSS Tree with layer positioning. Just waiting for a new release to update this PR.

@fasttime fasttime added the accepted There is consensus among the team that this change meets the criteria for inclusion label Dec 6, 2024

@jeddy3 jeddy3 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I've added two suggestions for extra tests.

I think I'd find it more intuitive if the boolean options matched, i.e. both made the rule stricter or more permissive.

For example, either:

  • allowUnnamedLayers: false
  • allowUnLayeredImports: false

or:

  • requireNamedLayers: true
  • requireImportLayers: true

Comment thread tests/rules/use-layers.test.js
Comment thread tests/rules/use-layers.test.js
@nzakas

nzakas commented Dec 6, 2024

Copy link
Copy Markdown
Member Author

With CSSTree updated, all of the locations are now correct. 🎉

Comment thread src/rules/use-layers.js
Comment thread docs/rules/use-layers.md Outdated
Comment thread src/rules/use-layers.js Outdated
nzakas and others added 3 commits January 14, 2025 12:56
Co-authored-by: Milos Djermanovic <milos.djermanovic@gmail.com>
Co-authored-by: Milos Djermanovic <milos.djermanovic@gmail.com>
Co-authored-by: Milos Djermanovic <milos.djermanovic@gmail.com>

@mdjermanovic mdjermanovic left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, thanks!

@mdjermanovic mdjermanovic merged commit 6ebf57e into main Jan 15, 2025
@mdjermanovic mdjermanovic deleted the issue18 branch January 15, 2025 08:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

accepted There is consensus among the team that this change meets the criteria for inclusion feature

Projects

Status: Complete

Development

Successfully merging this pull request may close these issues.

New Rule: use-layers

4 participants