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

feat(eslint-plugin): new nuxt-config-keys-order rule #491

Merged
merged 9 commits into from
Oct 14, 2024

Conversation

antfu
Copy link
Member

@antfu antfu commented Aug 29, 2024

Resolve #465

This PR introduces a new rule, nuxt/nuxt-config-keys-order, that sorts keys inside nuxt.config.* to a pre-defined order for consistency. The rule by default is only enable when stylistic is also enabled. But you could also explicitly control it:

export default defineNuxtConfig({
  eslint: {
    config: {
      nuxt: {
        sortConfigKeys: true
      }
    }
  }
})

Copy link

cloudflare-workers-and-pages bot commented Aug 29, 2024

Deploying nuxt-eslint with  Cloudflare Pages  Cloudflare Pages

Latest commit: ea1d2df
Status: ✅  Deploy successful!
Preview URL: https://fb1f7011.nuxt-eslint.pages.dev
Branch Preview URL: https://feat-rule-config-orders.nuxt-eslint.pages.dev

View logs

@antfu antfu marked this pull request as ready for review August 29, 2024 16:03
@antfu
Copy link
Member Author

antfu commented Oct 12, 2024

/cc @danielroe I am Trying to do what we discussed yesterday; I love the idea of enabling this rule only when stylistic is enabled. I tried to extends the config to have stylistic.nuxtConfigSort but now I found out this way, the stylistic config would always enable even if I only want to sort the config (can be provided by other config, or they just want to use Prettier). Thus I am thinking of moving it to nuxt.sortConfigKeys instead to separate from stylistic, but we could still read the stylistic flag to set the default. Just a heads-up in case if you other ideas.

@antfu antfu merged commit b65a80a into main Oct 14, 2024
4 checks passed
@antfu antfu deleted the feat/rule-config-orders branch October 14, 2024 06:13
'colorMode',
'content',
'mdc',
'ui',

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@antfu I think you forgot @nuxt/eslint itself

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 this pull request may close these issues.

Add rule(s) to sort keys in nuxt.config.ts to keep everything in order
2 participants