From 168df434f70984a16a95f7335f656199738d9702 Mon Sep 17 00:00:00 2001 From: Benedict Lee Date: Wed, 26 Nov 2025 12:00:14 +0800 Subject: [PATCH 1/2] feat: do not skip files not named `nuxt.config` This allows users to use this rule in their ESLint configs with other files as this rule would skip processing any file not matching the name, effectively ignoring ESLint configs applying it to other files --- .../eslint-plugin/src/rules/nuxt-config-keys-order/index.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/packages/eslint-plugin/src/rules/nuxt-config-keys-order/index.ts b/packages/eslint-plugin/src/rules/nuxt-config-keys-order/index.ts index e6dfe94a..e3435937 100644 --- a/packages/eslint-plugin/src/rules/nuxt-config-keys-order/index.ts +++ b/packages/eslint-plugin/src/rules/nuxt-config-keys-order/index.ts @@ -21,10 +21,6 @@ export const rule = createRule({ }, defaultOptions: [], create(context) { - if (!context.filename.match(/nuxt\.config\.[mc]?[jt]sx?$/)) { - return {} - } - return { ExportDefaultDeclaration(node) { let object: Tree.ObjectExpression | undefined From eedb6ffa595e1cce4c8d04670b8627c109f475c4 Mon Sep 17 00:00:00 2001 From: Benedict Lee Date: Wed, 26 Nov 2025 12:21:10 +0800 Subject: [PATCH 2/2] feat: apply `sort-config` rule by default to Nuxt config files in `.config` Nuxt supports the [config-dir proposal](https://github.com/pi0/config-dir) in the code, though it seems to be left out of the docs at the moment. This commit only directly supports the convention for configs as defined in the proposal (i.e. `.config/.`). For other filenames, users can use the rule in their own ESLint configs --- packages/eslint-config/src/configs/nuxt.ts | 1 + .../eslint-config/test/__snapshots__/flat-compose.test.ts.snap | 1 + 2 files changed, 2 insertions(+) diff --git a/packages/eslint-config/src/configs/nuxt.ts b/packages/eslint-config/src/configs/nuxt.ts index afce073b..79863c3d 100644 --- a/packages/eslint-config/src/configs/nuxt.ts +++ b/packages/eslint-config/src/configs/nuxt.ts @@ -54,6 +54,7 @@ export default function nuxt(options: NuxtESLintConfigOptions): Linter.Config[] configs.push({ name: 'nuxt/sort-config', files: [ + '**/.config/nuxt.?([cm])[jt]s?(x)', '**/nuxt.config.?([cm])[jt]s?(x)', ], rules: { diff --git a/packages/eslint-config/test/__snapshots__/flat-compose.test.ts.snap b/packages/eslint-config/test/__snapshots__/flat-compose.test.ts.snap index 2a3f1247..cdd525a6 100644 --- a/packages/eslint-config/test/__snapshots__/flat-compose.test.ts.snap +++ b/packages/eslint-config/test/__snapshots__/flat-compose.test.ts.snap @@ -294,6 +294,7 @@ exports[`flat config composition > with stylistic 1`] = ` }, { "files": [ + "**/.config/nuxt.?([cm])[jt]s?(x)", "**/nuxt.config.?([cm])[jt]s?(x)", ], "name": "nuxt/sort-config",