@w5s/eslint-config 6.0.0 → 7.1.1

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": "6.0.0",
3
+ "version": "7.1.1",
4
4
  "description": "ESLint configuration presets",
5
5
  "keywords": [
6
6
  "eslint",
@@ -38,27 +38,29 @@
38
38
  },
39
39
  "dependencies": {
40
40
  "@e18e/eslint-plugin": "~0.8.0",
41
- "@eslint-react/eslint-plugin": "~5.22.0",
41
+ "@eslint-react/eslint-plugin": "~5.24.0",
42
42
  "@eslint/js": "~10.0.0",
43
43
  "@eslint/markdown": "~8.0.0",
44
- "@next/eslint-plugin-next": "~16.3.0",
44
+ "@next/eslint-plugin-next": "~16.4.0",
45
45
  "@stylistic/eslint-plugin": "~5.10.0",
46
46
  "@typescript-eslint/eslint-plugin": "~8.71.0",
47
47
  "@typescript-eslint/parser": "^8.65.0",
48
48
  "@vitest/eslint-plugin": "~1.6.20",
49
- "@w5s/dev": "^6.0.0",
50
- "@w5s/eslint-config-ignore": "^1.33.0",
51
- "@w5s/prettier-config": "^3.28.0",
49
+ "@w5s/dev": "^7.0.0",
50
+ "@w5s/eslint-config-ignore": "^1.34.0",
51
+ "@w5s/prettier-config": "^3.29.1",
52
52
  "eslint-merge-processors": "^2.0.0",
53
53
  "eslint-plugin-github-actions-2": "~2.0.0",
54
54
  "eslint-plugin-import": "~2.32.0",
55
- "eslint-plugin-jsdoc": "~64.5.0",
55
+ "eslint-plugin-jsdoc": "~65.2.0",
56
+ "eslint-plugin-json-schema-validator-2": "~7.0.11",
56
57
  "eslint-plugin-jsonc": "~3.4.0",
57
58
  "eslint-plugin-n": "~18.4.0",
58
59
  "eslint-plugin-perfectionist": "~5.12.0",
59
- "eslint-plugin-unicorn": "~76.0.0",
60
+ "eslint-plugin-toml": "~1.5.0",
61
+ "eslint-plugin-unicorn": "~77.0.0",
60
62
  "eslint-plugin-unused-imports": "~4.4.1",
61
- "eslint-plugin-yml": "~3.8.0",
63
+ "eslint-plugin-yml": "~3.9.0",
62
64
  "globals": "^17.0.0",
63
65
  "jsonc-eslint-parser": "^3.0.0",
64
66
  "parse-gitignore": "^2.0.0",
@@ -86,5 +88,5 @@
86
88
  "publishConfig": {
87
89
  "access": "public"
88
90
  },
89
- "gitHead": "22c5f0c577887c9855d4a6fa3c139e0e36a1bc6a"
91
+ "gitHead": "d39c8e42e2e9cb34d05ea9e23c757383dd30795a"
90
92
  }
package/src/config/es.ts CHANGED
@@ -4,7 +4,7 @@ import globals from 'globals';
4
4
 
5
5
  import type { RuleOptions } from '../typegen/jsonc.js';
6
6
 
7
- import { esSourceGlob, sourceGlob } from '../glob.js';
7
+ import { jsSourceGlob, sourceGlob } from '../glob.js';
8
8
  import { defaultPluginOptions } from '../internal/defaultOptions.js';
9
9
  import { restrictedGlobals as defaultGlobalRestrictedGlobals } from '../restrictedGlobals.js';
10
10
  import { restrictedImportPaths as defaultGlobalRestrictedImportPaths } from '../restrictedImportPaths.js';
@@ -12,7 +12,7 @@ import { restrictedSyntax as defaultGlobalRestrictedSyntax } from '../restricted
12
12
  import { esRules } from '../rules/esRules.js';
13
13
  import { type Config, type PluginOptionsBase, type RestrictedGlobals, type RestrictedImportPaths, type RestrictedSyntax } from '../type.js';
14
14
 
15
- const defaultFiles = [esSourceGlob];
15
+ const defaultFiles = [jsSourceGlob];
16
16
 
