@w5s/eslint-config 3.12.0 → 3.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -10,10 +10,13 @@ export async function imports(options: imports.Options = {}) {
10
10
  const [importPlugin] = await Promise.all([interopDefault(import('eslint-plugin-import'))] as const);
11
11
  return [
12
12
  {
13
- name: 'w5s/import/rules',
13
+ name: 'w5s/import/setup',
14
14
  plugins: {
15
15
  import: importPlugin,
16
16
  },
17
+ },
18
+ {
19
+ name: 'w5s/import/rules',
17
20
  rules: {
18
21
  ...(recommended ? imports['recommended'] : {}),
19
22
  ...(stylisticEnabled
@@ -22,7 +25,7 @@ export async function imports(options: imports.Options = {}) {
22
25
  ...rules,
23
26
  },
24
27
  },
25
- ] as [Config] satisfies Array<Config>;
28
+ ] as [Config, Config] satisfies Array<Config>;
26
29
  }
27
30
 
28
31
  /**
@@ -3,13 +3,14 @@ import { interopDefault } from '@w5s/dev';
3
3
  import type { RuleOptions } from '../typegen/unicorn.js';
4
4
 
5
5
  import { sourceGlob } from '../glob.js';
6
+ import { withDefaultFiles } from '../internal/withDefaultFiles.js';
6
7
  import { type Config, type PluginOptionsBase, StylisticConfig } from '../type.js';
7
8
 
8
9
  const defaultFiles = [sourceGlob];
9
10
 
10
11
  export async function unicorn(options: unicorn.Options = {}) {
11
12
  const [unicornPlugin] = await Promise.all([interopDefault(import('eslint-plugin-unicorn'))] as const);
12
- const { files = defaultFiles, recommended = true, rules = {}, stylistic = true } = options;
13
+ const { files, recommended = true, rules = {}, stylistic = true } = options;
13
14
  const { enabled: stylisticEnabled } = StylisticConfig.from(stylistic);
14
15
 
15
16
  return [
@@ -20,7 +21,7 @@ export async function unicorn(options: unicorn.Options = {}) {
20
21
  },
21
22
  },
22
23
  {
23
- files,
24
+ files: withDefaultFiles(files, defaultFiles),
24
25
  name: 'w5s/unicorn/rules',
25
26
  rules: {
26
27
  ...(recommended && unicornPlugin.configs['unopinionated'].rules),
@@ -56,11 +56,16 @@ export async function defineConfig(options: DefineConfigOptions = {}) {
56
56
  const stylisticOptions =
57
57
  typeof plugins.stylistic === 'boolean' ? { enabled: plugins.stylistic } : { enabled: true, ...plugins.stylistic };
58
58
  const withDefaultStylistic = <T>(_options: T) => ({ stylistic: stylisticOptions, ..._options });
59
- const toOption = <T extends {}>(optionsOrBoolean: boolean | T | undefined) =>
59
+ const toOption = <T extends {}>(
60
+ optionsOrBoolean: boolean | T | undefined,
61
+ defaultEnabled = true,
62
+ ) =>
60
63
  withDefaultStylistic(
61
64
  (typeof optionsOrBoolean === 'boolean'
62
65
  ? { enabled: optionsOrBoolean }
63
- : { enabled: true, ...optionsOrBoolean }) as T & { enabled: boolean },
66
+ : optionsOrBoolean === undefined
67
+ ? { enabled: defaultEnabled }
68
+ : { enabled: defaultEnabled, ...optionsOrBoolean }) as T & { enabled: boolean },
64
69
  );
65
70
  const includeEnabled = <T extends { enabled?: boolean }, R extends Promise<readonly Config[]>>(factory: (config: T) => R, input: T) =>
66
71
  input.enabled ? [factory(input)] : [];
@@ -76,7 +81,7 @@ export async function defineConfig(options: DefineConfigOptions = {}) {
76
81
  ...includeEnabled(stylistic, toOption(plugins.stylistic)),
77
82
  ...includeEnabled(imports, toOption(plugins.import)),
78
83
  ...includeEnabled(markdown, toOption(plugins.markdown)),
79
- ...includeEnabled(next, toOption(plugins.next)),
84
+ ...includeEnabled(next, toOption(plugins.next, false)),
80
85
  ...includeEnabled(node, toOption(plugins.node)),
81
86
  ...includeEnabled(perfectionist, toOption(plugins.perfectionist)),
82
87
  ...includeEnabled(unicorn, toOption(plugins.unicorn)),