@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.
@@ -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, StylisticConfig } from '../type.js';
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 = true, rules = {}, stylistic = true } = options;
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: 'w5s/unicorn/setup',
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: 'w5s/unicorn/rules',
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
- ...(stylisticEnabled ? {} : {}),
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: 'w5s/unicorn/overrides',
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 = true, rules = {} } = options;
13
+ const { files = [sourceGlob], namespace, recommended, rules = {} } = defaultPluginOptions(options);
13
14
 
14
15
  return [
15
16
  {
16
- name: 'w5s/unused-imports/setup',
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: 'w5s/unused-imports/rules',
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, StylisticConfig } from '../type.js';
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 = true, rules = {}, stylistic = true } = options;
14
- const { enabled: stylisticEnabled, indent, quotes } = StylisticConfig.from(stylistic);
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: 'w5s/yml/setup',
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: 'w5s/yml/rules',
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.extensionsToGlob(Project.sourceExtensions(), { nested: true });
3
+ export const sourceGlob = Project.glob({ fileExtensions: [Project.sourceExtensions()], nested: true });
4
4
 
5
- export const esSourceGlob = Project.extensionsToGlob(Project.queryExtensions(['javascript', 'javascriptreact']), { nested: true });
5
+ export const esSourceGlob = Project.glob({ fileExtensions: [Project.queryExtensions(['javascript', 'javascriptreact'])], nested: true });
6
6
 
7
- export const jsxSourceGlob = Project.extensionsToGlob(Project.queryExtensions(['javascriptreact', 'typescriptreact']), { nested: true });
7
+ export const jsxSourceGlob = Project.glob({ fileExtensions: [Project.queryExtensions(['javascriptreact', 'typescriptreact'])], nested: true });
8
8
 
9
- export const jsonSourceGlob = Project.extensionsToGlob(['.json', '.json5', '.jsonc'], { nested: true });
9
+ export const jsonSourceGlob = Project.glob({ fileExtensions: [['.json', '.json5', '.jsonc']], nested: true });
10
10
 
11
- export const tsSourceGlob = Project.extensionsToGlob(Project.queryExtensions(['typescript', 'typescriptreact']), { nested: true });
11
+ export const tsSourceGlob = Project.glob({ fileExtensions: [Project.queryExtensions(['typescript', 'typescriptreact'])], nested: true });
12
12
 
13
- export const ymlSourceGlob = Project.extensionsToGlob(Project.queryExtensions(['yaml']), { nested: true });
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
  */
@@ -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