17
17
  export async function es(options: es.Options) {
18
18
  const {
@@ -34,7 +34,12 @@ export async function githubActions(options: githubActions.Options = {}) {
34
34
  name: `${namespace}/github-actions/rules`,
35
35
  rules: {
36
36
  ...(recommended ? recommendedConfig.rules : {}),
37
- ...(stylistic.enabled ? stylisticConfig.rules : {}),
37
+ ...(stylistic.enabled
38
+ ? {
39
+ ...stylisticConfig.rules,
40
+ 'github-actions/action-name-casing': 'off', // TODO: We use kebab-case for action names
41
+ }
42
+ : {}),
38
43
  ...rules,
39
44
  },
40
45
  },
@@ -2,12 +2,12 @@ import { interopDefault } from '@w5s/dev';
2
2
 
3
3
  import type { RuleOptions } from '../typegen/jsdoc.js';
4
4
 
5
- import { esSourceGlob, tsSourceGlob } from '../glob.js';
5
+ import { jsSourceGlob, tsSourceGlob } from '../glob.js';
6
6
  import { defaultPluginOptions } from '../internal/defaultOptions.js';
7
7
  import { withDefaultFiles } from '../internal/withDefaultFiles.js';
8
8
  import { type Config, type PluginOptionsBase } from '../type.js';
9
9
 
10
- const defaultJsFiles = [esSourceGlob];
10
+ const defaultJsFiles = [jsSourceGlob];
11
11
  const defaultTsFiles = [tsSourceGlob];
12
12
 
13
13
  export async function jsdoc(options: jsdoc.Options = {}): Promise<ReadonlyArray<Config>> {
@@ -1,12 +1,14 @@
1
1
  /* cSpell:disable */
2
2
  import { interopDefault } from '@w5s/dev';
3
3
 
4
- import type { RuleOptions } from '../typegen/jsonc.js';
4
+ import type { RuleOptions as JsoncRuleOptions } from '../typegen/jsonc.js';
5
+ import type { RuleOptions as SchemaRuleOptions } from '../typegen/schema.js';
5
6
 
6
7
  import { jsonSourceGlob } from '../glob.js';
7
8
  import { defaultPluginOptions } from '../internal/defaultOptions.js';
8
9
  import { withDefaultFiles } from '../internal/withDefaultFiles.js';
9
- import { type Config, type PluginOptionsBase } from '../type.js';
10
+ import { withSchema } from '../internal/withSchema.js';
11
+ import { type Config, type PluginOptionsBase, type PluginOptionsSchema } from '../type.js';
10
12
 
11
13
  const defaultFiles = [jsonSourceGlob];
12
14
 
@@ -22,12 +24,14 @@ export async function jsonc(options: jsonc.Options = {}): Promise<ReadonlyArray<
22
24
  rules = {},
23
25
  stylistic,
24
26
  } = defaultPluginOptions(options);
27
+ const schemaConfig = await withSchema(options.schema);
25
28
 
26
29
  return [
27
30
  {
28
31
  name: `${namespace}/jsonc/setup`,
29
32
  plugins: {
30
33
  jsonc: jsoncPlugin,
34
+ ...schemaConfig.plugins,
31
35
  },
32
36
  },
33
37
  {
@@ -38,6 +42,7 @@ export async function jsonc(options: jsonc.Options = {}): Promise<ReadonlyArray<
38
42
  name: `${namespace}/jsonc/rules`,
39
43
  rules: {
40
44
  ...(recommended ? jsoncPlugin.configs['flat/recommended-with-json'][0]?.rules : {}),
45
+ ...schemaConfig.rules,
41
46
  ...(stylistic.enabled
42
47
  ? {
43
48
  'jsonc/array-bracket-spacing': ['error', 'never'],
@@ -241,7 +246,7 @@ function sortTsconfigJson(namespace: string) {
241
246
  }
242
247
 
243
248
  export namespace jsonc {
244
- export interface Options extends PluginOptionsBase<Rules> {}
249
+ export interface Options extends PluginOptionsBase<Rules>, PluginOptionsSchema {}
245
250
 
246
- export type Rules = RuleOptions;
251
+ export type Rules = JsoncRuleOptions & SchemaRuleOptions;
247
252
  }
@@ -59,6 +59,7 @@ export async function markdown(options: markdown.Options = {}) {
59
59
  },
60
60
  name: `${namespace}/markdown/embed-code`,
61
61
  rules: {
62
+ 'markdown/no-multiple-h1': ['error', { frontmatterTitle: '' }], // Enforce a single H1, ignoring the frontmatter title
62
63
  ...looseRules(),
63
64
  'no-alert': 'off',
64
65
  'no-console': 'off',
@@ -0,0 +1,57 @@
1
+ import { interopDefault } from '@w5s/dev';
2
+
3
+ import type { RuleOptions as SchemaRuleOptions } from '../typegen/schema.js';
4
+ import type { RuleOptions } from '../typegen/toml.js';
5
+
6
+ import { tomlSourceGlob } from '../glob.js';
7
+ import { defaultPluginOptions } from '../internal/defaultOptions.js';
8
+ import { withDefaultFiles } from '../internal/withDefaultFiles.js';
9
+ import { withSchema } from '../internal/withSchema.js';
10
+ import { type Config, type PluginOptionsBase, type PluginOptionsSchema } from '../type.js';
11
+
12
+ const defaultFiles = [tomlSourceGlob];
13
+
14
+ export async function toml(options: toml.Options = {}) {
15
+ const tomlPlugin = await interopDefault(import('eslint-plugin-toml'));
16
+ const { files, namespace, recommended, rules = {}, stylistic } = defaultPluginOptions(options);
17
+ const recommendedRules = tomlPlugin.configs.recommended.at(-1)?.rules;
18
+ const standardRules = tomlPlugin.configs.standard.at(-1)?.rules;
19
+ const schemaConfig = await withSchema(options.schema);
20
+
21
+ return [
22
+ {
23
+ name: `${namespace}/toml/setup`,
24
+ plugins: {
25
+ toml: tomlPlugin,
26
+ ...schemaConfig.plugins,
27
+ },
28
+ },
29
+ {
30
+ files: withDefaultFiles(files, defaultFiles),
31
+ language: 'toml/toml',
32
+ name: `${namespace}/toml/rules`,
33
+ rules: {
34
+ 'no-irregular-whitespace': 'off',
35
+ 'spaced-comment': 'off',
36
+ ...(recommended ? recommendedRules : {}),
37
+ ...schemaConfig.rules,
38
+ ...(stylistic.enabled ? standardRules : {}),
39
+ ...(!recommended && stylistic.enabled
40
+ ? {
41
+ 'toml/no-unreadable-number-separator': 'off',
42
+ 'toml/precision-of-fractional-seconds': 'off',
43
+ 'toml/precision-of-integer': 'off',
44
+ 'toml/vue-custom-block/no-parsing-error': 'off',
45
+ }
46
+ : {}),
47
+ ...rules,
48
+ },
49
+ },
50
+ ] as [Config, Config] satisfies Array<Config>;
51
+ }
52
+
53
+ export namespace toml {
54
+ export interface Options extends PluginOptionsBase<Rules>, PluginOptionsSchema {}
55
+
56
+ export type Rules = RuleOptions & SchemaRuleOptions;
57
+ }
@@ -31,6 +31,7 @@ export async function unicorn(options: unicorn.Options = {}) {
31
31
  'unicorn/no-console-spaces': 'off',
32
32
  'unicorn/no-object-as-default-parameter': 'off',
33
33
  'unicorn/no-process-exit': 'off',
34
+ 'unicorn/no-top-level-side-effects': 'off', // Too many errors from config files
34
35
  'unicorn/no-unreadable-array-destructuring': 'off',
35
36
  'unicorn/no-useless-undefined': 'off',
36
37
  'unicorn/prefer-add-event-listener': 'off',
package/src/config/yml.ts CHANGED
@@ -1,11 +1,13 @@
1
1
  import { interopDefault } from '@w5s/dev';
2
2
 
3
+ import type { RuleOptions as SchemaRuleOptions } from '../typegen/schema.js';
3
4
  import type { RuleOptions } from '../typegen/yml.js';
4
5
 
5
6
  import { ymlSourceGlob } from '../glob.js';
6
7
  import { defaultPluginOptions } from '../internal/defaultOptions.js';
7
8
  import { withDefaultFiles } from '../internal/withDefaultFiles.js';
8
- import { type Config, type PluginOptionsBase } from '../type.js';
9
+ import { withSchema } from '../internal/withSchema.js';
10
+ import { type Config, type PluginOptionsBase, type PluginOptionsSchema } from '../type.js';
9
11
 
10
12
  const defaultFiles = [ymlSourceGlob];
11
13
 
@@ -13,12 +15,14 @@ export async function yml(options: yml.Options = {}) {
13
15
  const [ymlPlugin] = await Promise.all([interopDefault(import('eslint-plugin-yml'))] as const);
14
16
  const { files, namespace, recommended, rules = {}, stylistic } = defaultPluginOptions(options);
15
17
  const { enabled: stylisticEnabled, indent, quotes } = stylistic;
18
+ const schemaConfig = await withSchema(options.schema);
16
19
 
17
20
  return [
18
21
  {
19
22
  name: `${namespace}/yml/setup`,
20
23
  plugins: {
21
24
  yml: ymlPlugin,
25
+ ...schemaConfig.plugins,
22
26
  },
23
27
  },
24
28
  {
@@ -33,6 +37,7 @@ export async function yml(options: yml.Options = {}) {
33
37
  {} as RuleOptions,
34
38
  )
35
39
  : {}),
40
+ ...schemaConfig.rules,
36
41
  ...(stylisticEnabled
37
42
  ? {
38
43
  'style/spaced-comment': 'off', // Fix
@@ -60,7 +65,7 @@ export async function yml(options: yml.Options = {}) {
60
65
  }
61
66
 
62
67
  export namespace yml {
63
- export interface Options extends PluginOptionsBase<Rules> {}
68
+ export interface Options extends PluginOptionsBase<Rules>, PluginOptionsSchema {}
64
69
 
65
- export type Rules = RuleOptions;
70
+ export type Rules = RuleOptions & SchemaRuleOptions;
66
71
  }
package/src/config.ts CHANGED
@@ -13,6 +13,7 @@ export * from './config/perfectionist.js';
13
13
  export * from './config/react.js';
14
14
  export * from './config/stylistic.js';
15
15
  export * from './config/test.js';
16
+ export * from './config/toml.js';
16
17
  export * from './config/ts.js';
17
18
  export * from './config/unicorn.js';
18
19
  export * from './config/unused-imports.js';
@@ -33,6 +33,7 @@ export interface DefineConfigOptions extends config.ignores.Options {
33
33
  'react'?: boolean | config.react.Options | undefined;
34
34
  'stylistic'?: boolean | config.stylistic.Options | undefined;
35
35
  'test'?: boolean | config.test.Options | undefined;
36
+ 'toml'?: boolean | config.toml.Options | undefined;
36
37
  'ts'?: boolean | config.ts.Options | undefined;
37
38
  'unicorn'?: boolean | config.unicorn.Options | undefined;
38
39
  'unused-imports'?: boolean | config.unusedImports.Options | undefined;
@@ -95,6 +96,7 @@ export async function defineConfig(options: DefineConfigOptions = {}): Promise<A
95
96
 
96
97
  // other languages
97
98
  ...includeEnabled(config.jsonc, toOption(plugins.jsonc)),
99
+ ...includeEnabled(config.toml, toOption(plugins.toml)),
98
100
  ...includeEnabled(config.markdown, toOption(plugins.markdown)),
99
101
  ...includeEnabled(config.yml, toOption(plugins.yml)),
100
102
  ...includeEnabled(config.githubActions, toOption(plugins['github-actions'])),
package/src/glob.ts CHANGED
@@ -2,7 +2,7 @@ import { Project } from '@w5s/dev';
2
2
 
3
3
  export const sourceGlob = Project.glob({ fileExtensions: [Project.sourceExtensions()], nested: true });
4
4
 
5
- export const esSourceGlob = Project.glob({ fileExtensions: [Project.queryExtensions(['javascript', 'javascriptreact'])], nested: true });
5
+ export const jsSourceGlob = Project.glob({ fileExtensions: [Project.queryExtensions(['javascript', 'javascriptreact'])], nested: true });
6
6
 
7
7
  export const jsxSourceGlob = Project.glob({ fileExtensions: [Project.queryExtensions(['javascriptreact', 'typescriptreact'])], nested: true });
8
8
 
@@ -10,4 +10,6 @@ export const jsonSourceGlob = Project.glob({ fileExtensions: [['.json', '.json5'
10
10
 
11
11
  export const tsSourceGlob = Project.glob({ fileExtensions: [Project.queryExtensions(['typescript', 'typescriptreact'])], nested: true });
12
12
 
13
+ export const tomlSourceGlob = Project.glob({ fileExtensions: [['.toml']], nested: true });
14
+
13
15
  export const ymlSourceGlob = Project.glob({ fileExtensions: [Project.queryExtensions(['yaml'])], nested: true });
@@ -0,0 +1,22 @@
1
+ import { interopDefault } from '@w5s/dev';
2
+
3
+ export interface WithSchemaOptions {
4
+ /**
5
+ * Enable the schema validation
6
+ */
7
+ enabled?: boolean;
8
+ }
9
+
10
+ export async function withSchema(
11
+ options: boolean | undefined | WithSchemaOptions,
12
+ ) {
13
+ const enabled = typeof options === 'boolean' ? options : options?.enabled ?? true;
14
+
15
+ const schemaValidatorPlugin = await interopDefault(import('eslint-plugin-json-schema-validator-2'));
16
+ return {
17
+ plugins: {
18
+ schema: schemaValidatorPlugin,
19
+ },
20
+ rules: enabled ? { 'schema/no-invalid': 'error' as const } : {},
21
+ };
22
+ }
@@ -0,0 +1,10 @@
1
+ import type { WithSchemaOptions } from '../internal/withSchema.js';
2
+
3
+ export interface PluginOptionsSchema {
4
+ /**
5
+ * Enable or configure the JSON schema validator plugin.
6
+ *
7
+ * @default true
8
+ */
9
+ schema?: boolean | WithSchemaOptions;
10
+ }
package/src/type.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export * from './type/Config.js';
2
2
  export * from './type/PluginOptionsBase.js';
3
+ export * from './type/PluginOptionsSchema.js';
3
4
  export * from './type/RestrictedGlobals.js';
4
5
  export * from './type/RestrictedImportPaths.js';
5
6
  export * from './type/RestrictedSyntax.js';
@@ -48,7 +48,7 @@ export interface RuleOptions {
48
48
  * Reports against syntax not valid for the mode (e.g., Google Closure Compiler in non-Closure mode).
49
49
  * @see https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/check-syntax.md#repos-sticky-header
50
50
  */
51
- 'jsdoc/check-syntax'?: Linter.RuleEntry<[]>
51
+ 'jsdoc/check-syntax'?: Linter.RuleEntry<JsdocCheckSyntax>
52
52
  /**
53
53
  * Reports invalid block tag names.
54
54
  * @see https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/check-tag-names.md#repos-sticky-header
@@ -404,6 +404,8 @@ export interface RuleOptions {
404
404
  // ----- jsdoc/check-alignment -----
405
405
  type JsdocCheckAlignment = []|[{
406
406
 
407
+ ignoreEmptyLines?: boolean
408
+
407
409
  innerIndent?: number
408
410
  }]
409
411
  // ----- jsdoc/check-examples -----
@@ -433,6 +435,8 @@ type JsdocCheckIndentation = []|[{
433
435
 
434
436
  allowIndentedSections?: boolean
435
437
 
438
+ allowNoSpaceAfterAsterisk?: boolean
439
+
436
440
  excludeTags?: string[]
437
441
  }]
438
442
  // ----- jsdoc/check-line-alignment -----
@@ -491,6 +495,11 @@ type JsdocCheckPropertyNames = []|[{
491
495
 
492
496
  enableFixer?: boolean
493
497
  }]
498
+ // ----- jsdoc/check-syntax -----
499
+ type JsdocCheckSyntax = []|[{
500
+
501
+ enableFixer?: boolean
502
+ }]
494
503
  // ----- jsdoc/check-tag-names -----
495
504
  type JsdocCheckTagNames = []|[{
496
505
 
@@ -1041,7 +1050,6 @@ type JsdocRequireTags = []|[{
1041
1050
  tags?: (string | {
1042
1051
  context?: string
1043
1052
  tag?: string
1044
- [k: string]: unknown | undefined
1045
1053
  })[]
1046
1054
  }]
1047
1055
  // ----- jsdoc/require-template -----
@@ -0,0 +1,35 @@
1
+ /* eslint-disable */
2
+ /* prettier-ignore */
3
+ import type { Linter } from 'eslint'
4
+
5
+ declare module 'eslint' {
6
+ namespace Linter {
7
+ interface RulesRecord extends RuleOptions {}
8
+ }
9
+ }
10
+
11
+ export interface RuleOptions {
12
+ /**
13
+ * validate object with JSON Schema.
14
+ * @see https://nick2bad4u.github.io/eslint-plugin-json-schema-validator-2/docs/rules/no-invalid
15
+ */
16
+ 'schema/no-invalid'?: Linter.RuleEntry<SchemaNoInvalid>
17
+ }
18
+
19
+ /* ======= Declarations ======= */
20
+ // ----- schema/no-invalid -----
21
+ type SchemaNoInvalid = []|[(string | {
22
+ mergeSchemas?: (boolean | [("$schema" | "catalog" | "options"), ("$schema" | "catalog" | "options"), ...(("$schema" | "catalog" | "options"))[]])
23
+ reportMode?: ("all" | "most-specific")
24
+ schemas?: {
25
+ description?: string
26
+
27
+ fileMatch: [string, ...(string)[]]
28
+ name?: string
29
+ schema: ({
30
+ [k: string]: unknown | undefined
31
+ } | string)
32
+ [k: string]: unknown | undefined
33
+ }[]
34
+ useSchemastoreCatalog?: boolean
35
+ })]