@w5s/eslint-config 4.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": "4.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.19.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": "^4.0.0",
50
- "@w5s/eslint-config-ignore": "^1.31.0",
51
- "@w5s/prettier-config": "^3.26.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": "ed181ba68ebff886310db849facb938bb00f61ca"
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',
@@ -2,22 +2,23 @@ import { interopDefault } from '@w5s/dev';
2
2
 
3
3
  import type { RuleOptions } from '../typegen/node.js';
4
4
 
5
+ import { defaultPluginOptions } from '../internal/defaultOptions.js';
5
6
  import { type Config, type PluginOptionsBase } from '../type.js';
6
7
 
7
8
  export async function node(options: node.Options = {}) {
8
9
  const [nodePlugin] = await Promise.all([
9
10
  interopDefault(import('eslint-plugin-n')),
10
11
  ] as const);
11
- const { recommended, rules = {} } = options;
12
+ const { namespace, recommended, rules = {} } = defaultPluginOptions(options);
12
13
  return [
13
14
  {
14
- name: 'w5s/node/setup',
15
+ name: `${namespace}/node/setup`,
15
16
  plugins: {
16
17
  node: nodePlugin,
17
18
  },
18
19
  },
19
20
  {
20
- name: 'w5s/node/rules',
21
+ name: `${namespace}/node/rules`,
21
22
  rules: {
22
23
  ...(recommended
23
24
  ? {
@@ -2,13 +2,14 @@ import { interopDefault } from '@w5s/dev';
2
2
 
3
3
  import type { RuleOptions } from '../typegen/style.js';
4
4
 
5
+ import { defaultPluginOptions } from '../internal/defaultOptions.js';
5
6
  import { type Config, type PluginOptionsBase, StylisticConfig, type StylisticParameters } from '../type.js';
6
7
 
7
8
  export async function stylistic(options: stylistic.Options = {}) {
8
9
  const [stylisticPlugin] = await Promise.all([
9
10
  interopDefault(import('@stylistic/eslint-plugin')),
10
11
  ] as const);
11
- const { rules = {} } = options;
12
+ const { namespace, rules = {} } = defaultPluginOptions(options);
12
13
  const { enabled: stylisticEnabled, indent, jsx, quotes, semi } = StylisticConfig.from(options);
13
14
  const config = stylisticEnabled
14
15
  ? stylisticPlugin.configs.customize({
@@ -22,13 +23,13 @@ export async function stylistic(options: stylistic.Options = {}) {
22
23
 
23
24
  return [
24
25
  {
25
- name: 'w5s/style/setup',
26
+ name: `${namespace}/style/setup`,
26
27
  plugins: {
27
28
  style: stylisticPlugin,
28
29
  },
29
30
  },
30
31
  {
31
- name: 'w5s/style/rules',
32
+ name: `${namespace}/style/rules`,
32
33
  rules: {
33
34
  ...(stylisticEnabled
34
35
  ? {
@@ -10,18 +10,18 @@ export async function unusedImports(options: unusedImports.Options = {}) {
10
10
  const [unusedImportPlugin] = await Promise.all([
11
11
  interopDefault(import('eslint-plugin-unused-imports')),
12
12
  ] as const);
13
- const { files = [sourceGlob], recommended, rules = {} } = defaultPluginOptions(options);
13
+ const { files = [sourceGlob], namespace, recommended, rules = {} } = defaultPluginOptions(options);
14
14
 
15
15
  return [
16
16
  {
17
- name: 'w5s/unused-imports/setup',
17
+ name: `${namespace}/unused-imports/setup`,
18
18
  plugins: {
19
19
  'unused-imports': unusedImportPlugin,
20
20
  },
21
21
  },
22
22
  {
23
23
  files,
24
- name: 'w5s/unused-imports/rules',
24
+ name: `${namespace}/unused-imports/rules`,
25
25
  rules: {
26
26
  ...(recommended
27
27
  ? {
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,