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 Tailwindcss class sorter #441

Closed
2 of 4 tasks
dev-cetus opened this issue May 20, 2024 · 8 comments
Closed
2 of 4 tasks

Add Tailwindcss class sorter #441

dev-cetus opened this issue May 20, 2024 · 8 comments

Comments

@dev-cetus
Copy link

Describe the feature

it would be nice to be able to activate an option to enable the tailwindcss class sorter

Additional information

  • Would you be willing to help implement this feature?
  • Could this feature be implemented as a module?

Final checks

@meirroth
Copy link
Contributor

Hey @dev-cetus, the class sorter is a prettier plugin, so not handled with eslint.

To get it working once you've integrated prettier with eslint, you simply add the following line to your .prettierrc file:

  "plugins": ["prettier-plugin-tailwindcss"]

@dev-cetus
Copy link
Author

hey!
on the tailwind page they offer the module for prettier, but there is also one for eslint -> https://www.npmjs.com/package/eslint-plugin-tailwindcss

@shinGangan
Copy link
Contributor

Hi @dev-cetus , thank you for the great suggestion. I have one question regarding this issue.

  • Q. Will all Nuxt users benefit from adding this plugin?

The addition of this plugin is nice for Tailwind CSS users, but unnecessary for users who don't use Tailwind CSS.
I use Nuxt UI so I can benefit from it, but not all Nuxt users.

It is questionable to add rules as official modules that do not benefit all Nuxt users.

@dev-cetus
Copy link
Author

Hi @shinGangan !
Yes you're right, it will only be useful for tailwindcss users, as this plugin is only useful for eslint users. I suggest tailwindcss because that's what I use, but if unocss, bootstrap and other ui frameworks offer a class sorter, then they should be added.

@shinGangan
Copy link
Contributor

shinGangan commented May 20, 2024

@dev-cetus , thanks for comment!

As a web application developer, I agree with this opinion.
If the rules are used in other UI frameworks, I would be happy if they were introduced, as the settings would be reduced.

I suggest tailwindcss because that's what I use, but if unocss, bootstrap and other ui frameworks offer a class sorter, then they should be added.

However, I think it is better to consider topics related to Nuxt Framework and topics related to UI Framework separately from a maintenance perspective.
I think it's better for each UI Framework user to set their own rules.

@meirroth
Copy link
Contributor

This module is designed to be easily extensible, so I don't see why it should include rules for specific libraries.

@antfu antfu closed this as not planned Won't fix, can't repro, duplicate, stale May 20, 2024
@antfu
Copy link
Member

antfu commented May 20, 2024

It could be extended by the tailwind module with the module hook. It's out-of-scope of this module.

@gwynhokkers
Copy link

Just in case anyone stumbles across this, you can easily use the module by including it in the eslint.config
npm i eslint-plugin-tailwindcss

import tailwind from 'eslint-plugin-tailwindcss'
import withNuxt from './.nuxt/eslint.config.mjs'

export default withNuxt(
	{
		rules: {
		// Global
		// Vue
			'vue/multi-word-component-names': 0,
			'vue/max-attributes-per-line': [
				'warn',
				{
					singleline: {
						max: 5
					}
				}
			],
			'vue/no-v-html': 0
		}
	},
	...tailwind.configs['flat/recommended']
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants