@w5s/eslint-config 2.4.4 → 3.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.
Files changed (91) hide show
  1. package/dist/index.cjs +4199 -0
  2. package/dist/index.cjs.map +1 -0
  3. package/dist/index.d.cts +8054 -0
  4. package/dist/index.d.ts +8054 -3
  5. package/dist/index.js +4171 -22
  6. package/dist/index.js.map +1 -0
  7. package/package.json +26 -17
  8. package/src/config/createRules.ts +5 -0
  9. package/src/config/es.ts +58 -0
  10. package/src/config/ignores.ts +84 -0
  11. package/src/config/imports.ts +32 -0
  12. package/src/config/jsdoc.ts +53 -0
  13. package/src/config/jsonc.ts +237 -0
  14. package/src/config/node.ts +42 -0
  15. package/src/config/stylistic.ts +50 -0
  16. package/src/config/test.ts +44 -0
  17. package/src/config/ts.ts +97 -0
  18. package/src/config/unicorn.ts +68 -0
  19. package/src/config/yml.ts +70 -0
  20. package/src/config.ts +11 -0
  21. package/src/defineConfig.ts +62 -0
  22. package/src/index.ts +3 -31
  23. package/src/type/Config.ts +5 -0
  24. package/src/type/PluginOptionsBase.ts +14 -0
  25. package/src/type/StylisticConfig.ts +39 -0
  26. package/src/type.ts +3 -0
  27. package/src/typegen/.keep +0 -0
  28. package/src/typegen/import.d.ts +501 -0
  29. package/src/typegen/jsdoc.d.ts +1155 -0
  30. package/src/typegen/jsonc.d.ts +500 -0
  31. package/src/typegen/node.d.ts +529 -0
  32. package/src/typegen/style.d.ts +1637 -0
  33. package/src/typegen/test.d.ts +430 -0
  34. package/src/typegen/ts.d.ts +1872 -0
  35. package/src/typegen/unicorn.d.ts +913 -0
  36. package/src/typegen/yml.d.ts +363 -0
  37. package/dist/es.d.ts +0 -3
  38. package/dist/es.js +0 -10
  39. package/dist/jest.d.ts +0 -3
  40. package/dist/jest.js +0 -20
  41. package/dist/json.d.ts +0 -3
  42. package/dist/json.js +0 -14
  43. package/dist/rules/es/base.d.ts +0 -4
  44. package/dist/rules/es/base.js +0 -71
  45. package/dist/rules/es/import.d.ts +0 -3
  46. package/dist/rules/es/import.js +0 -74
  47. package/dist/rules/es/jsdoc.d.ts +0 -3
  48. package/dist/rules/es/jsdoc.js +0 -21
  49. package/dist/rules/es/node.d.ts +0 -3
  50. package/dist/rules/es/node.js +0 -20
  51. package/dist/rules/es/promise.d.ts +0 -3
  52. package/dist/rules/es/promise.js +0 -11
  53. package/dist/rules/es/unicorn.d.ts +0 -3
  54. package/dist/rules/es/unicorn.js +0 -72
  55. package/dist/rules/es.d.ts +0 -3
  56. package/dist/rules/es.js +0 -14
  57. package/dist/rules/ignore.d.ts +0 -3
  58. package/dist/rules/ignore.js +0 -54
  59. package/dist/rules/jest.d.ts +0 -3
  60. package/dist/rules/jest.js +0 -64
  61. package/dist/rules/jsonc.d.ts +0 -3
  62. package/dist/rules/jsonc.js +0 -183
  63. package/dist/rules/prettier.d.ts +0 -3
  64. package/dist/rules/prettier.js +0 -13
  65. package/dist/rules/typescript.d.ts +0 -3
  66. package/dist/rules/typescript.js +0 -249
  67. package/dist/rules/yml.d.ts +0 -3
  68. package/dist/rules/yml.js +0 -21
  69. package/dist/tsconfig.build.tsbuildinfo +0 -1
  70. package/dist/typescript.d.ts +0 -3
  71. package/dist/typescript.js +0 -21
  72. package/dist/yml.d.ts +0 -3
  73. package/dist/yml.js +0 -19
  74. package/src/es.ts +0 -12
  75. package/src/jest.ts +0 -18
  76. package/src/json.ts +0 -12
  77. package/src/rules/es/base.ts +0 -83
  78. package/src/rules/es/import.ts +0 -81
  79. package/src/rules/es/jsdoc.ts +0 -23
  80. package/src/rules/es/node.ts +0 -21
  81. package/src/rules/es/promise.ts +0 -12
  82. package/src/rules/es/unicorn.ts +0 -74
  83. package/src/rules/es.ts +0 -21
  84. package/src/rules/ignore.ts +0 -54
  85. package/src/rules/jest.ts +0 -68
  86. package/src/rules/jsonc.ts +0 -187
  87. package/src/rules/prettier.ts +0 -11
  88. package/src/rules/typescript.ts +0 -255
  89. package/src/rules/yml.ts +0 -22
  90. package/src/typescript.ts +0 -24
  91. package/src/yml.ts +0 -18
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@w5s/eslint-config",
3
- "version": "2.4.4",
3
+ "version": "3.0.0",
4
4
  "description": "ESLint configuration presets",
