Skip to content

Commit 143b6c1

Browse files
fix: add nuxt overrides
1 parent da9cd89 commit 143b6c1

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

src/configs/vue.ts

+44
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import type { ESLint, Linter } from "eslint";
2+
import { isPackageExists } from "local-pkg";
23

4+
import { GLOB_SRC_EXT } from "../globs";
35
import type {
46
FlatConfigItem,
57
OptionsFiles,
@@ -25,6 +27,8 @@ type PluginVue = ESLint.Plugin & {
2527
};
2628
/* eslint-enable ts/naming-convention */
2729

30+
const NuxtPackages = ["nuxt"];
31+
2832
export async function vue(
2933
options: Readonly<
3034
Required<
@@ -43,6 +47,8 @@ export async function vue(
4347

4448
const { indent = 2 } = typeof stylistic === "boolean" ? {} : stylistic;
4549

50+
const isUsingNuxt = NuxtPackages.some((i) => isPackageExists(i));
51+
4652
const [pluginVue, pluginVueI18n, parserVue, processorVueBlocks, { mergeProcessors }] = (await loadPackages([
4753
"eslint-plugin-vue",
4854
"@intlify/eslint-plugin-vue-i18n",
@@ -255,5 +261,43 @@ export async function vue(
255261
...overrides,
256262
},
257263
},
264+
265+
...((isUsingNuxt
266+
? [
267+
{
268+
name: "rs:nuxt:rules:off",
269+
files,
270+
rules: {
271+
"import/default": "off",
272+
"import/named": "off",
273+
"import/namespace": "off",
274+
"import/no-unresolved": "off",
275+
},
276+
},
277+
{
278+
name: "rs:nuxt:rules",
279+
files: [
280+
// These pages are not used directly by users so they can have one-word names.
281+
`**/pages/**/*.{${GLOB_SRC_EXT},vue}`,
282+
`**/layouts/**/*.{${GLOB_SRC_EXT},vue}`,
283+
`**/app.{${GLOB_SRC_EXT},vue}`,
284+
`**/error.{${GLOB_SRC_EXT},vue}`,
285+
286+
// These files shouldn't have multiple words in their names as they are within subdirectories.
287+
`**/components/*/**/*.{${GLOB_SRC_EXT},vue}`,
288+
],
289+
rules: {
290+
"vue/multi-word-component-names": "off",
291+
},
292+
},
293+
{
294+
// Pages and layouts are required to have a single root element if transitions are enabled.
295+
files: [`**/pages/**/*.{${GLOB_SRC_EXT},vue}`, `**/layouts/**/*.{${GLOB_SRC_EXT},vue}`],
296+
rules: {
297+
"vue/no-multiple-template-root": "error",
298+
},
299+
},
300+
]
301+
: []) satisfies FlatConfigItem[]),
258302
];
259303
}

0 commit comments

Comments
 (0)