@w5s/eslint-config 3.40.0 → 4.0.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@w5s/eslint-config",
3
- "version": "3.40.0",
3
+ "version": "4.0.0",
4
4
  "description": "ESLint configuration presets",
5
5
  "keywords": [
6
6
  "eslint",
@@ -46,12 +46,12 @@
46
46
  "@typescript-eslint/eslint-plugin": "~8.70.0",
47
47
  "@typescript-eslint/parser": "^8.65.0",
48
48
  "@vitest/eslint-plugin": "~1.6.20",
49
- "@w5s/dev": "^3.31.0",
50
- "@w5s/eslint-config-ignore": "^1.30.0",
51
- "@w5s/prettier-config": "^3.25.0",
49
+ "@w5s/dev": "^4.0.0",
50
+ "@w5s/eslint-config-ignore": "^1.31.0",
51
+ "@w5s/prettier-config": "^3.26.0",
52
52
  "eslint-merge-processors": "^2.0.0",
53
53
  "eslint-plugin-import": "~2.32.0",
54
- "eslint-plugin-jsdoc": "~64.4.0",
54
+ "eslint-plugin-jsdoc": "~64.5.0",
55
55
  "eslint-plugin-jsonc": "~3.4.0",
56
56
  "eslint-plugin-n": "~18.3.0",
57
57
  "eslint-plugin-perfectionist": "~5.11.0",
@@ -85,5 +85,5 @@
85
85
  "publishConfig": {
86
86
  "access": "public"
87
87
  },
88
- "gitHead": "c775b53274c35cb97edaa9ffa5cd5ffd47f9a4f0"
88
+ "gitHead": "ed181ba68ebff886310db849facb938bb00f61ca"
89
89
  }
@@ -3,8 +3,9 @@ import { interopDefault } from '@w5s/dev';
3
3
  import type { RuleOptions } from '../typegen/e18e.js';
4
4
 
5
5
  import { sourceGlob } from '../glob.js';
6
+ import { defaultPluginOptions } from '../internal/defaultOptions.js';
6
7
  import { withDefaultFiles } from '../internal/withDefaultFiles.js';
7
- import { type Config, type PluginOptionsBase, StylisticConfig } from '../type.js';
8
+ import { type Config, type PluginOptionsBase } from '../type.js';
8
9
 
9
10
  const defaultFiles = [sourceGlob];
10
11
 
@@ -14,19 +15,26 @@ const defaultFiles = [sourceGlob];
14
15
  */
