Skip to content

Commit 4485bc3

Browse files
committed
feat(projects): add overrides for options
1 parent 60049af commit 4485bc3

File tree

4 files changed

+34
-26
lines changed

4 files changed

+34
-26
lines changed

eslint.config.js

Lines changed: 21 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -11,30 +11,26 @@ const useBuild = false;
1111
/** @type {import('./src/index.ts').defineConfig} */
1212
const defineConfig = useBuild ? defineConfig2 : defineConfig1;
1313

14-
export default defineConfig(
15-
{
16-
vue: true,
17-
react: { files: ['**/*react.tsx'] },
18-
svelte: true,
19-
astro: true,
20-
unocss: false,
21-
formatter: {
22-
html: true,
23-
css: true,
24-
json: true,
25-
markdown: true,
26-
yaml: true,
27-
toml: true
28-
}
14+
export default defineConfig({
15+
vue: true,
16+
react: { files: ['**/*react.tsx'] },
17+
svelte: true,
18+
astro: true,
19+
unocss: false,
20+
formatter: {
21+
html: true,
22+
css: true,
23+
json: true,
24+
markdown: true,
25+
yaml: true,
26+
toml: true
2927
},
30-
{
31-
rules: {
32-
'vue/multi-word-component-names': [
33-
'warn',
34-
{
35-
ignores: ['index', 'App', '[id]']
36-
}
37-
]
38-
}
28+
overrides: {
29+
'vue/multi-word-component-names': [
30+
'warn',
31+
{
32+
ignores: ['index', 'App', '[id]']
33+
}
34+
]
3935
}
40-
);
36+
});

src/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ export async function defineConfig(options: Partial<Options> = {}, ...userConfig
3939
const prettier = await createPrettierConfig(opts.prettierRules);
4040
const formatter = await createFormatterConfig(opts.formatter, opts.prettierRules);
4141

42+
const overrides: FlatConfigItem = {
43+
rules: opts.overrides
44+
};
45+
4246
const userResolved = await Promise.all(userConfigs);
4347

4448
const configs: FlatConfigItem[] = [
@@ -55,6 +59,7 @@ export async function defineConfig(options: Partial<Options> = {}, ...userConfig
5559
...astro,
5660
...svelte,
5761
...unocss,
62+
overrides,
5863
...userResolved,
5964
...prettier,
6065
...formatter

src/options.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export async function createOptions(options: Partial<Options> = {}) {
88
const opts: ParsedOptions = {
99
cwd: process.cwd(),
1010
ignores: GLOB_EXCLUDE,
11+
overrides: {},
1112
prettierRules: {
1213
...DEFAULT_PRETTIER_RULES
1314
},
@@ -19,7 +20,7 @@ export async function createOptions(options: Partial<Options> = {}) {
1920
}
2021
};
2122

22-
const { cwd, ignores, prettierRules, usePrettierrc, formatter, unocss, ...rest } = options;
23+
const { cwd, ignores, overrides, prettierRules, usePrettierrc, formatter, unocss, ...rest } = options;
2324

2425
if (cwd) {
2526
opts.cwd = cwd;
@@ -29,6 +30,10 @@ export async function createOptions(options: Partial<Options> = {}) {
2930
opts.ignores = [...opts.ignores, ...ignores];
3031
}
3132

33+
if (overrides) {
34+
opts.overrides = overrides;
35+
}
36+
3237
if (prettierRules) {
3338
opts.prettierRules = { ...opts.prettierRules, ...prettierRules };
3439
}

src/types/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ export interface BaseOptions {
2121
cwd: string;
2222
/** The globs to ignore lint */
2323
ignores: string[];
24+
/** The override rules */
25+
overrides: FlatConfigItem['rules'];
2426
/**
2527
* Default prettier rules
2628
*

0 commit comments

Comments
 (0)