feat: new rule enforce-consistent-important-position#167
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
Adds a new ESLint rule enforce-consistent-important-position that enforces where the Tailwind CSS important modifier (!) appears in class names, supporting both legacy (start) and recommended (end) positions based on the Tailwind CSS version.
- Introduce shared utilities (
important-position.ts+ versioned async workers) to compute correct important‐modifier placement. - Define the ESLint rule logic and schema in
enforce-consistent-important-position.ts. - Provide a comprehensive test suite and update documentation/README for the new rule.
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/tailwindcss/important-position.ts | Core sync function and helpers (getDefaultPosition, getPositionWarning, getWorkerPath) |
| src/tailwindcss/important-position.async.worker.v4.ts | Worker bootstrap for v4 async implementation |
| src/tailwindcss/important-position.async.worker.v3.ts | Worker bootstrap for v3 async implementation |
| src/tailwindcss/important-position.async.v4.ts | Tailwind v4 logic for repositioning important modifiers |
| src/tailwindcss/important-position.async.v3.ts | Tailwind v3 logic for repositioning important modifiers |
| src/rules/enforce-consistent-important-position.ts | ESLint rule definition, option parsing, and integration with util functions |
| src/rules/enforce-consistent-important-position.test.ts | Vitest test suite covering both legacy and recommended positions across variants |
| docs/rules/enforce-consistent-important-position.md | Rule documentation with options, examples, and default behavior |
| README.md | Added the new rule to the rules table |
Comments suppressed due to low confidence (2)
src/rules/enforce-consistent-important-position.ts:65
- [nitpick] The rule description is quite generic. You may want to expand it to briefly mention both
legacyandrecommendedpositions for clarity in ESLint docs.
description: "Enforce consistent important position for classes.",
src/rules/enforce-consistent-important-position.test.ts:300
- There are no tests validating that a warning is emitted when using
recommendedposition on Tailwind CSS v3 (getPositionWarning). Consider adding a test case to cover that warning behavior.
it.runIf(getTailwindcssVersion().major <= TailwindcssVersion.V3)(`should use "legacy" as default position when no option is provided in tailwind <= 3`, () => {
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Recommended Position
New rule
enforce-consistent-important-positionLegacy Position
fixes #163