@w5s/eslint-config 3.11.0 → 3.13.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/dist/index.d.ts +4811 -1988
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +215 -172
- package/dist/index.js.map +1 -1
- package/package.json +10 -9
- package/src/config/e18e.ts +8 -5
- package/src/config/es.ts +9 -7
- package/src/config/ignores.ts +1 -1
- package/src/config/imports.ts +11 -6
- package/src/config/jsdoc.ts +8 -5
- package/src/config/jsonc.ts +27 -24
- package/src/config/markdown.ts +25 -8
- package/src/config/next.ts +14 -11
- package/src/config/node.ts +5 -3
- package/src/config/perfectionist.ts +44 -0
- package/src/config/react.ts +9 -6
- package/src/config/stylistic.ts +7 -5
- package/src/config/test.ts +10 -7
- package/src/config/ts.ts +10 -7
- package/src/config/unicorn.ts +9 -6
- package/src/config/yml.ts +8 -5
- package/src/config.ts +2 -1
- package/src/defineConfig.ts +56 -32
- package/src/index.ts +2 -2
- package/src/internal/withDefaultFiles.ts +12 -0
- package/src/meta.ts +2 -2
- package/src/rules/esRules/bestPractices.ts +32 -32
- package/src/rules/esRules/errors.ts +8 -8
- package/src/rules/esRules/es6.ts +8 -8
- package/src/rules/esRules/variables.ts +4 -4
- package/src/rules/tsRules.ts +1 -0
- package/src/type/PluginOptionsBase.ts +8 -4
- package/src/type/StylisticConfig.ts +3 -2
- package/src/typegen/perfectionist.d.ts +4494 -0
- package/src/typegen/unicorn.d.ts +374 -310
package/src/config/e18e.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { interopDefault } from '@w5s/dev';
|
|
2
|
-
|
|
2
|
+
|
|
3
3
|
import type { RuleOptions } from '../typegen/e18e.js';
|
|
4
|
+
|
|
4
5
|
import { sourceGlob } from '../glob.js';
|
|
6
|
+
import { withDefaultFiles } from '../internal/withDefaultFiles.js';
|
|
7
|
+
import { type Config, type PluginOptionsBase, StylisticConfig } from '../type.js';
|
|
5
8
|
|
|
6
9
|
const defaultFiles = [sourceGlob];
|
|
7
10
|
|
|
@@ -11,7 +14,7 @@ const defaultFiles = [sourceGlob];
|
|
|
11
14
|
*/
|
|
12
15
|
export async function e18e(options: e18e.Options = {}) {
|
|
13
16
|
const [e18ePlugin] = await Promise.all([interopDefault(import('@e18e/eslint-plugin'))] as const);
|
|
14
|
-
const { files
|
|
17
|
+
const { files, modernization = true, moduleReplacements = false, performanceImprovements = true, rules = {}, stylistic = true } = options;
|
|
15
18
|
const { enabled: stylisticEnabled } = StylisticConfig.from(stylistic);
|
|
16
19
|
|
|
17
20
|
return [
|
|
@@ -22,8 +25,8 @@ export async function e18e(options: e18e.Options = {}) {
|
|
|
22
25
|
},
|
|
23
26
|
},
|
|
24
27
|
{
|
|
28
|
+
files: withDefaultFiles(files, defaultFiles),
|
|
25
29
|
name: 'w5s/e18e/rules',
|
|
26
|
-
files,
|
|
27
30
|
rules: {
|
|
28
31
|
...modernization ? e18ePlugin.configs.modernization.rules : {},
|
|
29
32
|
...moduleReplacements ? e18ePlugin.configs.moduleReplacements.rules : {},
|
|
@@ -44,8 +47,6 @@ export async function e18e(options: e18e.Options = {}) {
|
|
|
44
47
|
}
|
|
45
48
|
|
|
46
49
|
export namespace e18e {
|
|
47
|
-
export type Rules = RuleOptions;
|
|
48
|
-
|
|
49
50
|
export interface Options extends PluginOptionsBase<Rules> {
|
|
50
51
|
/**
|
|
51
52
|
* Include modernization default configuration
|
|
@@ -68,4 +69,6 @@ export namespace e18e {
|
|
|
68
69
|
*/
|
|
69
70
|
performanceImprovements?: boolean;
|
|
70
71
|
}
|
|
72
|
+
|
|
73
|
+
export type Rules = RuleOptions;
|
|
71
74
|
}
|
package/src/config/es.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import globals from 'globals';
|
|
2
1
|
import eslintConfig from '@eslint/js';
|
|
3
2
|
import { Project } from '@w5s/dev';
|
|
4
|
-
import
|
|
3
|
+
import globals from 'globals';
|
|
4
|
+
|
|
5
5
|
import type { RuleOptions } from '../typegen/jsonc.js';
|
|
6
|
-
|
|
6
|
+
|
|
7
7
|
import { esSourceGlob } from '../glob.js';
|
|
8
|
+
import { esRules } from '../rules/esRules.js';
|
|
9
|
+
import { type Config, type PluginOptionsBase } from '../type.js';
|
|
8
10
|
|
|
9
11
|
const defaultFiles = [esSourceGlob];
|
|
10
12
|
|
|
@@ -13,7 +15,6 @@ export async function es(options: es.Options) {
|
|
|
13
15
|
|
|
14
16
|
return [
|
|
15
17
|
{
|
|
16
|
-
name: 'w5s/es/setup',
|
|
17
18
|
languageOptions: {
|
|
18
19
|
ecmaVersion: Project.ecmaVersion(),
|
|
19
20
|
globals: {
|
|
@@ -39,10 +40,11 @@ export async function es(options: es.Options) {
|
|
|
39
40
|
linterOptions: {
|
|
40
41
|
reportUnusedDisableDirectives: true,
|
|
41
42
|
},
|
|
43
|
+
name: 'w5s/es/setup',
|
|
42
44
|
},
|
|
43
45
|
{
|
|
44
|
-
name: 'w5s/es/rules',
|
|
45
46
|
files: defaultFiles,
|
|
47
|
+
name: 'w5s/es/rules',
|
|
46
48
|
rules: {
|
|
47
49
|
...(recommended ? es['recommended'] : {}),
|
|
48
50
|
...rules,
|
|
@@ -60,7 +62,7 @@ es['recommended'] = {
|
|
|
60
62
|
};
|
|
61
63
|
|
|
62
64
|
export namespace es {
|
|
63
|
-
export type Rules = RuleOptions;
|
|
64
|
-
|
|
65
65
|
export interface Options extends PluginOptionsBase<Rules> {}
|
|
66
|
+
|
|
67
|
+
export type Rules = RuleOptions;
|
|
66
68
|
}
|
package/src/config/ignores.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { type ESLintIgnoreOptions, eslintIgnores } from '@w5s/eslint-config-ignore';
|
|
2
2
|
|
|
3
3
|
export async function ignores(options: ignores.Options = {}) {
|
|
4
4
|
const config = await eslintIgnores(options);
|
package/src/config/imports.ts
CHANGED
|
@@ -1,17 +1,22 @@
|
|
|
1
1
|
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';
|
|
6
|
+
|
|
5
7
|
export async function imports(options: imports.Options = {}) {
|
|
6
|
-
const {
|
|
8
|
+
const { recommended = true, rules = {}, stylistic = true } = options;
|
|
7
9
|
const { enabled: stylisticEnabled } = StylisticConfig.from(stylistic);
|
|
8
10
|
const [importPlugin] = await Promise.all([interopDefault(import('eslint-plugin-import'))] as const);
|
|
9
11
|
return [
|
|
10
12
|
{
|
|
11
|
-
name: 'w5s/import/
|
|
13
|
+
name: 'w5s/import/setup',
|
|
12
14
|
plugins: {
|
|
13
15
|
import: importPlugin,
|
|
14
16
|
},
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
name: 'w5s/import/rules',
|
|
15
20
|
rules: {
|
|
16
21
|
...(recommended ? imports['recommended'] : {}),
|
|
17
22
|
...(stylisticEnabled
|
|
@@ -20,7 +25,7 @@ export async function imports(options: imports.Options = {}) {
|
|
|
20
25
|
...rules,
|
|
21
26
|
},
|
|
22
27
|
},
|
|
23
|
-
] as [Config] satisfies Array<Config>;
|
|
28
|
+
] as [Config, Config] satisfies Array<Config>;
|
|
24
29
|
}
|
|
25
30
|
|
|
26
31
|
/**
|
|
@@ -42,7 +47,7 @@ imports['stylistic'] = {
|
|
|
42
47
|
};
|
|
43
48
|
|
|
44
49
|
export namespace imports {
|
|
45
|
-
export type Rules = RuleOptions;
|
|
46
|
-
|
|
47
50
|
export interface Options extends PluginOptionsBase<Rules> {}
|
|
51
|
+
|
|
52
|
+
export type Rules = RuleOptions;
|
|
48
53
|
}
|
package/src/config/jsdoc.ts
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import { interopDefault } from '@w5s/dev';
|
|
2
|
-
|
|
2
|
+
|
|
3
3
|
import type { RuleOptions } from '../typegen/jsdoc.js';
|
|
4
|
+
|
|
4
5
|
import { sourceGlob } from '../glob.js';
|
|
6
|
+
import { withDefaultFiles } from '../internal/withDefaultFiles.js';
|
|
7
|
+
import { type Config, type PluginOptionsBase, StylisticConfig } from '../type.js';
|
|
5
8
|
|
|
6
9
|
const defaultFiles = [sourceGlob];
|
|
7
10
|
|
|
8
11
|
export async function jsdoc(options: jsdoc.Options = {}): Promise<readonly Config[]> {
|
|
9
12
|
const [jsdocPlugin] = await Promise.all([interopDefault(import('eslint-plugin-jsdoc'))] as const);
|
|
10
13
|
const {
|
|
11
|
-
files
|
|
14
|
+
files,
|
|
12
15
|
recommended = true,
|
|
13
16
|
rules = {},
|
|
14
17
|
stylistic = true,
|
|
@@ -23,8 +26,8 @@ export async function jsdoc(options: jsdoc.Options = {}): Promise<readonly Confi
|
|
|
23
26
|
},
|
|
24
27
|
},
|
|
25
28
|
{
|
|
29
|
+
files: withDefaultFiles(files, defaultFiles),
|
|
26
30
|
name: 'w5s/jsdoc/rules',
|
|
27
|
-
files,
|
|
28
31
|
rules: {
|
|
29
32
|
...(recommended ? jsdocPlugin.configs['flat/recommended-typescript-flavor'].rules : {}),
|
|
30
33
|
|
|
@@ -61,7 +64,7 @@ export async function jsdoc(options: jsdoc.Options = {}): Promise<readonly Confi
|
|
|
61
64
|
}
|
|
62
65
|
|
|
63
66
|
export namespace jsdoc {
|
|
64
|
-
export type Rules = RuleOptions;
|
|
65
|
-
|
|
66
67
|
export interface Options extends PluginOptionsBase<Rules> {}
|
|
68
|
+
|
|
69
|
+
export type Rules = RuleOptions;
|
|
67
70
|
}
|
package/src/config/jsonc.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
/* cSpell:disable */
|
|
2
2
|
import { interopDefault } from '@w5s/dev';
|
|
3
|
-
|
|
3
|
+
|
|
4
4
|
import type { RuleOptions } from '../typegen/jsonc.js';
|
|
5
|
+
|
|
5
6
|
import { jsonSourceGlob } from '../glob.js';
|
|
7
|
+
import { withDefaultFiles } from '../internal/withDefaultFiles.js';
|
|
8
|
+
import { type Config, type PluginOptionsBase, StylisticConfig } from '../type.js';
|
|
6
9
|
|
|
7
10
|
const defaultFiles = [jsonSourceGlob];
|
|
8
11
|
|
|
@@ -12,7 +15,7 @@ export async function jsonc(options: jsonc.Options = {}): Promise<readonly Confi
|
|
|
12
15
|
interopDefault(import('jsonc-eslint-parser')),
|
|
13
16
|
] as const);
|
|
14
17
|
const {
|
|
15
|
-
files
|
|
18
|
+
files,
|
|
16
19
|
recommended = true,
|
|
17
20
|
rules = {},
|
|
18
21
|
stylistic = true,
|
|
@@ -27,7 +30,7 @@ export async function jsonc(options: jsonc.Options = {}): Promise<readonly Confi
|
|
|
27
30
|
},
|
|
28
31
|
},
|
|
29
32
|
{
|
|
30
|
-
files,
|
|
33
|
+
files: withDefaultFiles(files, defaultFiles),
|
|
31
34
|
languageOptions: {
|
|
32
35
|
parser: jsoncParser,
|
|
33
36
|
},
|
|
@@ -56,25 +59,6 @@ export async function jsonc(options: jsonc.Options = {}): Promise<readonly Confi
|
|
|
56
59
|
] as [Config, Config, Config, Config] satisfies Array<Config>;
|
|
57
60
|
}
|
|
58
61
|
|
|
59
|
-
function sortTsconfigJson() {
|
|
60
|
-
return {
|
|
61
|
-
files: ['**/tsconfig*.json'],
|
|
62
|
-
rules: {
|
|
63
|
-
'jsonc/sort-keys': [
|
|
64
|
-
'error',
|
|
65
|
-
{
|
|
66
|
-
order: ['$schema', 'display', 'extends', 'compilerOptions', 'include', 'exclude', 'files', 'references'],
|
|
67
|
-
pathPattern: '^$',
|
|
68
|
-
},
|
|
69
|
-
{
|
|
70
|
-
order: { type: 'asc' },
|
|
71
|
-
pathPattern: '.*',
|
|
72
|
-
},
|
|
73
|
-
],
|
|
74
|
-
},
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
|
|
78
62
|
function sortPackageJson() {
|
|
79
63
|
return {
|
|
80
64
|
files: ['**/package.json'],
|
|
@@ -235,8 +219,27 @@ function sortPackageJson() {
|
|
|
235
219
|
};
|
|
236
220
|
}
|
|
237
221
|
|
|
238
|
-
|
|
239
|
-
|
|
222
|
+
function sortTsconfigJson() {
|
|
223
|
+
return {
|
|
224
|
+
files: ['**/tsconfig*.json'],
|
|
225
|
+
rules: {
|
|
226
|
+
'jsonc/sort-keys': [
|
|
227
|
+
'error',
|
|
228
|
+
{
|
|
229
|
+
order: ['$schema', 'display', 'extends', 'compilerOptions', 'include', 'exclude', 'files', 'references'],
|
|
230
|
+
pathPattern: '^$',
|
|
231
|
+
},
|
|
232
|
+
{
|
|
233
|
+
order: { type: 'asc' },
|
|
234
|
+
pathPattern: '.*',
|
|
235
|
+
},
|
|
236
|
+
],
|
|
237
|
+
},
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
240
|
|
|
241
|
+
export namespace jsonc {
|
|
241
242
|
export interface Options extends PluginOptionsBase<Rules> {}
|
|
243
|
+
|
|
244
|
+
export type Rules = RuleOptions;
|
|
242
245
|
}
|
package/src/config/markdown.ts
CHANGED
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
import { interopDefault, Project } from '@w5s/dev';
|
|
2
2
|
import { mergeProcessors, processorPassThrough } from 'eslint-merge-processors';
|
|
3
|
-
|
|
3
|
+
|
|
4
4
|
import type { RuleOptions } from '../typegen/markdown.js';
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
import { withDefaultFiles } from '../internal/withDefaultFiles.js';
|
|
7
|
+
import { type Config, type PluginOptionsBase, StylisticConfig } from '../type.js';
|
|
8
|
+
|
|
9
|
+
const defaultFiles = [`**/${Project.extensionsToGlob(Project.queryExtensions(['markdown']))}`, '**/CHANGELOG.md', '**/CODE_OF_CONDUCT.md'];
|
|
7
10
|
|
|
8
11
|
export async function markdown(options: markdown.Options = {}) {
|
|
9
12
|
const [markdownPlugin] = await Promise.all([interopDefault(import('@eslint/markdown'))] as const);
|
|
10
13
|
const {
|
|
14
|
+
files,
|
|
11
15
|
language = 'markdown/gfm',
|
|
12
|
-
|
|
16
|
+
languageOptions,
|
|
13
17
|
recommended = true,
|
|
14
18
|
rules = {},
|
|
15
19
|
stylistic = true,
|
|
@@ -24,8 +28,12 @@ export async function markdown(options: markdown.Options = {}) {
|
|
|
24
28
|
},
|
|
25
29
|
},
|
|
26
30
|
{
|
|
27
|
-
files,
|
|
28
|
-
language
|
|
31
|
+
files: withDefaultFiles(files, defaultFiles),
|
|
32
|
+
language,
|
|
33
|
+
languageOptions: {
|
|
34
|
+
frontmatter: 'yaml',
|
|
35
|
+
...languageOptions,
|
|
36
|
+
},
|
|
29
37
|
name: 'w5s/markdown/rules',
|
|
30
38
|
// eslint-disable-next-line ts/no-non-null-assertion
|
|
31
39
|
processor: mergeProcessors([markdownPlugin.processors!.markdown, processorPassThrough]),
|
|
@@ -39,12 +47,21 @@ export async function markdown(options: markdown.Options = {}) {
|
|
|
39
47
|
}
|
|
40
48
|
|
|
41
49
|
export namespace markdown {
|
|
42
|
-
export type Rules = RuleOptions;
|
|
43
|
-
|
|
44
50
|
export interface Options extends PluginOptionsBase<Rules> {
|
|
45
51
|
/**
|
|
46
52
|
* Default to 'markdown/gfm' (Github Flavored Markdown)
|
|
47
53
|
*/
|
|
48
|
-
language?: 'markdown/
|
|
54
|
+
language?: 'markdown/commonmark' | 'markdown/gfm';
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Default to 'yaml'
|
|
58
|
+
* If you want to use TOML frontmatter, set this to 'toml'
|
|
59
|
+
* If you want to disable frontmatter parsing, set this to undefined
|
|
60
|
+
*/
|
|
61
|
+
languageOptions?: {
|
|
62
|
+
frontmatter?: 'toml' | 'yaml';
|
|
63
|
+
};
|
|
49
64
|
}
|
|
65
|
+
|
|
66
|
+
export type Rules = RuleOptions;
|
|
50
67
|
}
|
package/src/config/next.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { ESLintConfig, interopDefault } from '@w5s/dev';
|
|
2
|
-
|
|
2
|
+
|
|
3
3
|
import type { RuleOptions } from '../typegen/next.js';
|
|
4
|
+
|
|
4
5
|
import { sourceGlob } from '../glob.js';
|
|
6
|
+
import { withDefaultFiles } from '../internal/withDefaultFiles.js';
|
|
7
|
+
import { type Config, type PluginOptionsBase } from '../type.js';
|
|
5
8
|
|
|
6
9
|
const defaultFiles = [sourceGlob];
|
|
7
10
|
|
|
@@ -9,7 +12,7 @@ export async function next(options: next.Options = {}) {
|
|
|
9
12
|
const [nextPlugin] = await Promise.all([
|
|
10
13
|
interopDefault(import('@next/eslint-plugin-next')),
|
|
11
14
|
] as const);
|
|
12
|
-
const { files
|
|
15
|
+
const { files, recommended = true, rules = {} } = options;
|
|
13
16
|
|
|
14
17
|
return [
|
|
15
18
|
{
|
|
@@ -19,8 +22,7 @@ export async function next(options: next.Options = {}) {
|
|
|
19
22
|
},
|
|
20
23
|
},
|
|
21
24
|
{
|
|
22
|
-
|
|
23
|
-
files,
|
|
25
|
+
files: withDefaultFiles(files, defaultFiles),
|
|
24
26
|
languageOptions: {
|
|
25
27
|
parserOptions: {
|
|
26
28
|
ecmaFeatures: {
|
|
@@ -29,22 +31,23 @@ export async function next(options: next.Options = {}) {
|
|
|
29
31
|
},
|
|
30
32
|
sourceType: 'module',
|
|
31
33
|
},
|
|
32
|
-
|
|
33
|
-
react: {
|
|
34
|
-
version: 'detect',
|
|
35
|
-
},
|
|
36
|
-
},
|
|
34
|
+
name: 'w5s/next/rules',
|
|
37
35
|
rules: {
|
|
38
36
|
...(recommended ? ESLintConfig.renameRules(nextPlugin.configs.recommended.rules ?? {}, { '@next/next': 'next' }) : {}),
|
|
39
37
|
...(recommended ? ESLintConfig.renameRules(nextPlugin.configs['core-web-vitals'].rules ?? {}, { '@next/next': 'next' }) : {}),
|
|
40
38
|
...rules,
|
|
41
39
|
},
|
|
40
|
+
settings: {
|
|
41
|
+
react: {
|
|
42
|
+
version: 'detect',
|
|
43
|
+
},
|
|
44
|
+
},
|
|
42
45
|
},
|
|
43
46
|
] as [Config, Config] satisfies Array<Config>;
|
|
44
47
|
}
|
|
45
48
|
|
|
46
49
|
export namespace next {
|
|
47
|
-
export type Rules = RuleOptions;
|
|
48
|
-
|
|
49
50
|
export interface Options extends Omit<PluginOptionsBase<Rules>, 'stylistic'> {}
|
|
51
|
+
|
|
52
|
+
export type Rules = RuleOptions;
|
|
50
53
|
}
|
package/src/config/node.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { interopDefault } from '@w5s/dev';
|
|
2
|
-
|
|
2
|
+
|
|
3
3
|
import type { RuleOptions } from '../typegen/node.js';
|
|
4
4
|
|
|
5
|
+
import { type Config, type PluginOptionsBase } from '../type.js';
|
|
6
|
+
|
|
5
7
|
export async function node(options: node.Options = {}) {
|
|
6
8
|
const [nodePlugin] = await Promise.all([
|
|
7
9
|
interopDefault(import('eslint-plugin-n')),
|
|
@@ -41,7 +43,7 @@ export async function node(options: node.Options = {}) {
|
|
|
41
43
|
}
|
|
42
44
|
|
|
43
45
|
export namespace node {
|
|
44
|
-
export type Rules = RuleOptions;
|
|
45
|
-
|
|
46
46
|
export interface Options extends Omit<PluginOptionsBase<Rules>, 'files' | 'stylistic'> {}
|
|
47
|
+
|
|
48
|
+
export type Rules = RuleOptions;
|
|
47
49
|
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { interopDefault } from '@w5s/dev';
|
|
2
|
+
|
|
3
|
+
import type { RuleOptions } from '../typegen/perfectionist.js';
|
|
4
|
+
|
|
5
|
+
import { sourceGlob } from '../glob.js';
|
|
6
|
+
import { withDefaultFiles } from '../internal/withDefaultFiles.js';
|
|
7
|
+
import { type Config, type PluginOptionsBase, StylisticConfig } from '../type.js';
|
|
8
|
+
|
|
9
|
+
const defaultFiles = [sourceGlob];
|
|
10
|
+
|
|
11
|
+
export async function perfectionist(options: perfectionist.Options = {}) {
|
|
12
|
+
const [perfectionistPlugin] = await Promise.all([interopDefault(import('eslint-plugin-perfectionist'))] as const);
|
|
13
|
+
const {
|
|
14
|
+
files,
|
|
15
|
+
recommended = true,
|
|
16
|
+
rules = {},
|
|
17
|
+
stylistic = true,
|
|
18
|
+
} = options;
|
|
19
|
+
const { enabled: stylisticEnabled } = StylisticConfig.from(stylistic);
|
|
20
|
+
|
|
21
|
+
return [
|
|
22
|
+
{
|
|
23
|
+
name: 'w5s/perfectionist/setup',
|
|
24
|
+
plugins: {
|
|
25
|
+
perfectionist: perfectionistPlugin,
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
files: withDefaultFiles(files, defaultFiles),
|
|
30
|
+
name: 'w5s/perfectionist/rules',
|
|
31
|
+
rules: {
|
|
32
|
+
...(recommended ? perfectionistPlugin.configs['recommended-natural'].rules : {}),
|
|
33
|
+
...(stylisticEnabled ? {} : {}),
|
|
34
|
+
...rules,
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
] as [Config, Config] satisfies Array<Config>;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export namespace perfectionist {
|
|
41
|
+
export interface Options extends PluginOptionsBase<Rules> {}
|
|
42
|
+
|
|
43
|
+
export type Rules = RuleOptions;
|
|
44
|
+
}
|
package/src/config/react.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { interopDefault } from '@w5s/dev';
|
|
2
|
-
|
|
2
|
+
|
|
3
3
|
import type { RuleOptions } from '../typegen/react.js';
|
|
4
|
+
|
|
4
5
|
import { sourceGlob } from '../glob.js';
|
|
6
|
+
import { withDefaultFiles } from '../internal/withDefaultFiles.js';
|
|
7
|
+
import { type Config, type PluginOptionsBase } from '../type.js';
|
|
5
8
|
|
|
6
9
|
const defaultFiles = [sourceGlob];
|
|
7
10
|
|
|
@@ -9,7 +12,7 @@ export async function react(options: react.Options = {}) {
|
|
|
9
12
|
const [reactPlugin] = await Promise.all([
|
|
10
13
|
interopDefault(import('@eslint-react/eslint-plugin')),
|
|
11
14
|
] as const);
|
|
12
|
-
const { files
|
|
15
|
+
const { files, recommended, rules = {} } = options;
|
|
13
16
|
return [
|
|
14
17
|
{
|
|
15
18
|
name: 'w5s/react/setup',
|
|
@@ -18,8 +21,7 @@ export async function react(options: react.Options = {}) {
|
|
|
18
21
|
},
|
|
19
22
|
},
|
|
20
23
|
{
|
|
21
|
-
|
|
22
|
-
files,
|
|
24
|
+
files: withDefaultFiles(files, defaultFiles),
|
|
23
25
|
languageOptions: {
|
|
24
26
|
parserOptions: {
|
|
25
27
|
ecmaFeatures: {
|
|
@@ -28,6 +30,7 @@ export async function react(options: react.Options = {}) {
|
|
|
28
30
|
},
|
|
29
31
|
sourceType: 'module',
|
|
30
32
|
},
|
|
33
|
+
name: 'w5s/react/rules',
|
|
31
34
|
rules: {
|
|
32
35
|
...(recommended ? reactPlugin.configs['recommended'].rules : {}),
|
|
33
36
|
...rules,
|
|
@@ -37,7 +40,7 @@ export async function react(options: react.Options = {}) {
|
|
|
37
40
|
}
|
|
38
41
|
|
|
39
42
|
export namespace react {
|
|
40
|
-
export type Rules = RuleOptions;
|
|
41
|
-
|
|
42
43
|
export interface Options extends Omit<PluginOptionsBase<Rules>, 'stylistic'> {}
|
|
44
|
+
|
|
45
|
+
export type Rules = RuleOptions;
|
|
43
46
|
}
|
package/src/config/stylistic.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { interopDefault } from '@w5s/dev';
|
|
2
|
-
|
|
2
|
+
|
|
3
3
|
import type { RuleOptions } from '../typegen/style.js';
|
|
4
4
|
|
|
5
|
+
import { type Config, type PluginOptionsBase, StylisticConfig, type StylisticParameters } from '../type.js';
|
|
6
|
+
|
|
5
7
|
export async function stylistic(options: stylistic.Options = {}) {
|
|
6
8
|
const [stylisticPlugin] = await Promise.all([
|
|
7
9
|
interopDefault(import('@stylistic/eslint-plugin')),
|
|
@@ -33,8 +35,8 @@ export async function stylistic(options: stylistic.Options = {}) {
|
|
|
33
35
|
...config.rules,
|
|
34
36
|
'style/arrow-parens': ['error', 'always'],
|
|
35
37
|
'style/brace-style': ['error', '1tbs'],
|
|
36
|
-
'style/operator-linebreak': ['error', 'after', { overrides: { ':': 'before', '?': 'before', '
|
|
37
|
-
'style/quotes': ['error', quotes ?? StylisticConfig.default.quotes, {
|
|
38
|
+
'style/operator-linebreak': ['error', 'after', { overrides: { ':': 'before', '?': 'before', '|': 'before', '|>': 'before' } }],
|
|
39
|
+
'style/quotes': ['error', quotes ?? StylisticConfig.default.quotes, { allowTemplateLiterals: 'always', avoidEscape: true }],
|
|
38
40
|
}
|
|
39
41
|
: {}),
|
|
40
42
|
...rules,
|
|
@@ -44,7 +46,7 @@ export async function stylistic(options: stylistic.Options = {}) {
|
|
|
44
46
|
}
|
|
45
47
|
|
|
46
48
|
export namespace stylistic {
|
|
47
|
-
export type Rules = RuleOptions;
|
|
48
|
-
|
|
49
49
|
export interface Options extends Pick<PluginOptionsBase<Rules>, 'rules'>, StylisticParameters {}
|
|
50
|
+
|
|
51
|
+
export type Rules = RuleOptions;
|
|
50
52
|
}
|
package/src/config/test.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { ESLintConfig, interopDefault, Project } from '@w5s/dev';
|
|
2
|
-
|
|
2
|
+
|
|
3
3
|
import type { RuleOptions } from '../typegen/test.js';
|
|
4
4
|
|
|
5
|
+
import { withDefaultFiles } from '../internal/withDefaultFiles.js';
|
|
6
|
+
import { type Config, type PluginOptionsBase, StylisticConfig } from '../type.js';
|
|
7
|
+
|
|
5
8
|
const sourceGlob = Project.extensionsToGlob(Project.sourceExtensions());
|
|
6
9
|
const defaultFiles = [
|
|
7
10
|
`**/__mocks__/**/${sourceGlob}`,
|
|
@@ -13,7 +16,7 @@ export async function test(options: test.Options = {}) {
|
|
|
13
16
|
const [vitestPlugin] = await Promise.all([
|
|
14
17
|
interopDefault(import('@vitest/eslint-plugin')),
|
|
15
18
|
] as const);
|
|
16
|
-
const { files
|
|
19
|
+
const { files, recommended = true, rules = {}, stylistic = true } = options;
|
|
17
20
|
const { enabled: stylisticEnabled } = StylisticConfig.from(stylistic);
|
|
18
21
|
|
|
19
22
|
return [
|
|
@@ -24,7 +27,7 @@ export async function test(options: test.Options = {}) {
|
|
|
24
27
|
},
|
|
25
28
|
},
|
|
26
29
|
{
|
|
27
|
-
files,
|
|
30
|
+
files: withDefaultFiles(files, defaultFiles),
|
|
28
31
|
name: 'w5s/test/rules',
|
|
29
32
|
rules: {
|
|
30
33
|
...(recommended
|
|
@@ -32,9 +35,9 @@ export async function test(options: test.Options = {}) {
|
|
|
32
35
|
vitest: 'test',
|
|
33
36
|
})
|
|
34
37
|
: {}),
|
|
35
|
-
'test/valid-title': ESLintConfig.fixme(undefined),
|
|
36
|
-
|
|
37
38
|
'e18e/prefer-static-regex': 'off',
|
|
39
|
+
|
|
40
|
+
'test/valid-title': ESLintConfig.fixme(undefined),
|
|
38
41
|
...(stylisticEnabled
|
|
39
42
|
? {}
|
|
40
43
|
: {}),
|
|
@@ -45,7 +48,7 @@ export async function test(options: test.Options = {}) {
|
|
|
45
48
|
}
|
|
46
49
|
|
|
47
50
|
export namespace test {
|
|
48
|
-
export type Rules = RuleOptions;
|
|
49
|
-
|
|
50
51
|
export interface Options extends PluginOptionsBase<Rules> {}
|
|
52
|
+
|
|
53
|
+
export type Rules = RuleOptions;
|
|
51
54
|
}
|
package/src/config/ts.ts
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
/* eslint-disable ts/no-non-null-assertion */
|
|
2
2
|
import { ESLintConfig, interopDefault } from '@w5s/dev';
|
|
3
|
-
|
|
3
|
+
|
|
4
4
|
import type { RuleOptions } from '../typegen/ts.js';
|
|
5
|
-
|
|
5
|
+
|
|
6
6
|
import { tsSourceGlob } from '../glob.js';
|
|
7
|
+
import { withDefaultFiles } from '../internal/withDefaultFiles.js';
|
|
8
|
+
import { tsRules } from '../rules/tsRules.js';
|
|
9
|
+
import { type Config, type PluginOptionsBase, StylisticConfig } from '../type.js';
|
|
7
10
|
|
|
8
11
|
const defaultFiles = [tsSourceGlob];
|
|
9
12
|
|
|
@@ -15,7 +18,7 @@ export async function ts(options: ts.Options = {}) {
|
|
|
15
18
|
const tsRecommendedRules = tsPlugin.configs['eslint-recommended']!.overrides![0]!.rules!;
|
|
16
19
|
const tsStrictRules = tsPlugin.configs['strict']!.rules!;
|
|
17
20
|
const tsTypeCheckedRules = tsPlugin.configs['recommended-type-checked-only']!.rules!;
|
|
18
|
-
const { files
|
|
21
|
+
const { files, rules = {}, stylistic = true, typeChecked = false } = options;
|
|
19
22
|
const { enabled: stylisticEnabled } = StylisticConfig.from(stylistic);
|
|
20
23
|
|
|
21
24
|
return [
|
|
@@ -26,7 +29,7 @@ export async function ts(options: ts.Options = {}) {
|
|
|
26
29
|
},
|
|
27
30
|
},
|
|
28
31
|
{
|
|
29
|
-
files,
|
|
32
|
+
files: withDefaultFiles(files, defaultFiles),
|
|
30
33
|
languageOptions: {
|
|
31
34
|
parser: tsParser,
|
|
32
35
|
parserOptions: {
|
|
@@ -65,12 +68,12 @@ export async function ts(options: ts.Options = {}) {
|
|
|
65
68
|
},
|
|
66
69
|
] as const)
|
|
67
70
|
: []),
|
|
68
|
-
] as [Config, Config] | [Config, Config
|
|
71
|
+
] as [Config, Config, Config] | [Config, Config] satisfies Array<Config>;
|
|
69
72
|
}
|
|
70
73
|
export namespace ts {
|
|
71
|
-
export type Rules = RuleOptions;
|
|
72
|
-
|
|
73
74
|
export interface Options extends PluginOptionsBase<Rules> {
|
|
74
75
|
typeChecked?: boolean;
|
|
75
76
|
}
|
|
77
|
+
|
|
78
|
+
export type Rules = RuleOptions;
|
|
76
79
|
}
|