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

Add rule: enforce-class-compile to eslint-plugin #3505

Closed
4 tasks done
levchak0910 opened this issue Jan 11, 2024 · 0 comments · Fixed by #3506
Closed
4 tasks done

Add rule: enforce-class-compile to eslint-plugin #3505

levchak0910 opened this issue Jan 11, 2024 · 0 comments · Fixed by #3506

Comments

@levchak0910
Copy link
Contributor

Clear and concise description of the problem

It would be great to have some automated solution when developers want to use a compile class transformer across the whole project

Suggested solution

The possible solution is to add a new ESLint rule, which can handle it

Example:

<div
-  class="flex p-2"
+  class=":uno: flex p-2"
-  :class="'flex p-2'"
+  :class="':uno: flex p-2'"
-  :class="{flex}"
+  :class="{':uno: flex': flex}"
></div>

Alternative

Alternative 1: First I tried to omit an :uno: prefix by using custom regexp /(?<quot>["'`])([^$\n"'`]+?)(?:\k<quot>)/g but it can brake the app when attribute value is the same as relevant uno class. The value will be replaced with uno-<hash>, which is not desired

Example:

<input type="hidden">

will be replaced with

<input type="uno-<hash>">

Alternative 2: create a Vite plugin that will statically analyze the code and add an :uno: prefix to all class attributes/directives.

Disadvantages:

  • can take a lot of time to implement
  • it enforces class compilation without the ability to partially apply compilation and thence developers have no leverage over it

Additional context

No response

Validations

  • Read the Contributing Guidelines.
  • Read the README.md of using the package.
  • Already used the Interactive Docs.
  • Check that there isn't already an issue that request the same feature to avoid creating a duplicate.
github-merge-queue bot pushed a commit that referenced this issue Mar 14, 2024
…3506)

Co-authored-by: Jacob Bowdoin <7559478+jacob-8@users.noreply.github.com>
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 a pull request may close this issue.

1 participant