5
5
  "keywords": [
6
6
  "eslint",
@@ -18,8 +18,20 @@
18
18
  },
19
19
  "license": "MIT",
20
20
  "author": "Julien Polo <julien.polo@gmail.com>",
21
- "type": "commonjs",
22
- "main": "dist/index.js",
21
+ "type": "module",
22
+ "exports": {
23
+ ".": {
24
+ "require": {
25
+ "types": "./dist/index.d.cts",
26
+ "default": "./dist/index.cjs"
27
+ },
28
+ "import": {
29
+ "types": "./dist/index.d.ts",
30
+ "default": "./dist/index.js"
31
+ }
32
+ },
33
+ "./dist/*": "./dist/*"
34
+ },
23
35
  "files": [
24
36
  "dist/",
25
37
  "src/",
@@ -33,28 +45,25 @@
33
45
  "postpack": "npx clean-package restore"
34
46
  },
35
47
  "dependencies": {
36
- "@rushstack/eslint-patch": "^1.1.0",
48
+ "@stylistic/eslint-plugin": "^2.0.0",
37
49
  "@typescript-eslint/eslint-plugin": "^8.0.0",
38
50
  "@typescript-eslint/parser": "^8.0.0",
39
- "@w5s/dev": "^2.5.3",
40
- "@w5s/prettier-config": "^2.2.10",
41
- "eslint-config-airbnb-base": "^15.0.0",
42
- "eslint-config-prettier": "^10.0.0",
51
+ "@vitest/eslint-plugin": "^1.0.0",
52
+ "@w5s/dev": "^3.0.0",
53
+ "@w5s/prettier-config": "^3.0.0",
43
54
  "eslint-plugin-import": "^2.25.0",
44
- "eslint-plugin-jest": "^28.0.0",
45
- "eslint-plugin-jsdoc": "^50.0.0",
55
+ "eslint-plugin-jsdoc": "^61.0.0",
46
56
  "eslint-plugin-jsonc": "^2.4.0",
47
57
  "eslint-plugin-n": "^17.0.0",
48
- "eslint-plugin-prettier": "^5.0.0-alpha.0",
49
- "eslint-plugin-promise": "^7.0.0",
50
58
  "eslint-plugin-unicorn": "^56.0.0",
51
59
  "eslint-plugin-yml": "^1.1.0",
52
60
  "find-up": "^5.0.0",
53
- "parse-gitignore": "^2.0.0"
61
+ "jsonc-eslint-parser": "^2.0.0",
62
+ "parse-gitignore": "^2.0.0",
63
+ "yaml-eslint-parser": "^1.0.0"
54
64
  },
55
65
  "peerDependencies": {
56
- "eslint": "8.x",
57
- "prettier": "2.x || 3.x",
66
+ "eslint": "9.x",
58
67
  "typescript": "4.x || 5.x"
59
68
  },
60
69
  "peerDependenciesMeta": {
@@ -66,11 +75,11 @@
66
75
  }
67
76
  },
68
77
  "engines": {
69
- "node": ">=18.0.0"
78
+ "node": ">=20.0.0"
70
79
  },
71
80
  "publishConfig": {
72
81
  "access": "public"
73
82
  },
74
83
  "sideEffect": false,
75
- "gitHead": "e50ce223ae442c3c06efe68aae22809092184290"
84
+ "gitHead": "e038232410218bd01be847ffe84bdb5f6261adc6"
76
85
  }