15
16
  export async function e18e(options: e18e.Options = {}) {
16
17
  const [e18ePlugin] = await Promise.all([interopDefault(import('@e18e/eslint-plugin'))] as const);
17
- const { files, modernization = true, moduleReplacements = false, performanceImprovements = true, rules = {}, stylistic = true } = options;
18
- const { enabled: stylisticEnabled } = StylisticConfig.from(stylistic);
18
+ const {
19
+ files,
20
+ modernization = true,
21
+ moduleReplacements = false,
22
+ namespace,
23
+ performanceImprovements = true,
24
+ rules = {},
25
+ stylistic,
26
+ } = defaultPluginOptions(options);
19
27
 
20
28
  return [
21
29
  {
22
- name: 'w5s/e18e/setup',
30
+ name: `${namespace}/e18e/setup`,
23
31
  plugins: {
24
32
  e18e: e18ePlugin,
25
33
  },
26
34
  },
27
35
  {
28
36
  files: withDefaultFiles(files, defaultFiles),
29
- name: 'w5s/e18e/rules',
37
+ name: `${namespace}/e18e/rules`,
30
38
  rules: {
31
39
  ...modernization ? e18ePlugin.configs.modernization.rules : {},
32
40
  ...moduleReplacements ? e18ePlugin.configs.moduleReplacements.rules : {},
@@ -40,7 +48,7 @@ export async function e18e(options: e18e.Options = {}) {
40
48
  'e18e/prefer-array-to-spliced': 'off',
41
49
  'e18e/prefer-spread-syntax': 'off',
42
50
 
43
- ...(stylisticEnabled ? {} : {}),
51
+ ...(stylistic.enabled ? {} : {}),
44
52
  ...rules,
45
53
  },
46
54
  },
package/src/config/es.ts CHANGED
@@ -5,6 +5,7 @@ import globals from 'globals';
5
5
  import type { RuleOptions } from '../typegen/jsonc.js';
6
6
 
7
7
  import { esSourceGlob, sourceGlob } from '../glob.js';
8
+ import { defaultPluginOptions } from '../internal/defaultOptions.js';
8
9
  import { restrictedGlobals as defaultGlobalRestrictedGlobals } from '../restrictedGlobals.js';
9
10
  import { restrictedImportPaths as defaultGlobalRestrictedImportPaths } from '../restrictedImportPaths.js';
10
11
  import { restrictedSyntax as defaultGlobalRestrictedSyntax } from '../restrictedSyntax.js';
@@ -18,10 +19,11 @@ export async function es(options: es.Options) {
18
19
  defaultRestrictedGlobals = defaultGlobalRestrictedGlobals,
19
20
  defaultRestrictedImportPaths = defaultGlobalRestrictedImportPaths,
20
21
  defaultRestrictedSyntax = defaultGlobalRestrictedSyntax,
21
- recommended = true,
22
+ namespace,
23
+ recommended,
22
24
  restrictedImportPaths: paths,
23
25
  rules = {},
24
- } = options;
26
+ } = defaultPluginOptions(options);
25
27
  const resolvedGlobals =
26
28
  typeof options.restrictedGlobals === 'function'
27
29
  ? options.restrictedGlobals(defaultRestrictedGlobals)
@@ -59,11 +61,11 @@ export async function es(options: es.Options) {
59
61
  linterOptions: {
60
62
  reportUnusedDisableDirectives: true,
61
63
  },
62
- name: 'w5s/es/setup',
64
+ name: `${namespace}/es/setup`,
63
65
  },
64
66
  {
65
67
  files: [sourceGlob],
66
- name: 'w5s/source/restricted-rules',
68
+ name: `${namespace}/source/restricted-rules`,
67
69
  rules: {
68
70
  'no-restricted-globals': [
69
71
  'error',
@@ -83,7 +85,7 @@ export async function es(options: es.Options) {
83
85
  },
84
86
  {
85
87
  files: defaultFiles,
86
- name: 'w5s/es/rules',
88
+ name: `${namespace}/es/rules`,
87
89
  rules: {
88
90
  ...(recommended ? es.recommended : {}),
89
91
  ...rules,
@@ -2,24 +2,24 @@ import { interopDefault } from '@w5s/dev';
2
2
 
3
3
  import type { RuleOptions } from '../typegen/import.js';
4
4
 
5
- import { type Config, type PluginOptionsBase, StylisticConfig } from '../type.js';
5
+ import { defaultPluginOptions } from '../internal/defaultOptions.js';
6
+ import { type Config, type PluginOptionsBase } from '../type.js';
6
7
 
7
8
  export async function imports(options: imports.Options = {}) {
8
- const { recommended = true, rules = {}, stylistic = true } = options;
9
- const { enabled: stylisticEnabled } = StylisticConfig.from(stylistic);
9
+ const { namespace, recommended, rules = {}, stylistic } = defaultPluginOptions(options);
10
10
  const [importPlugin] = await Promise.all([interopDefault(import('eslint-plugin-import'))] as const);
11
11
  return [
12
12
  {
13
- name: 'w5s/import/setup',
13
+ name: `${namespace}/import/setup`,
14
14
  plugins: {
15
15
  import: importPlugin,
16
16
  },
17
17
  },
18
18
  {
19
- name: 'w5s/import/rules',
19
+ name: `${namespace}/import/rules`,
20
20
  rules: {
21
21
  ...(recommended ? imports.recommended : {}),
22
- ...(stylisticEnabled
22
+ ...(stylistic.enabled
23
23
  ? imports.stylistic
24
24
  : {}),
25
25
  ...rules,
@@ -3,8 +3,9 @@ import { interopDefault } from '@w5s/dev';
3
3
  import type { RuleOptions } from '../typegen/jsdoc.js';
4
4
 
5
5
  import { esSourceGlob, tsSourceGlob } from '../glob.js';
6
+ import { defaultPluginOptions } from '../internal/defaultOptions.js';
6
7
  import { withDefaultFiles } from '../internal/withDefaultFiles.js';
7
- import { type Config, type PluginOptionsBase, StylisticConfig } from '../type.js';
8
+ import { type Config, type PluginOptionsBase } from '../type.js';
8
9
 
9
10
  const defaultJsFiles = [esSourceGlob];
10
11
  const defaultTsFiles = [tsSourceGlob];
@@ -13,16 +14,16 @@ export async function jsdoc(options: jsdoc.Options = {}): Promise<ReadonlyArray<
13
14
  const [jsdocPlugin] = await Promise.all([interopDefault(import('eslint-plugin-jsdoc'))] as const);
14
15
  const {
15
16
  files,
16
- recommended = true,
17
+ namespace,
18
+ recommended,
17
19
  rules = {},
18
- stylistic = true,
19
- } = options;
20
- const { enabled: stylisticEnabled } = StylisticConfig.from(stylistic);
20
+ stylistic,
21
+ } = defaultPluginOptions(options);
21
22
 
22
23
  const recommendedRules = recommended
23
24
  ? jsdocPlugin.configs['flat/recommended-typescript-flavor'].rules
24
25
  : {};
25
- const stylisticRules = stylisticEnabled
26
+ const stylisticRules = stylistic.enabled
26
27
  ? {
27
28
  ...jsdocPlugin.configs['flat/stylistic-typescript-flavor'].rules,
28
29
  'jsdoc/check-alignment': 'warn',
@@ -33,14 +34,14 @@ export async function jsdoc(options: jsdoc.Options = {}): Promise<ReadonlyArray<
33
34
 
34
35
  return [
35
36
  {
36
- name: 'w5s/jsdoc/setup',
37
+ name: `${namespace}/jsdoc/setup`,
37
38
  plugins: {
38
39
  jsdoc: jsdocPlugin,
39
40
  },
40
41
  },
41
42
  {
42
43
  files: withDefaultFiles(files, defaultJsFiles),
43
- name: 'w5s/jsdoc/rules-js',
44
+ name: `${namespace}/jsdoc/rules-js`,
44
45
  rules: {
45
46
  ...recommendedRules,
46
47
 
@@ -68,7 +69,7 @@ export async function jsdoc(options: jsdoc.Options = {}): Promise<ReadonlyArray<
68
69
  },
69
70
  {
70
71
  files: withDefaultFiles(files, defaultTsFiles),
71
- name: 'w5s/jsdoc/rules-ts',
72
+ name: `${namespace}/jsdoc/rules-ts`,
72
73
  rules: {
73
74
  ...recommendedRules,
74
75
 
@@ -4,8 +4,9 @@ import { interopDefault } from '@w5s/dev';
4
4
  import type { RuleOptions } from '../typegen/jsonc.js';
5
5
 
6
6
  import { jsonSourceGlob } from '../glob.js';
7
+ import { defaultPluginOptions } from '../internal/defaultOptions.js';
7
8
  import { withDefaultFiles } from '../internal/withDefaultFiles.js';
8
- import { type Config, type PluginOptionsBase, StylisticConfig } from '../type.js';
9
+ import { type Config, type PluginOptionsBase } from '../type.js';
9
10
 
10
11
  const defaultFiles = [jsonSourceGlob];
11
12
 
@@ -16,15 +17,15 @@ export async function jsonc(options: jsonc.Options = {}): Promise<ReadonlyArray<
16
17
  ] as const);
17
18
  const {
18
19
  files,
19
- recommended = true,
20
+ namespace,
21
+ recommended,
20
22
  rules = {},
21
- stylistic = true,
22
- } = options;
23
- const { enabled: stylisticEnabled, indent } = StylisticConfig.from(stylistic);
23
+ stylistic,
24
+ } = defaultPluginOptions(options);
24
25
 
25
26
  return [
26
27
  {
27
- name: 'w5s/jsonc/setup',
28
+ name: `${namespace}/jsonc/setup`,
28
29
  plugins: {
29
30
  jsonc: jsoncPlugin,
30
31
  },
@@ -34,15 +35,15 @@ export async function jsonc(options: jsonc.Options = {}): Promise<ReadonlyArray<
34
35
  languageOptions: {
35
36
  parser: jsoncParser,
36
37
  },
37
- name: 'w5s/jsonc/rules',
38
+ name: `${namespace}/jsonc/rules`,
38
39
  rules: {
39
40
  ...(recommended ? jsoncPlugin.configs['flat/recommended-with-json'][0]?.rules : {}),
40
- ...(stylisticEnabled
41
+ ...(stylistic.enabled
41
42
  ? {
42
43
  'jsonc/array-bracket-spacing': ['error', 'never'],
43
44
  'jsonc/comma-dangle': ['error', 'never'],
44
45
  'jsonc/comma-style': ['error', 'last'],
45
- 'jsonc/indent': ['error', indent],
46
+ 'jsonc/indent': ['error', stylistic.indent],
46
47
  'jsonc/key-spacing': ['error', { afterColon: true, beforeColon: false }],
47
48
  'jsonc/object-curly-newline': ['error', { consistent: true, multiline: true }],
48
49
  'jsonc/object-curly-spacing': ['error', 'always'],
@@ -54,8 +55,8 @@ export async function jsonc(options: jsonc.Options = {}): Promise<ReadonlyArray<
54
55
  ...rules,
55
56
  },
56
57
  },
57
- stylisticEnabled ? sortPackageJson() : {},
58
- stylisticEnabled ? sortTsconfigJson() : {},
58
+ stylistic.enabled ? sortPackageJson() : {},
59
+ stylistic.enabled ? sortTsconfigJson() : {},
59
60
  ] as [Config, Config, Config, Config] satisfies Array<Config>;
60
61
  }
61
62
 
package/src/config/jsx.ts CHANGED
@@ -3,17 +3,19 @@ import { interopDefault } from '@w5s/dev';
3
3
  import type { RuleOptions } from '../typegen/jsx-a11y.js';
4
4
 
5
5
  import { jsxSourceGlob } from '../glob.js';
6
+ import { defaultPluginOptions } from '../internal/defaultOptions.js';
6
7
  import { withDefaultFiles } from '../internal/withDefaultFiles.js';
7
8
  import { type Config, type PluginOptionsBase } from '../type.js';
8
9
 
9
10
  const defaultFiles = [jsxSourceGlob];
10
11
 
11
12
  export async function jsx(options: jsx.Options = {}) {
12
- const { files, jsxA11y = false, recommended = true, rules = {} } = options;
13
+ const { files, jsxA11y = false, namespace, recommended, rules = {} } = defaultPluginOptions(options);
13
14
  // eslint-disable-next-line ts/await-thenable
14
15
  const [jsxA11yPlugin] = await Promise.all([
15
16
  jsxA11y ? interopDefault(import('eslint-plugin-jsx-a11y')) : undefined,
16
17
  ] as const);
18
+
17
19
  return [
18
20
  {
19
21
  languageOptions: {
@@ -24,14 +26,14 @@ export async function jsx(options: jsx.Options = {}) {
24
26
  },
25
27
  sourceType: 'module',
26
28
  },
27
- name: 'w5s/jsx/setup',
29
+ name: `${namespace}/jsx/setup`,
28
30
  plugins: {
29
31
  ...(jsxA11yPlugin ? { 'jsx-a11y': jsxA11yPlugin } : {}),
30
32
  },
31
33
  },
32
34
  {
33
35
  files: withDefaultFiles(files, defaultFiles),
34
- name: 'w5s/jsx/rules',
36
+ name: `${namespace}/jsx/rules`,
35
37
  rules: {
36
38
  ...(recommended && jsxA11yPlugin != null ? jsxA11yPlugin.configs.recommended.rules : {}),
37
39
  ...rules,
@@ -4,11 +4,12 @@ import { mergeProcessors, processorPassThrough } from 'eslint-merge-processors';
4
4
  import type { RuleOptions } from '../typegen/markdown.js';
5
5
 
6
6
  import { sourceGlob } from '../glob.js';
7
+ import { defaultPluginOptions } from '../internal/defaultOptions.js';
7
8
  import { withDefaultFiles } from '../internal/withDefaultFiles.js';
8
9
  import { looseRules } from '../rules/looseRules.js';
9
- import { type Config, type PluginOptionsBase, StylisticConfig } from '../type.js';
10
+ import { type Config, type PluginOptionsBase } from '../type.js';
10
11
 
11
- const defaultFiles = [Project.extensionsToGlob(Project.queryExtensions(['markdown']), { nested: true })];
12
+ const defaultFiles = [Project.glob({ fileExtensions: [Project.queryExtensions(['markdown'])], nested: true })];
12
13
 
13
14
  export async function markdown(options: markdown.Options = {}) {
14
15
  const [markdownPlugin] = await Promise.all([
@@ -18,16 +19,16 @@ export async function markdown(options: markdown.Options = {}) {
18
19
  files,
19
20
  language = 'markdown/gfm',
20
21
  languageOptions,
21
- recommended = true,
22
+ namespace,
23
+ recommended,
22
24
  rules = {},
23
- stylistic = true,
24
- } = options;
25
- const { enabled: stylisticEnabled } = StylisticConfig.from(stylistic);
25
+ stylistic,
26
+ } = defaultPluginOptions(options);
26
27
 
27
28
  const resolvedFiles = withDefaultFiles(files, defaultFiles);
28
29
  return [
29
30
  {
30
- name: 'w5s/markdown/setup',
31
+ name: `${namespace}/markdown/setup`,
31
32
  plugins: {
32
33
  markdown: markdownPlugin,
33
34
  },
@@ -39,12 +40,12 @@ export async function markdown(options: markdown.Options = {}) {
39
40
  frontmatter: 'yaml',
40
41
  ...languageOptions,
41
42
  },
42
- name: 'w5s/markdown/rules',
43
+ name: `${namespace}/markdown/rules`,
43
44
 
44
45
  processor: mergeProcessors([markdownPlugin.processors.markdown, processorPassThrough]),
45
46
  rules: {
46
47
  ...(recommended ? markdownPlugin.configs.recommended.at(0)?.rules : {}),
47
- ...(stylisticEnabled ? {} : {}),
48
+ ...(stylistic.enabled ? {} : {}),
48
49
  ...rules,
49
50
  },
50
51
  },
@@ -56,7 +57,7 @@ export async function markdown(options: markdown.Options = {}) {
56
57
  projectService: false,
57
58
  },
58
59
  },
59
- name: 'w5s/markdown/embed-code',
60
+ name: `${namespace}/markdown/embed-code`,
60
61
  rules: {
61
62
  ...looseRules(),
62
63
  'no-alert': 'off',
@@ -12,7 +12,7 @@ export async function next(options: next.Options = {}) {
12
12
  const [nextPlugin] = await Promise.all([
13
13
  interopDefault(import('@next/eslint-plugin-next')),
14
14
  ] as const);
15
- const { files, recommended = true, rules = {} } = options;
15
+ const { files, recommended, rules = {} } = options;
16
16
 
17
17
  return [
18
18
  {
@@ -3,8 +3,9 @@ import { interopDefault } from '@w5s/dev';
3
3
  import type { RuleOptions } from '../typegen/perfectionist.js';
4
4
 
5
5
  import { sourceGlob } from '../glob.js';
6
+ import { defaultPluginOptions } from '../internal/defaultOptions.js';
6
7
  import { withDefaultFiles } from '../internal/withDefaultFiles.js';
7
- import { type Config, type PluginOptionsBase, StylisticConfig } from '../type.js';
8
+ import { type Config, type PluginOptionsBase } from '../type.js';
8
9
 
9
10
  const defaultFiles = [sourceGlob];
10
11
 
@@ -12,25 +13,25 @@ export async function perfectionist(options: perfectionist.Options = {}) {
12
13
  const [perfectionistPlugin] = await Promise.all([interopDefault(import('eslint-plugin-perfectionist'))] as const);
13
14
  const {
14
15
  files,
15
- recommended = true,
16
+ namespace,
17
+ recommended,
16
18
  rules = {},
17
- stylistic = true,
18
- } = options;
19
- const { enabled: stylisticEnabled } = StylisticConfig.from(stylistic);
19
+ stylistic,
20
+ } = defaultPluginOptions(options);
20
21
 
21
22
  return [
22
23
  {
23
- name: 'w5s/perfectionist/setup',
24
+ name: `${namespace}/perfectionist/setup`,
24
25
  plugins: {
25
26
  perfectionist: perfectionistPlugin,
26
27
  },
27
28
  },
28
29
  {
29
30
  files: withDefaultFiles(files, defaultFiles),
30
- name: 'w5s/perfectionist/rules',
31
+ name: `${namespace}/perfectionist/rules`,
31
32
  rules: {
32
33
  ...(recommended ? perfectionistPlugin.configs['recommended-natural'].rules : {}),
33
- ...(stylisticEnabled ? {} : {}),
34
+ ...(stylistic.enabled ? {} : {}),
34
35
  ...rules,
35
36
  },
36
37
  },
@@ -3,6 +3,7 @@ import { ESLintConfig, interopDefault } from '@w5s/dev';
3
3
  import type { RuleOptions } from '../typegen/react.js';
4
4
 
5
5
  import { sourceGlob } from '../glob.js';
6
+ import { defaultPluginOptions } from '../internal/defaultOptions.js';
6
7
  import { withDefaultFiles } from '../internal/withDefaultFiles.js';
7
8
  import { type Config, type PluginOptionsBase } from '../type.js';
8
9
 
@@ -12,10 +13,10 @@ export async function react(options: react.Options = {}) {
12
13
  const [reactPlugin] = await Promise.all([
13
14
  interopDefault(import('@eslint-react/eslint-plugin')),
14
15
  ] as const);
15
- const { files, recommended = true, rules = {} } = options;
16
+ const { files, namespace, recommended, rules = {} } = defaultPluginOptions(options);
16
17
  return [
17
18
  {
18
- name: 'w5s/react/setup',
19
+ name: `${namespace}/react/setup`,
19
20
  plugins: {
20
21
  react: reactPlugin,
21
22
  },
@@ -30,7 +31,7 @@ export async function react(options: react.Options = {}) {
30
31
  },
31
32
  sourceType: 'module',
32
33
  },
33
- name: 'w5s/react/rules',
34
+ name: `${namespace}/react/rules`,
34
35
  rules: {
35
36
  // eslint-disable-next-line ts/no-non-null-assertion
36
37
  ...(recommended ? ESLintConfig.renameRules(reactPlugin.configs.recommended.rules!, { '@eslint-react': 'react' }) : {}),
@@ -2,9 +2,10 @@ import { ESLintConfig, interopDefault, Project } from '@w5s/dev';
2
2
 
3
3
  import type { RuleOptions } from '../typegen/test.js';
4
4
 
5
+ import { defaultPluginOptions } from '../internal/defaultOptions.js';
5
6
  import { withDefaultFiles } from '../internal/withDefaultFiles.js';
6
7
  import { looseRules } from '../rules/looseRules.js';
7
- import { type Config, type PluginOptionsBase, StylisticConfig } from '../type.js';
8
+ import { type Config, type PluginOptionsBase } from '../type.js';
8
9
 
9
10
  const defaultFiles = Project.extensionsToTestGlob(Project.sourceExtensions());
10
11
 
@@ -12,19 +13,18 @@ export async function test(options: test.Options = {}) {
12
13
  const [vitestPlugin] = await Promise.all(([
13
14
  interopDefault(import('@vitest/eslint-plugin')),
14
15
  ]) as const);
15
- const { files, recommended = true, rules = {}, stylistic = true } = options;
16
- const { enabled: stylisticEnabled } = StylisticConfig.from(stylistic);
16
+ const { files, namespace, recommended, rules = {}, stylistic } = defaultPluginOptions(options);
17
17
 
18
18
  return [
19
19
  {
20
- name: 'w5s/test/setup',
20
+ name: `${namespace}/test/setup`,
21
21
  plugins: {
22
22
  test: vitestPlugin,
23
23
  },
24
24
  },
25
25
  {
26
26
  files: withDefaultFiles(files, defaultFiles),
27
- name: 'w5s/test/rules',
27
+ name: `${namespace}/test/rules`,
28
28
  rules: {
29
29
  ...(recommended
30
30
  ? {
@@ -38,7 +38,7 @@ export async function test(options: test.Options = {}) {
38
38
  'test/valid-title': ESLintConfig.fixme(undefined),
39
39
  }
40
40
  : {}),
41
- ...(stylisticEnabled
41
+ ...(stylistic.enabled
42
42
  ? {}
43
43
  : {}),
44
44
  ...rules,
package/src/config/ts.ts CHANGED
@@ -4,9 +4,10 @@ import { ESLintConfig, interopDefault } from '@w5s/dev';
4
4
  import type { RuleOptions } from '../typegen/ts.js';
5
5
 
6
6
  import { tsSourceGlob } from '../glob.js';
7
+ import { defaultPluginOptions } from '../internal/defaultOptions.js';
7
8
  import { withDefaultFiles } from '../internal/withDefaultFiles.js';
8
9
  import { tsRules } from '../rules/tsRules.js';
9
- import { type Config, type PluginOptionsBase, StylisticConfig } from '../type.js';
10
+ import { type Config, type PluginOptionsBase } from '../type.js';
10
11
 
11
12
  const tsRenameMap = {
12
13
  '@typescript-eslint': 'ts',
@@ -20,20 +21,20 @@ export async function ts(options: ts.Options = {}) {
20
21
  ] as const);
21
22
  const {
22
23
  files,
24
+ namespace,
23
25
  parserOptions = {},
24
- recommended = true,
26
+ recommended,
25
27
  rules = {},
26
- stylistic = true,
28
+ stylistic,
27
29
  tsconfigPath = './tsconfig.json',
28
30
  typeChecked = true,
29
- } = options;
30
- const { enabled: stylisticEnabled } = StylisticConfig.from(stylistic);
31
+ } = defaultPluginOptions(options);
31
32
  const tsCustomRules = tsRules();
32
33
  const resolvedFiles = withDefaultFiles(files, defaultFiles);
33
34
 
34
35
  return [
35
36
  {
36
- name: 'w5s/ts/setup',
37
+ name: `${namespace}/ts/setup`,
37
38
  plugins: {
38
39
  ts: tsPlugin,
39
40
  },
@@ -57,13 +58,13 @@ export async function ts(options: ts.Options = {}) {
57
58
  ...parserOptions,
58
59
  },
59
60
  },
60
- name: 'w5s/ts/rules',
61
+ name: `${namespace}/ts/rules`,
61
62
  rules: {
62
63
  ...(recommended ? ESLintConfig.renameRules(tsPlugin.configs['eslint-recommended']!.overrides![0]!.rules!, tsRenameMap) : {}),
63
64
  ...(recommended ? ESLintConfig.renameRules(tsPlugin.configs['strict']!.rules!, tsRenameMap) : {}),
64
65
  ...(recommended && typeChecked ? ESLintConfig.renameRules(tsPlugin.configs['recommended-type-checked-only']!.rules!, tsRenameMap) : {}),
65
66
  ...(recommended ? tsCustomRules : {}),
66
- ...(stylisticEnabled
67
+ ...(stylistic.enabled
67
68
  ? {
68
69
  // eslint-disable-next-line ts/no-non-null-asserted-optional-chain
69
70
  ...ESLintConfig.renameRules(tsPlugin.configs['stylistic']?.rules!, tsRenameMap),
@@ -3,26 +3,26 @@ 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 { defaultPluginOptions } from '../internal/defaultOptions.js';
6
7
  import { withDefaultFiles } from '../internal/withDefaultFiles.js';
7
- import { type Config, type PluginOptionsBase, StylisticConfig } from '../type.js';
8
+ import { type Config, type PluginOptionsBase } from '../type.js';
8
9
 
9
10
  const defaultFiles = [sourceGlob];
10
11
 
11
12
  export async function unicorn(options: unicorn.Options = {}) {
12
13
  const [unicornPlugin] = await Promise.all([interopDefault(import('eslint-plugin-unicorn'))] as const);
13
- const { files, recommended = true, rules = {}, stylistic = true } = options;
14
- const { enabled: stylisticEnabled } = StylisticConfig.from(stylistic);
14
+ const { files, namespace, recommended, rules = {}, stylistic } = defaultPluginOptions(options);
15
15
 
16
16
  return [
17
17
  {
18
- name: 'w5s/unicorn/setup',
18
+ name: `${namespace}/unicorn/setup`,
19
19
  plugins: {
20
20
  unicorn: unicornPlugin,
21
21
  },
22
22
  },
23
23
  {
24
24
  files: withDefaultFiles(files, defaultFiles),
25
- name: 'w5s/unicorn/rules',
25
+ name: `${namespace}/unicorn/rules`,
26
26
  rules: {
27
27
  ...(recommended && unicornPlugin.configs.unopinionated.rules),
28
28
  // Disabled for safety
@@ -37,14 +37,14 @@ export async function unicorn(options: unicorn.Options = {}) {
37
37
  'unicorn/prefer-default-parameters': 'off',
38
38
  'unicorn/prefer-set-has': 'off',
39
39
  'unicorn/throw-new-error': 'off', // Creating errors with call signature is OK
40
- ...(stylisticEnabled ? {} : {}),
40
+ ...(stylistic.enabled ? {} : {}),
41
41
  ...rules,
42
42
  },
43
43
  },
44
44
  // TODO: move to another file ?
45
45
  {
46
46
  files: ['**/*.config.cjs', '**/*.config.js'],
47
- name: 'w5s/unicorn/overrides',
47
+ name: `${namespace}/unicorn/overrides`,
48
48
  rules: {
49
49
  'unicorn/prefer-module': 'off',
50
50
  },
@@ -3,13 +3,14 @@ import { interopDefault } from '@w5s/dev';
3
3
  import type { RuleOptions } from '../typegen/unused-imports.js';
4
4
 
5
5
  import { sourceGlob } from '../glob.js';
6
+ import { defaultPluginOptions } from '../internal/defaultOptions.js';
6
7
  import { type Config, type PluginOptionsBase } from '../type.js';
7
8
 
8
9
  export async function unusedImports(options: unusedImports.Options = {}) {
9
10
  const [unusedImportPlugin] = await Promise.all([
10
11
  interopDefault(import('eslint-plugin-unused-imports')),
11
12
  ] as const);
12
- const { files = [sourceGlob], recommended = true, rules = {} } = options;
13
+ const { files = [sourceGlob], recommended, rules = {} } = defaultPluginOptions(options);
13
14
 
14
15
  return [
15
16
  {
package/src/config/yml.ts CHANGED
@@ -3,19 +3,20 @@ import { interopDefault } from '@w5s/dev';
3
3
  import type { RuleOptions } from '../typegen/yml.js';
4
4
 
5
5
  import { ymlSourceGlob } from '../glob.js';
6
+ import { defaultPluginOptions } from '../internal/defaultOptions.js';
6
7
  import { withDefaultFiles } from '../internal/withDefaultFiles.js';
7
- import { type Config, type PluginOptionsBase, StylisticConfig } from '../type.js';
8
+ import { type Config, type PluginOptionsBase } from '../type.js';
8
9
 
9
10
  const defaultFiles = [ymlSourceGlob];
10
11
 
11
12
  export async function yml(options: yml.Options = {}) {
12
13
  const [ymlPlugin] = await Promise.all([interopDefault(import('eslint-plugin-yml'))] as const);
13
- const { files, recommended = true, rules = {}, stylistic = true } = options;
14
- const { enabled: stylisticEnabled, indent, quotes } = StylisticConfig.from(stylistic);
14
+ const { files, namespace, recommended, rules = {}, stylistic } = defaultPluginOptions(options);
15
+ const { enabled: stylisticEnabled, indent, quotes } = stylistic;
15
16
 
16
17
  return [
17
18
  {
18
- name: 'w5s/yml/setup',
19
+ name: `${namespace}/yml/setup`,
19
20
  plugins: {
20
21
  yml: ymlPlugin,
21
22
  },
@@ -23,7 +24,7 @@ export async function yml(options: yml.Options = {}) {
23
24
  {
24
25
  files: withDefaultFiles(files, defaultFiles),
25
26
  language: 'yml/yaml',
26
- name: 'w5s/yml/rules',
27
+ name: `${namespace}/yml/rules`,
27
28
  rules: {
28
29
  ...(recommended
29
30
  ? ymlPlugin.configs.recommended.reduce(