-
Notifications
You must be signed in to change notification settings - Fork 21
feat: add @supports condition awareness via ignoreWithinAtSupports #303
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
base: master
Are you sure you want to change the base?
Conversation
moa-io
commented
May 20, 2025
- Implement new ignoreWithinAtSupports option to skip browser compatibility warnings for features wrapped in valid @supports blocks
- Add comprehensive test cases covering:
- Basic @supports acceptance
- Nested conditions
- Logical operators (and/or/not)
- Edge cases with partial support
- Update documentation with new option usage examples
- Implement new ignoreWithinAtSupports option to skip browser compatibility warnings for features wrapped in valid @supports blocks - Add comprehensive test cases covering: * Basic @supports acceptance * Nested conditions * Logical operators (and/or/not) * Edge cases with partial support - Update documentation with new option usage examples
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Implements a new ignoreWithinAtSupports option that skips compatibility warnings for features inside valid @supports rules.
- Add
css-supports-parserdependency and bump package version - Implement
isFeatureInPositiveSupportsConditionlogic and integrateignoreWithinAtSupportsin the main rule - Add comprehensive tests covering basic, nested, logical, and edge‐case scenarios
- Update README with usage and behavior examples
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| package.json | Bumped version and added css-supports-parser dependency |
| lib/index.js | Added parsing logic and ignoreWithinAtSupports handling |
| lib/index.test.js | New tests for ignoreWithinAtSupports across various scenarios |
| README.md | Documented the new option with examples |
| { | ||
| code: '@supports (width: 1rem) { div { width: 1rem; } }', | ||
| description: | ||
| 'should acceot partial support when ignorePartialSupport=false while declared as condition', |
Copilot
AI
May 28, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix typo in test description: change "acceot" to "accept".
| 'should acceot partial support when ignorePartialSupport=false while declared as condition', | |
| 'should accept partial support when ignorePartialSupport=false while declared as condition', |
| { | ||
| code: '@supports (width: 1rem) { div { width: 1rem; } }', | ||
| description: | ||
| 'should acceot partial support when ignorePartialSupport=false while declared as condition', |
Copilot
AI
May 28, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update description to reference ignoreWithinAtSupports rather than ignorePartialSupport to match the test's intent.
| 'should acceot partial support when ignorePartialSupport=false while declared as condition', | |
| 'should accept partial support when ignoreWithinAtSupports=false while declared as condition', |
|
|
||
| const parser = supportsMap.get(parent.params); | ||
|
|
||
| switch (parser.checkProperty(node.toString())) { |
Copilot
AI
May 28, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Handle the case where checkProperty returns undefined (neither true nor false) to avoid treating unsupported conditions as supported; consider adding a default case to the switch.
| /** | ||
| * @type {Map<string, SupportsParser>} | ||
| */ | ||
| const supportsMap = new Map(); |
Copilot
AI
May 28, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The global supportsMap is never cleared and could grow without bound across lint runs; consider scoping or clearing it to prevent a memory leak.
| /** | |
| * @type {Map<string, SupportsParser>} | |
| */ | |
| const supportsMap = new Map(); | |
| // Removed global declaration of supportsMap |
|
|
||
| const parser = supportsMap.get(parent.params); | ||
|
|
||
| switch (parser.checkProperty(node.toString())) { |
Copilot
AI
May 28, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Rather than passing node.toString(), use the declaration's node.prop (e.g., 'display') to feed the parser only the property name for better accuracy and performance.
| switch (parser.checkProperty(node.toString())) { | |
| switch (parser.checkProperty(node.prop)) { |