@w5s/eslint-config 3.40.0 → 5.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/dist/index.d.ts +28 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +127 -100
- package/dist/index.js.map +1 -1
- package/package.json +7 -7
- package/src/config/e18e.ts +14 -6
- package/src/config/es.ts +7 -5
- package/src/config/imports.ts +6 -6
- package/src/config/jsdoc.ts +10 -9
- package/src/config/jsonc.ts +12 -11
- package/src/config/jsx.ts +5 -3
- package/src/config/markdown.ts +11 -10
- package/src/config/next.ts +1 -1
- package/src/config/node.ts +4 -3
- package/src/config/perfectionist.ts +9 -8
- package/src/config/react.ts +4 -3
- package/src/config/stylistic.ts +4 -3
- package/src/config/test.ts +6 -6
- package/src/config/ts.ts +9 -8
- package/src/config/unicorn.ts +7 -7
- package/src/config/unused-imports.ts +4 -3
- package/src/config/yml.ts +6 -5
- package/src/glob.ts +6 -6
- package/src/internal/defaultOptions.ts +19 -0
- package/src/type/PluginOptionsBase.ts +8 -0
- package/src/typegen/jsdoc.d.ts +30 -0
package/src/config/unicorn.ts
CHANGED
|
@@ -3,26 +3,26 @@ import { interopDefault } from '@w5s/dev';
|
|
|
3
3
|
import type { RuleOptions } from '../typegen/unicorn.js';
|
|
4
4
|
|
|
5
5
|
import { sourceGlob } from '../glob.js';
|
|
6
|
+
import { defaultPluginOptions } from '../internal/defaultOptions.js';
|
|
6
7
|
import { withDefaultFiles } from '../internal/withDefaultFiles.js';
|
|
7
|
-
import { type Config, type PluginOptionsBase
|
|
8
|
+
import { type Config, type PluginOptionsBase } from '../type.js';
|
|
8
9
|
|
|
9
10
|
const defaultFiles = [sourceGlob];
|
|
10
11
|
|
|
11
12
|
export async function unicorn(options: unicorn.Options = {}) {
|
|
12
13
|
const [unicornPlugin] = await Promise.all([interopDefault(import('eslint-plugin-unicorn'))] as const);
|
|
13
|
-
const { files, recommended
|
|
14
|
-
const { enabled: stylisticEnabled } = StylisticConfig.from(stylistic);
|
|
14
|
+
const { files, namespace, recommended, rules = {}, stylistic } = defaultPluginOptions(options);
|
|
15
15
|
|
|
16
16
|
return [
|
|
17
17
|
{
|
|
18
|
-
name:
|
|
18
|
+
name: `${namespace}/unicorn/setup`,
|
|
19
19
|
plugins: {
|
|
20
20
|
unicorn: unicornPlugin,
|
|
21
21
|
},
|
|
22
22
|
},
|
|
23
23
|
{
|
|
24
24
|
files: withDefaultFiles(files, defaultFiles),
|
|
25
|
-
name:
|
|
25
|
+
name: `${namespace}/unicorn/rules`,
|
|
26
26
|
rules: {
|
|
27
27
|
...(recommended && unicornPlugin.configs.unopinionated.rules),
|
|
28
28
|
// Disabled for safety
|
|
@@ -37,14 +37,14 @@ export async function unicorn(options: unicorn.Options = {}) {
|
|
|
37
37
|
'unicorn/prefer-default-parameters': 'off',
|
|
38
38
|
'unicorn/prefer-set-has': 'off',
|
|
39
39
|
'unicorn/throw-new-error': 'off', // Creating errors with call signature is OK
|
|
40
|
-
...(
|
|
40
|
+
...(stylistic.enabled ? {} : {}),
|
|
41
41
|
...rules,
|
|
42
42
|
},
|
|
43
43
|
},
|
|
44
44
|
// TODO: move to another file ?
|
|
45
45
|
{
|
|
46
46
|
files: ['**/*.config.cjs', '**/*.config.js'],
|
|
47
|
-
name:
|
|
47
|
+
name: `${namespace}/unicorn/overrides`,
|
|
48
48
|
rules: {
|
|
49
49
|
'unicorn/prefer-module': 'off',
|
|
50
50
|
},
|
|
@@ -3,24 +3,25 @@ import { interopDefault } from '@w5s/dev';
|
|
|
3
3
|
import type { RuleOptions } from '../typegen/unused-imports.js';
|
|
4
4
|
|
|
5
5
|
import { sourceGlob } from '../glob.js';
|
|
6
|
+
import { defaultPluginOptions } from '../internal/defaultOptions.js';
|
|
6
7
|
import { type Config, type PluginOptionsBase } from '../type.js';
|
|
7
8
|
|
|
8
9
|
export async function unusedImports(options: unusedImports.Options = {}) {
|
|
9
10
|
const [unusedImportPlugin] = await Promise.all([
|
|
10
11
|
interopDefault(import('eslint-plugin-unused-imports')),
|
|
11
12
|
] as const);
|
|
12
|
-
const { files = [sourceGlob], recommended
|
|
13
|
+
const { files = [sourceGlob], namespace, recommended, rules = {} } = defaultPluginOptions(options);
|
|
13
14
|
|
|
14
15
|
return [
|
|
15
16
|
{
|
|
16
|
-
name:
|
|
17
|
+
name: `${namespace}/unused-imports/setup`,
|
|
17
18
|
plugins: {
|
|
18
19
|
'unused-imports': unusedImportPlugin,
|
|
19
20
|
},
|
|
20
21
|
},
|
|
21
22
|
{
|
|
22
23
|
files,
|
|
23
|
-
name:
|
|
24
|
+
name: `${namespace}/unused-imports/rules`,
|
|
24
25
|
rules: {
|
|
25
26
|
...(recommended
|
|
26
27
|
? {
|
package/src/config/yml.ts
CHANGED
|
@@ -3,19 +3,20 @@ import { interopDefault } from '@w5s/dev';
|
|
|
3
3
|
import type { RuleOptions } from '../typegen/yml.js';
|
|
4
4
|
|
|
5
5
|
import { ymlSourceGlob } from '../glob.js';
|
|
6
|
+
import { defaultPluginOptions } from '../internal/defaultOptions.js';
|
|
6
7
|
import { withDefaultFiles } from '../internal/withDefaultFiles.js';
|
|
7
|
-
import { type Config, type PluginOptionsBase
|
|
8
|
+
import { type Config, type PluginOptionsBase } from '../type.js';
|
|
8
9
|
|
|
9
10
|
const defaultFiles = [ymlSourceGlob];
|
|
10
11
|
|
|
11
12
|
export async function yml(options: yml.Options = {}) {
|
|
12
13
|
const [ymlPlugin] = await Promise.all([interopDefault(import('eslint-plugin-yml'))] as const);
|
|
13
|
-
const { files, recommended
|
|
14
|
-
const { enabled: stylisticEnabled, indent, quotes } =
|
|
14
|
+
const { files, namespace, recommended, rules = {}, stylistic } = defaultPluginOptions(options);
|
|
15
|
+
const { enabled: stylisticEnabled, indent, quotes } = stylistic;
|
|
15
16
|
|
|
16
17
|
return [
|
|
17
18
|
{
|
|
18
|
-
name:
|
|
19
|
+
name: `${namespace}/yml/setup`,
|
|
19
20
|
plugins: {
|
|
20
21
|
yml: ymlPlugin,
|
|
21
22
|
},
|
|
@@ -23,7 +24,7 @@ export async function yml(options: yml.Options = {}) {
|
|
|
23
24
|
{
|
|
24
25
|
files: withDefaultFiles(files, defaultFiles),
|
|
25
26
|
language: 'yml/yaml',
|
|
26
|
-
name:
|
|
27
|
+
name: `${namespace}/yml/rules`,
|
|
27
28
|
rules: {
|
|
28
29
|
...(recommended
|
|
29
30
|
? ymlPlugin.configs.recommended.reduce(
|
package/src/glob.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { Project } from '@w5s/dev';
|
|
2
2
|
|
|
3
|
-
export const sourceGlob = Project.
|
|
3
|
+
export const sourceGlob = Project.glob({ fileExtensions: [Project.sourceExtensions()], nested: true });
|
|
4
4
|
|
|
5
|
-
export const esSourceGlob = Project.
|
|
5
|
+
export const esSourceGlob = Project.glob({ fileExtensions: [Project.queryExtensions(['javascript', 'javascriptreact'])], nested: true });
|
|
6
6
|
|
|
7
|
-
export const jsxSourceGlob = Project.
|
|
7
|
+
export const jsxSourceGlob = Project.glob({ fileExtensions: [Project.queryExtensions(['javascriptreact', 'typescriptreact'])], nested: true });
|
|
8
8
|
|
|
9
|
-
export const jsonSourceGlob = Project.
|
|
9
|
+
export const jsonSourceGlob = Project.glob({ fileExtensions: [['.json', '.json5', '.jsonc']], nested: true });
|
|
10
10
|
|
|
11
|
-
export const tsSourceGlob = Project.
|
|
11
|
+
export const tsSourceGlob = Project.glob({ fileExtensions: [Project.queryExtensions(['typescript', 'typescriptreact'])], nested: true });
|
|
12
12
|
|
|
13
|
-
export const ymlSourceGlob = Project.
|
|
13
|
+
export const ymlSourceGlob = Project.glob({ fileExtensions: [Project.queryExtensions(['yaml'])], nested: true });
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type PluginOptionsBase, StylisticConfig } from '../type.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Return a new plugin option object with default values
|
|
5
|
+
*
|
|
6
|
+
* @param options
|
|
7
|
+
*/
|
|
8
|
+
export function defaultPluginOptions<T extends PluginOptionsBase<any>>(options: T): Omit<T, 'namespace' | 'recommended' | 'stylistic'> & {
|
|
9
|
+
namespace: Exclude<PluginOptionsBase<any>['namespace'], undefined>;
|
|
10
|
+
recommended: Exclude<PluginOptionsBase<any>['recommended'], undefined>;
|
|
11
|
+
stylistic: StylisticConfig;
|
|
12
|
+
} {
|
|
13
|
+
return {
|
|
14
|
+
...options,
|
|
15
|
+
namespace: options.namespace ?? 'w5s',
|
|
16
|
+
recommended: options.recommended ?? true,
|
|
17
|
+
stylistic: StylisticConfig.from(options.stylistic ?? true),
|
|
18
|
+
};
|
|
19
|
+
}
|
|
@@ -8,6 +8,14 @@ export interface PluginOptionsBase<Rules> {
|
|
|
8
8
|
*/
|
|
9
9
|
files?: ((currentFiles: Array<string>) => Array<string>) | Linter.Config['files'];
|
|
10
10
|
|
|
11
|
+
/**
|
|
12
|
+
* Namespace of configurations.
|
|
13
|
+
* Useful for tier configuration and rebranding
|
|
14
|
+
*
|
|
15
|
+
* @default 'w5s'
|
|
16
|
+
*/
|
|
17
|
+
namespace?: string | undefined;
|
|
18
|
+
|
|
11
19
|
/**
|
|
12
20
|
* Include recommended settings
|
|
13
21
|
*/
|
package/src/typegen/jsdoc.d.ts
CHANGED
|
@@ -363,6 +363,11 @@ export interface RuleOptions {
|
|
|
363
363
|
* @see https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/text-escaping.md#repos-sticky-header
|
|
364
364
|
*/
|
|
365
365
|
'jsdoc/text-escaping'?: Linter.RuleEntry<JsdocTextEscaping>
|
|
366
|
+
/**
|
|
367
|
+
* Disallows (or requires descriptions for) `@ts-<directive>` comments, mirroring `@typescript-eslint/ban-ts-comment`.
|
|
368
|
+
* @see https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/ts-ban-ts-comment.md#repos-sticky-header
|
|
369
|
+
*/
|
|
370
|
+
'jsdoc/ts-ban-ts-comment'?: Linter.RuleEntry<JsdocTsBanTsComment>
|
|
366
371
|
/**
|
|
367
372
|
* Prefers either function properties or method signatures
|
|
368
373
|
* @see https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/ts-method-signature-style.md#repos-sticky-header
|
|
@@ -1137,6 +1142,31 @@ type JsdocTextEscaping = []|[{
|
|
|
1137
1142
|
|
|
1138
1143
|
escapeMarkdown?: boolean
|
|
1139
1144
|
}]
|
|
1145
|
+
// ----- jsdoc/ts-ban-ts-comment -----
|
|
1146
|
+
type JsdocTsBanTsComment = []|[{
|
|
1147
|
+
|
|
1148
|
+
minimumDescriptionLength?: number
|
|
1149
|
+
|
|
1150
|
+
"ts-check"?: (boolean | "allow-with-description" | {
|
|
1151
|
+
|
|
1152
|
+
descriptionFormat?: string
|
|
1153
|
+
})
|
|
1154
|
+
|
|
1155
|
+
"ts-expect-error"?: (boolean | "allow-with-description" | {
|
|
1156
|
+
|
|
1157
|
+
descriptionFormat?: string
|
|
1158
|
+
})
|
|
1159
|
+
|
|
1160
|
+
"ts-ignore"?: (boolean | "allow-with-description" | {
|
|
1161
|
+
|
|
1162
|
+
descriptionFormat?: string
|
|
1163
|
+
})
|
|
1164
|
+
|
|
1165
|
+
"ts-nocheck"?: (boolean | "allow-with-description" | {
|
|
1166
|
+
|
|
1167
|
+
descriptionFormat?: string
|
|
1168
|
+
})
|
|
1169
|
+
}]
|
|
1140
1170
|
// ----- jsdoc/ts-method-signature-style -----
|
|
1141
1171
|
type JsdocTsMethodSignatureStyle = []|[("method" | "property")]|[("method" | "property"), {
|
|
1142
1172
|
|