Skip to content

Rule Change: Add allowSelectors option to "use-baseline" rule #210

@Grapedge

Description

@Grapedge

What rule do you want to change?

use-baseline

What change do you want to make?

Generate fewer warnings

How do you think the change should be implemented?

A new option

Example code

.foo {
  &:hover {
    color: red;
  }
}

What does the rule currently do for this code?

Selector 'nesting' is not a widely available baseline feature.

What will the rule do after it's changed?

After the change, if a selector is included in allowSelectors, it will not report an error even if it's not a baseline feature.

import css from '@eslint/css';

export default {
  files: ['**/*.css'],
  language: 'css/css',
  plugins: { css },
  languageOptions: {
    tolerant: true,
  },
  rules: {
    'css/use-baseline': [
      'error',
      { 
        available: 2021, 
        allowSelectors: ['nesting']  // ✅ New option
      }
    ],
  },
};

Participation

  • I am willing to submit a pull request to implement this change.

Additional comments

Our project uses PostCSS to process CSS nesting selector syntax, so the syntax in the Example code is valid for our environment.

We currently cannot set the 'css/use-baseline' rule to 'error' because it would generate numerous false positives in our codebase.

We hope to configure an allowlist of non-baseline selectors in ESLint to prevent errors when using PostCSS features.

I'm uncertain whether similar allow-list options should be supported for other CSS constructs like properties, at-rules, media conditions or types. Currently, I don't know if anyone actually needs these.

Metadata

Metadata

Assignees

Labels

acceptedThere is consensus among the team that this change meets the criteria for inclusionenhancementNew feature or request

Type

No type

Projects

Status

Implementing

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions