@w5s/eslint-config 5.0.0 → 6.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": "5.0.0",
3
+ "version": "6.0.0",
4
4
  "description": "ESLint configuration presets",
5
5
  "keywords": [
6
6
  "eslint",
@@ -38,24 +38,25 @@
38
38
  },
39
39
  "dependencies": {
40
40
  "@e18e/eslint-plugin": "~0.8.0",
41
- "@eslint-react/eslint-plugin": "~5.20.0",
41
+ "@eslint-react/eslint-plugin": "~5.22.0",
42
42
  "@eslint/js": "~10.0.0",
43
43
  "@eslint/markdown": "~8.0.0",
44
44
  "@next/eslint-plugin-next": "~16.3.0",
45
45
  "@stylistic/eslint-plugin": "~5.10.0",
46
- "@typescript-eslint/eslint-plugin": "~8.70.0",
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": "^5.0.0",
50
- "@w5s/eslint-config-ignore": "^1.32.0",
51
- "@w5s/prettier-config": "^3.27.0",
49
+ "@w5s/dev": "^6.0.0",
50
+ "@w5s/eslint-config-ignore": "^1.33.0",
51
+ "@w5s/prettier-config": "^3.28.0",
52
52
  "eslint-merge-processors": "^2.0.0",
53
+ "eslint-plugin-github-actions-2": "~2.0.0",
53
54
  "eslint-plugin-import": "~2.32.0",
54
55
  "eslint-plugin-jsdoc": "~64.5.0",
55
56
  "eslint-plugin-jsonc": "~3.4.0",
56
- "eslint-plugin-n": "~18.3.0",
57
- "eslint-plugin-perfectionist": "~5.11.0",
58
- "eslint-plugin-unicorn": "~74.0.0",
57
+ "eslint-plugin-n": "~18.4.0",
58
+ "eslint-plugin-perfectionist": "~5.12.0",
59
+ "eslint-plugin-unicorn": "~76.0.0",
59
60
  "eslint-plugin-unused-imports": "~4.4.1",
60
61
  "eslint-plugin-yml": "~3.8.0",
61
62
  "globals": "^17.0.0",
@@ -85,5 +86,5 @@
85
86
  "publishConfig": {
86
87
  "access": "public"
87
88
  },
88
- "gitHead": "13458dbf2ac200ee3013fb7be9ff1ca6122ff4f4"
89
+ "gitHead": "22c5f0c577887c9855d4a6fa3c139e0e36a1bc6a"
89
90
  }
@@ -0,0 +1,48 @@
1
+ import { interopDefault } from '@w5s/dev';
2
+
3
+ import type { RuleOptions } from '../typegen/github-actions.js';
4
+
5
+ import { defaultPluginOptions } from '../internal/defaultOptions.js';
6
+ import { withDefaultFiles } from '../internal/withDefaultFiles.js';
7
+ import { type Config, type PluginOptionsBase } from '../type.js';
8
+
9
+ const fallbackFiles = [
10
+ '.github/workflows/*.{yml,yaml}',
11
+ '**/action.{yml,yaml}',
12
+ '.github/dependabot.{yml,yaml}',
13
+ ];
14
+
15
+ export async function githubActions(options: githubActions.Options = {}) {
16
+ const [githubActionsPlugin] = await Promise.all([
17
+ interopDefault(import('eslint-plugin-github-actions-2')),
18
+ ] as const);
19
+ const { files, namespace, recommended, rules = {}, stylistic } = defaultPluginOptions(options);
20
+ const recommendedConfig = githubActionsPlugin.configs.recommended;
21
+ const stylisticConfig = githubActionsPlugin.configs.stylistic;
22
+ const defaultFiles = (recommendedConfig.files ?? fallbackFiles).flat();
23
+
24
+ return [
25
+ {
26
+ name: `${namespace}/github-actions/setup`,
27
+ plugins: {
28
+ 'github-actions': githubActionsPlugin,
29
+ },
30
+ },
31
+ {
32
+ files: withDefaultFiles(files, defaultFiles),
33
+ languageOptions: recommendedConfig.languageOptions,
34
+ name: `${namespace}/github-actions/rules`,
35
+ rules: {
36
+ ...(recommended ? recommendedConfig.rules : {}),
37
+ ...(stylistic.enabled ? stylisticConfig.rules : {}),
38
+ ...rules,
39
+ },
40
+ },
41
+ ] as [Config, Config] satisfies Array<Config>;
42
+ }
43
+
44
+ export namespace githubActions {
45
+ export interface Options extends PluginOptionsBase<Rules> {}
46
+
47
+ export type Rules = RuleOptions;
48
+ }
@@ -55,14 +55,15 @@ export async function jsonc(options: jsonc.Options = {}): Promise<ReadonlyArray<
55
55
  ...rules,
56
56
  },
57
57
  },
58
- stylistic.enabled ? sortPackageJson() : {},
59
- stylistic.enabled ? sortTsconfigJson() : {},
58
+ stylistic.enabled ? sortPackageJson(namespace) : {},
59
+ stylistic.enabled ? sortTsconfigJson(namespace) : {},
60
60
  ] as [Config, Config, Config, Config] satisfies Array<Config>;
61
61
  }
62
62
 
63
- function sortPackageJson() {
63
+ function sortPackageJson(namespace: string) {
64
64
  return {
65
65
  files: ['**/package.json'],
66
+ name: `${namespace}/jsonc/sort-package-json`,
66
67
  rules: {
67
68
  'jsonc/sort-keys': [
68
69
  'error',
@@ -219,9 +220,10 @@ function sortPackageJson() {
219
220
  };
220
221
  }
221
222
 
222
- function sortTsconfigJson() {
223
+ function sortTsconfigJson(namespace: string) {
223
224
  return {
224
225
  files: ['**/tsconfig*.json'],
226
+ name: `${namespace}/jsonc/sort-tsconfig`,
225
227
  rules: {
226
228
  'jsonc/sort-keys': [
227
229
  'error',
package/src/config.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export * from './config/e18e.js';
2
2
  export * from './config/es.js';
3
+ export * from './config/github-actions.js';
3
4
  export * from './config/ignores.js';
4
5
  export * from './config/imports.js';
5
6
  export * from './config/jsdoc.js';
@@ -21,6 +21,7 @@ export interface DefineConfigOptions extends config.ignores.Options {
21
21
  plugins?: undefined | {
22
22
  'e18e'?: boolean | config.e18e.Options | undefined;
23
23
  'es'?: boolean | config.es.Options | undefined;
24
+ 'github-actions'?: boolean | config.githubActions.Options | undefined;
24
25
  'import'?: boolean | config.imports.Options | undefined;
25
26
  'jsdoc'?: boolean | config.jsdoc.Options | undefined;
26
27
  'jsonc'?: boolean | config.jsonc.Options | undefined;
@@ -96,6 +97,7 @@ export async function defineConfig(options: DefineConfigOptions = {}): Promise<A
96
97
  ...includeEnabled(config.jsonc, toOption(plugins.jsonc)),
97
98
  ...includeEnabled(config.markdown, toOption(plugins.markdown)),
98
99
  ...includeEnabled(config.yml, toOption(plugins.yml)),
100
+ ...includeEnabled(config.githubActions, toOption(plugins['github-actions'])),
99
101
  ...(rules ? [{ rules }] : []),
100
102
  ...todo,
101
103
  ...overrides,