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 a formatter option similar to @antfu/eslint-config. #477

Open
2 of 4 tasks
gsh1024 opened this issue Aug 12, 2024 · 3 comments
Open
2 of 4 tasks

Add a formatter option similar to @antfu/eslint-config. #477

gsh1024 opened this issue Aug 12, 2024 · 3 comments
Labels
enhancement New feature or request pr welcome

Comments

@gsh1024
Copy link

gsh1024 commented Aug 12, 2024

Describe the feature

Both @nuxt/eslint and @antfu/eslint-config do not format CSS by default. However, with @antfu/eslint-config, you can format CSS by installing the eslint-plugin-format plugin and then configuring the formatters option:

https://github.com/antfu/eslint-config?tab=readme-ov-file#formatters

@nuxt/eslint does not have this option. I went through the official documentation and only found a stylistic option, but this option only controls the formatting of JS and Vue files; it does not format CSS files:

https://eslint.nuxt.com/packages/module#eslint-stylistic

I had to configure Prettier myself to format CSS files. Wouldn't it be more convenient for developers if there was a formatters option similar to the one in @antfu/eslint-config?

Below is my test code and configuration. I intentionally messed up the formatting to test the formatting functionality of @nuxt/eslint:

<!-- The template will be automatically formatted -->
<template>
  <div>
<NuxtRouteAnnouncer />
    <NuxtWelcome />
  </div>
</template>

<!-- The script will be automatically formatted  -->
<script lang="ts" setup>
const str= "Hello, World!"
console.log(str)
</script>

<!-- The styles will not be automatically formatted -->
<style>body{color:red;
}
</style>

Additional information

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

Final checks

@antfu antfu added enhancement New feature or request and removed pending triage labels Aug 12, 2024
@antfu
Copy link
Member

antfu commented Aug 12, 2024

I am up to that, if more users agree on that (I personally would always use @antfu/eslint-config together, so I don't really need it myself, but I do understand it might be useful to have without bind to my personal config).

Also, PR welcome if anyone wants to work on that. Thanks!

@shinGangan
Copy link
Contributor

shinGangan commented Aug 16, 2024

Hello @gsh1024 , @antfu , I basically agree with this issue.

However, if you check the style in the Vue file, we believe that eslint-plugin-vue-scoped-css is a suitable role.
(This plugin was created by ota-meshi, the author of eslint-plguin-vue)

Therefore, I think the content of the discussion will change depending on whether the target is .css or style in the vue file.

@gsh1024
Copy link
Author

gsh1024 commented Aug 21, 2024

I ended up solving the problem using @antfu/eslint-config. 😭

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request pr welcome
Projects
None yet
Development

No branches or pull requests

3 participants