@@ -0,0 +1,5 @@
1
+ export function createRules(prefix: string) {
2
+ return {
3
+ [`${prefix}no-unused-vars`]: ['error', { argsIgnorePattern: '^_' }],
4
+ };
5
+ }
@@ -0,0 +1,58 @@
1
+ import globals from 'globals';
2
+ import eslintConfig from '@eslint/js';
3
+ import { Project } from '@w5s/dev';
4
+ import { type PluginOptionsBase, type Config } from '../type.js';
5
+ import type { RuleOptions } from '../typegen/jsonc.js';
6
+ import { createRules } from './createRules.js';
7
+
8
+ export async function es(
9
+ options: es.Options,
10
+ ) {
11
+ const { rules = {} } = options;
12
+
13
+ return [
14
+ {
15
+ name: 'w5s/es/setup',
16
+ languageOptions: {
17
+ ecmaVersion: Project.ecmaVersion(),
18
+ globals: {
19
+ ...globals.browser,
20
+ ...globals[`es${Project.ecmaVersion()}`],
21
+ ...globals.node,
22
+ __DEV__: 'readonly',
23
+ __PROD__: 'readonly',
24
+ __TEST__: 'readonly',
25
+ document: 'readonly',
26
+ navigator: 'readonly',
27
+ window: 'readonly',
28
+ },
29
+ parserOptions: {
30
+ ecmaFeatures: {
31
+ jsx: true,
32
+ },
33
+ ecmaVersion: Project.ecmaVersion(),
34
+ sourceType: 'module',
35
+ },
36
+ sourceType: 'module',
37
+ },
38
+ linterOptions: {
39
+ reportUnusedDisableDirectives: true,
40
+ },
41
+ },
42
+ {
43
+ name: 'w5s/es/rules',
44
+ plugins: {},
45
+ rules: {
46
+ ...eslintConfig.configs.recommended.rules,
47
+ ...createRules(''),
48
+ ...rules,
49
+ },
50
+ },
51
+ ] as [Config, Config] satisfies Array<Config>;
52
+ }
53
+
54
+ export namespace es {
55
+ export type Rules = RuleOptions;
56
+
57
+ export interface Options extends PluginOptionsBase<Rules> {}
58
+ }
@@ -0,0 +1,84 @@
1
+ import fs from 'node:fs';
2
+ import nodePath from 'node:path';
3
+ import process from 'node:process';
4
+ import findUp from 'find-up';
5
+ import parseGitignore from 'parse-gitignore';
6
+ import type { Config } from '../type.js';
7
+
8
+ const getGitignore = async (cwd: string, prefix = ''): Promise<Array<string>> => {
9
+ const gitIgnoreFile = await findUp(nodePath.join(prefix, '.gitignore'), { cwd });
10
+ if (gitIgnoreFile != null) {
11
+ const { patterns } = parseGitignore.parse(await fs.promises.readFile(gitIgnoreFile));
12
+ const returnValue = patterns.map((pattern) => nodePath.join(prefix, pattern));
13
+ return returnValue;
14
+ }
15
+ return [];
16
+ };
17
+
18
+ export async function ignores(options: ignores.Options = {}) {
19
+ const cwd = process.cwd();
20
+ const [ignoreRoot, ignoreAndroid, ignoreIOS] = await Promise.all([
21
+ getGitignore(cwd),
22
+ getGitignore(cwd, 'android'),
23
+ getGitignore(cwd, 'ios'),
24
+ ]);
25
+
26
+ return [
27
+ {
28
+ ignores: [
29
+ '**/node_modules',
30
+ '**/dist',
31
+ '**/package-lock.json',
32
+ '**/yarn.lock',
33
+ '**/pnpm-lock.yaml',
34
+ '**/bun.lockb',
35
+
36
+ '**/.docusaurus',
37
+ '**/output',
38
+ '**/coverage',
39
+ '**/temp',
40
+ '**/.temp',
41
+ '**/tmp',
42
+ '**/.tmp',
43
+ '**/.history',
44
+ '**/.vitepress/cache',
45
+ '**/.nuxt',
46
+ '**/.next',
47
+ '**/.svelte-kit',
48
+ '**/.vercel',
49
+ '**/.changeset',
50
+ '**/.idea',
51
+ '**/.cache',
52
+ '**/.output',
53
+ '**/.vite-inspect',
54
+ '**/.yarn',
55
+ '**/vendor',
56
+ '**/vendors',
57
+ '**/*.min.*',
58
+
59
+ '**/*.timestamp-*.mjs', // esbuild/vite temporary files
60
+
61
+ '.modules/',
62
+ '.go/',
63
+ '.pnpm-store/',
64
+ // '!.*',
65
+ // '.venv/',
66
+ // 'deprecated/',
67
+ // 'test-output/',
68
+ // 'venv/',
69
+ // '_generated_/',
70
+
71
+ ...ignoreRoot,
72
+ ...ignoreAndroid,
73
+ ...ignoreIOS,
74
+ ...(options.ignores ?? []),
75
+ ] as Array<string>,
76
+ name: 'w5s/ignore',
77
+ },
78
+ ] as const satisfies Array<Config>;
79
+ }
80
+ export namespace ignores {
81
+ export interface Options {
82
+ ignores?: string[];
83
+ }
84
+ }
@@ -0,0 +1,32 @@
1
+ import { PluginOptionsBase, StylisticConfig, type Config } from '../type.js';
2
+ import type { RuleOptions } from '../typegen/import.js';
3
+ // @ts-ignore
4
+ import importPlugin from 'eslint-plugin-import';
5
+
6
+ const importConfig = importPlugin.flatConfigs['recommended'];
7
+
8
+ export async function imports(options: imports.Options = {}) {
9
+ const { rules = {}, stylistic = true } = options;
10
+ const { enabled: stylisticEnabled } = StylisticConfig.from(stylistic);
11
+ return [
12
+ {
13
+ name: 'w5s/import/rules',
14
+ plugins: importConfig.plugins ?? {},
15
+ rules: {
16
+ ...(importConfig?.rules),
17
+ ...(stylisticEnabled
18
+ ? {
19
+ // Stylistic rules
20
+ }
21
+ : {}),
22
+ ...rules,
23
+ },
24
+ },
25
+ ] as [Config] satisfies Array<Config>;
26
+ }
27
+
28
+ export namespace imports {
29
+ export type Rules = RuleOptions;
30
+
31
+ export interface Options extends PluginOptionsBase<Rules> {}
32
+ }
@@ -0,0 +1,53 @@
1
+ import { interopDefault } from '@w5s/dev';
2
+ import { StylisticConfig, type PluginOptionsBase, type Config } from '../type.js';
3
+ import type { RuleOptions } from '../typegen/jsdoc.js';
4
+
5
+ export async function jsdoc(options: jsdoc.Options = {}): Promise<readonly Config[]> {
6
+ const [jsdocPlugin] = await Promise.all([
7
+ interopDefault(import('eslint-plugin-jsdoc')),
8
+ ] as const);
9
+ const { rules = {}, stylistic = true } = options;
10
+ const { enabled: stylisticEnabled } = StylisticConfig.from(stylistic);
11
+
12
+ return [
13
+ {
14
+ name: 'w5s/jsdoc/setup',
15
+ plugins: {
16
+ jsdoc: jsdocPlugin,
17
+ },
18
+ },
19
+ {
20
+ name: 'w5s/jsdoc/rules',
21
+ rules: {
22
+ ...(jsdocPlugin.configs['flat/recommended'].rules),
23
+ 'jsdoc/no-undefined-types': 'off', // https://github.com/gajus/eslint-plugin-jsdoc/issues/839
24
+ 'jsdoc/require-hyphen-before-param-description': ['warn', 'always'],
25
+ 'jsdoc/require-jsdoc': 'off',
26
+ 'jsdoc/require-param-description': 'off',
27
+ 'jsdoc/require-returns': 'off',
28
+ 'jsdoc/tag-lines': ['warn', 'any', { startLines: 1 }],
29
+ 'jsdoc/valid-types': 'off', // FIXME: reports lots of false positive
30
+ // 'strict': ['error', 'safe'],
31
+ ...(stylisticEnabled
32
+ ? {
33
+ // ...(jsdocPlugin.configs['flat/stylistic'].rules),
34
+ 'jsdoc/check-alignment': 'warn',
35
+ 'jsdoc/multiline-blocks': 'warn',
36
+ }
37
+ : {}),
38
+ ...rules,
39
+ },
40
+ settings: {
41
+ jsdoc: {
42
+ mode: 'typescript',
43
+ },
44
+ },
45
+ },
46
+ ] as [Config, Config] satisfies Array<Config>;
47
+ }
48
+
49
+ export namespace jsdoc {
50
+ export type Rules = RuleOptions;
51
+
52
+ export interface Options extends PluginOptionsBase<Rules> {}
53
+ }
@@ -0,0 +1,237 @@
1
+ /* cSpell:disable */
2
+ import { interopDefault, Project } from '@w5s/dev';
3
+ import { StylisticConfig, type PluginOptionsBase, type Config } from '../type.js';
4
+ import type { RuleOptions } from '../typegen/jsonc.js';
5
+
6
+ const defaultFiles = [`**/${Project.extensionsToGlob(['.json', '.json5', '.jsonc'])}`];
7
+
8
+ export async function jsonc(options: jsonc.Options = {}): Promise<readonly Config[]> {
9
+ const [jsoncPlugin, jsoncParser] = await Promise.all([
10
+ interopDefault(import('eslint-plugin-jsonc')),
11
+ interopDefault(import('jsonc-eslint-parser')),
12
+ ] as const);
13
+ const { files = defaultFiles, rules = {}, stylistic = true } = options;
14
+ const { enabled: stylisticEnabled, indent } = StylisticConfig.from(stylistic);
15
+
16
+ return [
17
+ {
18
+ name: 'w5s/jsonc/setup',
19
+ plugins: {
20
+ jsonc: jsoncPlugin,
21
+ },
22
+ },
23
+ {
24
+ files,
25
+ languageOptions: {
26
+ parser: jsoncParser,
27
+ },
28
+ name: 'w5s/jsonc/rules',
29
+ rules: {
30
+ ...(jsoncPlugin.configs['flat/recommended-with-json'][0]?.rules),
31
+ ...(stylisticEnabled
32
+ ? {
33
+ 'jsonc/array-bracket-spacing': ['error', 'never'],
34
+ 'jsonc/comma-dangle': ['error', 'never'],
35
+ 'jsonc/comma-style': ['error', 'last'],
36
+ 'jsonc/indent': ['error', indent],
37
+ 'jsonc/key-spacing': ['error', { afterColon: true, beforeColon: false }],
38
+ 'jsonc/object-curly-newline': ['error', { consistent: true, multiline: true }],
39
+ 'jsonc/object-curly-spacing': ['error', 'always'],
40
+ 'jsonc/object-property-newline': ['error', { allowMultiplePropertiesPerLine: true }],
41
+ 'jsonc/quote-props': 'error',
42
+ 'jsonc/quotes': 'error',
43
+ }
44
+ : {}),
45
+ ...rules,
46
+ },
47
+ },
48
+ stylisticEnabled ? sortPackageJson() : {},
49
+ stylisticEnabled ? sortTsconfigJson() : {},
50
+ ] as [Config, Config, Config, Config] satisfies Array<Config>;
51
+ }
52
+
53
+ function sortTsconfigJson() {
54
+ return {
55
+ files: ['tsconfig*.json'],
56
+ rules: {
57
+ 'jsonc/sort-keys': [
58
+ 'error',
59
+ {
60
+ order: ['$schema', 'display', 'extends', 'compilerOptions', 'include', 'exclude', 'files', 'references'],
61
+ pathPattern: '^$',
62
+ },
63
+ {
64
+ order: { type: 'asc' },
65
+ pathPattern: '.*',
66
+ },
67
+ ],
68
+ },
69
+ };
70
+ }
71
+
72
+ function sortPackageJson() {
73
+ return {
74
+ files: ['package.json'],
75
+ rules: {
76
+ 'jsonc/sort-keys': [
77
+ 'error',
78
+ {
79
+ order: [
80
+ '$schema',
81
+ 'name',
82
+ 'displayName',
83
+ 'version',
84
+ 'private',
85
+ 'description',
86
+ 'categories',
87
+ 'keywords',
88
+ 'homepage',
89
+ 'bugs',
90
+ 'repository',
91
+ 'funding',
92
+ 'license',
93
+ 'qna',
94
+ 'author',
95
+ 'maintainers', // Key order (per item): name, email, url
96
+ 'contributors', // Key order (per item): name, email, url
97
+ 'publisher',
98
+ 'sideEffects',
99
+ 'type',
100
+ 'imports',
101
+ 'exports',
102
+ 'main',
103
+ 'svelte',
104
+ 'umd:main',
105
+ 'jsdelivr',
106
+ 'unpkg',
107
+ 'module',
108
+ 'source',
109
+ 'jsnext:main',
110
+ 'browser',
111
+ 'react-native',
112
+ 'types',
113
+ 'typesVersions',
114
+ 'typings',
115
+ 'style',
116
+ 'example',
117
+ 'examplestyle',
118
+ 'assets',
119
+ 'bin',
120
+ 'man',
121
+ 'directories', // Key order: lib, bin, man, doc, example, test
122
+ 'files', // Unique items
123
+ 'workspaces',
124
+ 'binary', // Key order: module_name, module_path, remote_path, package_name, host
125
+ 'scripts', // Script sort
126
+ 'betterScripts', // Script sort
127
+ 'contributes',
128
+ 'activationEvents', // Unique items
129
+ 'husky', // Sorts the hooks field using git hook sort
130
+ 'simple-git-hooks', // Key sort using git hook sort
131
+ 'pre-commit',
132
+ 'commitlint',
133
+ 'lint-staged',
134
+ 'config',
135
+ 'nodemonConfig',
136
+ 'browserify',
137
+ 'babel',
138
+ 'browserslist',
139
+ 'xo',
140
+ 'prettier', // Prettier sort
141
+ 'eslintConfig', // ESLint sort
142
+ 'eslintIgnore',
143
+ 'npmpackagejsonlint', // Key sort (also recognizes: npmPackageJsonLintConfig, npmpkgjsonlint)
144
+ 'release',
145
+ 'remarkConfig',
146
+ 'stylelint',
147
+ 'ava',
148
+ 'jest',
149
+ 'mocha',
150
+ 'nyc',
151
+ 'tap',
152
+ 'resolutions',
153
+ 'dependencies',
154
+ 'devDependencies',
155
+ 'dependenciesMeta', // Key sort (deep)
156
+ 'peerDependencies',
157
+ 'peerDependenciesMeta', // Key sort (deep)
158
+ 'optionalDependencies',
159
+ 'bundledDependencies',
160
+ 'bundleDependencies',
161
+ 'extensionPack',
162
+ 'extensionDependencies',
163
+ 'flat',
164
+ 'packageManager',
165
+ 'engines',
166
+ 'engineStrict',
167
+ 'volta', // Key order: node, npm, yarn
168
+ 'languageName',
169
+ 'os',
170
+ 'cpu',
171
+ 'preferGlobal',
172
+ 'publishConfig',
173
+ 'icon',
174
+ 'badges', // Key order (per item): description, url, href
175
+ 'galleryBanner',
176
+ 'preview',
177
+ 'markdown',
178
+ ],
179
+ pathPattern: '^$',
180
+ },
181
+ {
182
+ order: ['url', 'email'],
183
+ pathPattern: `^bugs$`,
184
+ },
185
+ ...['repository', 'funding', 'license', 'author'].map((key) => ({
186
+ order: ['type', 'name', 'email', 'url'],
187
+ pathPattern: `^${key}$`,
188
+ })),
189
+ ...['scripts', 'betterScripts'].map((key) => ({
190
+ order: { type: 'asc' },
191
+ pathPattern: `^${key}$`,
192
+ })),
193
+ ...[
194
+ 'bin',
195
+ 'contributes',
196
+ 'commitlint',
197
+ 'config',
198
+ 'nodemonConfig',
199
+ 'browserify',
200
+ 'babel',
201
+ 'xo',
202
+ 'release',
203
+ 'remarkConfig',
204
+ 'ava',
205
+ 'jest',
206
+ 'mocha',
207
+ 'nyc',
208
+ 'tap',
209
+ 'resolutions',
210
+ 'engines',
211
+ 'engineStrict',
212
+ 'preferGlobal',
213
+ 'publishConfig',
214
+ 'galleryBanner',
215
+ ].map((key) => ({
216
+ order: { type: 'asc' },
217
+ pathPattern: `^${key}$`,
218
+ })),
219
+ {
220
+ order: { type: 'asc' },
221
+ pathPattern: '^(?:dev|peer|optional|bundled|extension)?[Dd]ependencies$',
222
+ },
223
+ {
224
+ order: ['types', 'require', 'import'],
225
+ pathPattern: '^exports.*$',
226
+ },
227
+ ],
228
+
229
+ },
230
+ };
231
+ }
232
+
233
+ export namespace jsonc {
234
+ export type Rules = RuleOptions;
235
+
236
+ export interface Options extends PluginOptionsBase<Rules> {}
237
+ }
@@ -0,0 +1,42 @@
1
+ import { interopDefault } from '@w5s/dev';
2
+ import { type Config, type PluginOptionsBase } from '../type.js';
3
+ import type { RuleOptions } from '../typegen/node.js';
4
+
5
+ export async function node(options: node.Options = {}) {
6
+ const [nodePlugin] = await Promise.all([
7
+ interopDefault(import('eslint-plugin-n')),
8
+ ] as const);
9
+ const { rules = {} } = options;
10
+ return [
11
+ {
12
+ name: 'w5s/node/setup',
13
+ plugins: {
14
+ node: nodePlugin,
15
+ },
16
+ },
17
+ {
18
+ name: 'w5s/node/rules',
19
+ rules: {
20
+ // 'node/handle-callback-err': ['error', '^(err|error|_error)$'],
21
+ 'node/no-deprecated-api': 'error',
22
+ 'node/no-exports-assign': 'error',
23
+ 'node/no-new-require': 'error',
24
+ 'node/no-path-concat': 'error',
25
+ 'node/no-sync': 'error',
26
+ 'node/prefer-global/buffer': ['error', 'never'],
27
+ 'node/prefer-global/console': ['error', 'always'],
28
+ // 'node/prefer-global/process': ['error', 'never'],
29
+ 'node/prefer-global/url': ['error', 'always'],
30
+ 'node/prefer-global/url-search-params': ['error', 'always'],
31
+ 'node/process-exit-as-throw': 'error',
32
+ ...rules,
33
+ },
34
+ },
35
+ ] as [Config, Config] satisfies Array<Config>;
36
+ }
37
+
38
+ export namespace node {
39
+ export type Rules = RuleOptions;
40
+
41
+ export interface Options extends Omit<PluginOptionsBase<Rules>, 'files' | 'stylistic'> {}
42
+ }
@@ -0,0 +1,50 @@
1
+ import { interopDefault } from '@w5s/dev';
2
+ import { StylisticConfig, type PluginOptionsBase, type Config, type StylisticParameters } from '../type.js';
3
+ import type { RuleOptions } from '../typegen/style.js';
4
+
5
+ export async function stylistic(options: stylistic.Options = {}) {
6
+ const [stylisticPlugin] = await Promise.all([
7
+ interopDefault(import('@stylistic/eslint-plugin')),
8
+ ] as const);
9
+ const { rules = {} } = options;
10
+ const { enabled: stylisticEnabled, indent, jsx, quotes, semi } = StylisticConfig.from(options);
11
+ const config = stylisticEnabled
12
+ ? stylisticPlugin.configs.customize({
13
+ indent,
14
+ jsx,
15
+ pluginName: 'style',
16
+ quotes,
17
+ semi,
18
+ })
19
+ : { rules: {} };
20
+
21
+ return [
22
+ {
23
+ name: 'w5s/style/setup',
24
+ plugins: {
25
+ style: stylisticPlugin,
26
+ },
27
+ },
28
+ {
29
+ name: 'w5s/style/rules',
30
+ rules: {
31
+ ...(stylisticEnabled
32
+ ? {
33
+ ...config.rules,
34
+ 'style/arrow-parens': ['error', 'always'],
35
+ 'style/brace-style': ['error', '1tbs'],
36
+ 'style/operator-linebreak': ['error', 'after', { overrides: { ':': 'before', '?': 'before', '|>': 'before' } }],
37
+ 'style/quotes': ['error', quotes ?? StylisticConfig.default.quotes, { avoidEscape: true, allowTemplateLiterals: true }],
38
+ }
39
+ : {}),
40
+ ...rules,
41
+ },
42
+ },
43
+ ] as [Config, Config] satisfies Array<Config>;
44
+ }
45
+
46
+ export namespace stylistic {
47
+ export type Rules = RuleOptions;
48
+
49
+ export interface Options extends Pick<PluginOptionsBase<Rules>, 'rules'>, StylisticParameters {}
50
+ }