Skip to content
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

New Rule: color-function-notation #76

Closed
1 task done
azat-io opened this issue Mar 1, 2025 · 4 comments
Closed
1 task done

New Rule: color-function-notation #76

azat-io opened this issue Mar 1, 2025 · 4 comments
Labels

Comments

@azat-io
Copy link
Contributor

azat-io commented Mar 1, 2025

Rule details

Specify modern or legacy notation for color-functions.

What type of rule is this?

Warns about a potential problem

Example code

There are two ways to set color notation.

Legacy:

.test {
  color: rgba(12, 122, 231, 0.2);
  background: oklch(0, 0, 0);
}

Modern:

.test {
  color: rgba(12 122 231 / 0.2);
  background: oklch(0 0 0);
}

I think it would be good to have a rule to check this.

{
  rules: {
    'color-function-notation': ['error', 'modern'],
  },
}

Participation

  • I am willing to submit a pull request to implement this rule.
@azat-io azat-io added the feature label Mar 1, 2025
@nzakas
Copy link
Member

nzakas commented Mar 3, 2025

This seems like it's enforcing a stylistic preference? Is there any functional difference between legacy and modern styles?

@nzakas nzakas added this to Triage Mar 3, 2025
@github-project-automation github-project-automation bot moved this to Needs Triage in Triage Mar 3, 2025
@nzakas nzakas moved this from Needs Triage to Triaging in Triage Mar 3, 2025
@azat-io
Copy link
Contributor Author

azat-io commented Mar 3, 2025

Yes, it's a stylistic change. Are stylistic rules planned to be maintained in a separate package?

@ota-meshi
Copy link
Member

I don't think that object-shorthand rule in eslint/js belongs to the stylistic rules, but I think that whether it's object-shorthand or not is functionally the same. (the object-shorthand rule has been frozen for a different reason)
If the rules that enforce the modern CSS notation are stylistic rules, I think that the eslint/js rules should also be reviewed. What do you think?

@nzakas
Copy link
Member

nzakas commented Mar 7, 2025

@ota-meshi these are two completely different concerns. @eslint/js has a lot of rules that we probably wouldn't include if building from scratch, but we aren't going to remove them due to compatibility issues.

For new packages, such as eslint/css, we are not going to include stylistic rules from the start. We don't plan on creating any plugins that focus specifically on stylistic rules -- we'll leave that to the ecosystem to produce if they so desire. In general, I think people should just use a source code formatter that does this automatically.

@nzakas nzakas closed this as not planned Won't fix, can't repro, duplicate, stale Mar 7, 2025
@github-project-automation github-project-automation bot moved this from Triaging to Complete in Triage Mar 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Complete
Development

No branches or pull requests

3 participants