Skip to content

Conversation

@moa-io
Copy link

@moa-io 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
@RJWadley RJWadley requested a review from Copilot May 28, 2025 03:03
Copy link

Copilot AI left a 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-parser dependency and bump package version
  • Implement isFeatureInPositiveSupportsCondition logic and integrate ignoreWithinAtSupports in 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',
Copy link

Copilot AI May 28, 2025

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".

Suggested change
'should acceot partial support when ignorePartialSupport=false while declared as condition',
'should accept partial support when ignorePartialSupport=false while declared as condition',

Copilot uses AI. Check for mistakes.
{
code: '@supports (width: 1rem) { div { width: 1rem; } }',
description:
'should acceot partial support when ignorePartialSupport=false while declared as condition',
Copy link

Copilot AI May 28, 2025

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.

Suggested change
'should acceot partial support when ignorePartialSupport=false while declared as condition',
'should accept partial support when ignoreWithinAtSupports=false while declared as condition',

Copilot uses AI. Check for mistakes.

const parser = supportsMap.get(parent.params);

switch (parser.checkProperty(node.toString())) {
Copy link

Copilot AI May 28, 2025

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.

Copilot uses AI. Check for mistakes.
Comment on lines +15 to +18
/**
* @type {Map<string, SupportsParser>}
*/
const supportsMap = new Map();
Copy link

Copilot AI May 28, 2025

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.

Suggested change
/**
* @type {Map<string, SupportsParser>}
*/
const supportsMap = new Map();
// Removed global declaration of supportsMap

Copilot uses AI. Check for mistakes.

const parser = supportsMap.get(parent.params);

switch (parser.checkProperty(node.toString())) {
Copy link

Copilot AI May 28, 2025

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.

Suggested change
switch (parser.checkProperty(node.toString())) {
switch (parser.checkProperty(node.prop)) {

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant