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

Change Request: support CSS-in-JS #30

Open
1 task
rakleed opened this issue Dec 8, 2024 · 3 comments
Open
1 task

Change Request: support CSS-in-JS #30

rakleed opened this issue Dec 8, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@rakleed
Copy link

rakleed commented Dec 8, 2024

Environment

Node version: v22.11.0
npm version: v10.9.0
Local ESLint version: v9.16.0 (Currently used)
Global ESLint version: Not found
Operating System: darwin 24.1.0

What problem do you want to solve?

I'd like the plugin to work for CSS-in-JS solutions like styled-components, emotion, linaria and React inline styles.

What do you think is the correct solution?

In stylelint, you can use PostCSS parser for that purpose. Here is an example: https://github.com/hudochenkov/postcss-styled-syntax

So I guess #29 is related

Participation

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

Additional comments

No response

@rakleed rakleed added the enhancement New feature or request label Dec 8, 2024
@nzakas
Copy link
Member

nzakas commented Dec 9, 2024

@rakleed please explain what you mean by "support CSS-in-JS". Some examples would be helpful. (I'm not sure what exactly I'm supposed to be looking at in those links. Because I don't use CSS-in-JS, I'll need you to provide as much context as possible.)

@nzakas nzakas added this to Triage Dec 9, 2024
@github-project-automation github-project-automation bot moved this to Needs Triage in Triage Dec 9, 2024
@nzakas nzakas moved this from Needs Triage to Triaging in Triage Dec 9, 2024
@rakleed
Copy link
Author

rakleed commented Dec 9, 2024

This means that you can write CSS directly in JS files. See examples:

So you need to check the JS files, find such CSS code in template literals, and lint it.

In stylelint, you can use PostCSS parser for that purpose. Here is an example: https://github.com/hudochenkov/postcss-styled-syntax

So I guess #29 is related

@nzakas
Copy link
Member

nzakas commented Dec 10, 2024

Ah gotcha. This would actually be a multi-step process to get this working for ESLint.

First, we'd need to finish up work on this RFC:
eslint/rfcs#105

That would give ESLint the ability to pick out specific parts of a JavaScript file and mark it as CSS. ESLint would then be able to present all of the CSS and JS problems in one file.

The problem of interpolated values is one I'm not sure how to address.

I'll leave this issue open to track this request. Just be aware it's a non-trivial amount of work so likely won't be completed anytime soon.

@nzakas nzakas moved this from Triaging to Evaluating in Triage Dec 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Evaluating
Development

No branches or pull requests

2 participants