@the-stranger/eslint-plugin 2.0.2 → 2.1.1

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 (79) hide show
  1. package/README.md +41 -29
  2. package/package.json +26 -72
  3. package/src/index.d.ts +1 -2
  4. package/src/index.js +1 -1
  5. package/src/lib/configs.d.ts +19 -0
  6. package/src/lib/configs.js +75 -0
  7. package/src/lib/disable-type-checked.d.ts +4 -0
  8. package/src/lib/disable-type-checked.js +8 -0
  9. package/src/lib/meta.d.ts +0 -1
  10. package/src/lib/namer.d.ts +3 -1
  11. package/src/lib/namer.js +2 -0
  12. package/src/lib/utils/get-module-root.d.ts +11 -0
  13. package/src/lib/utils/get-module-root.js +31 -0
  14. package/src/lib/utils/optional-import-resolver.d.ts +76 -0
  15. package/src/lib/utils/optional-import-resolver.js +168 -0
  16. package/src/lib/utils/optional-import.d.ts +47 -0
  17. package/src/lib/utils/optional-import.js +142 -0
  18. package/src/lib/utils/options.d.ts +3 -0
  19. package/src/lib/utils/options.js +24 -0
  20. package/src/utils.d.ts +2 -4
  21. package/src/utils.js +2 -3
  22. package/src/index.d.ts.map +0 -1
  23. package/src/lib/configs/index.d.ts +0 -17
  24. package/src/lib/configs/index.d.ts.map +0 -1
  25. package/src/lib/configs/index.js +0 -26
  26. package/src/lib/configs/jest.d.ts +0 -4
  27. package/src/lib/configs/jest.d.ts.map +0 -1
  28. package/src/lib/configs/jest.js +0 -27
  29. package/src/lib/configs/jsdoc.d.ts +0 -5
  30. package/src/lib/configs/jsdoc.d.ts.map +0 -1
  31. package/src/lib/configs/jsdoc.js +0 -44
  32. package/src/lib/configs/jsonc.d.ts +0 -4
  33. package/src/lib/configs/jsonc.d.ts.map +0 -1
  34. package/src/lib/configs/jsonc.js +0 -128
  35. package/src/lib/configs/n.d.ts +0 -4
  36. package/src/lib/configs/n.d.ts.map +0 -1
  37. package/src/lib/configs/n.js +0 -24
  38. package/src/lib/configs/nx.d.ts +0 -6
  39. package/src/lib/configs/nx.d.ts.map +0 -1
  40. package/src/lib/configs/nx.js +0 -45
  41. package/src/lib/configs/perfectionist.d.ts +0 -4
  42. package/src/lib/configs/perfectionist.d.ts.map +0 -1
  43. package/src/lib/configs/perfectionist.js +0 -129
  44. package/src/lib/configs/promise.d.ts +0 -4
  45. package/src/lib/configs/promise.d.ts.map +0 -1
  46. package/src/lib/configs/promise.js +0 -16
  47. package/src/lib/configs/regexp.d.ts +0 -4
  48. package/src/lib/configs/regexp.d.ts.map +0 -1
  49. package/src/lib/configs/regexp.js +0 -5
  50. package/src/lib/configs/toml.d.ts +0 -4
  51. package/src/lib/configs/toml.d.ts.map +0 -1
  52. package/src/lib/configs/toml.js +0 -35
  53. package/src/lib/configs/typescript-eslint.d.ts +0 -4
  54. package/src/lib/configs/typescript-eslint.d.ts.map +0 -1
  55. package/src/lib/configs/typescript-eslint.js +0 -26
  56. package/src/lib/configs/unicorn.d.ts +0 -4
  57. package/src/lib/configs/unicorn.d.ts.map +0 -1
  58. package/src/lib/configs/unicorn.js +0 -66
  59. package/src/lib/configs/vitest.d.ts +0 -4
  60. package/src/lib/configs/vitest.d.ts.map +0 -1
  61. package/src/lib/configs/vitest.js +0 -15
  62. package/src/lib/configs/yml.d.ts +0 -4
  63. package/src/lib/configs/yml.d.ts.map +0 -1
  64. package/src/lib/configs/yml.js +0 -127
  65. package/src/lib/extend-config.d.ts +0 -3
  66. package/src/lib/extend-config.d.ts.map +0 -1
  67. package/src/lib/extend-config.js +0 -22
  68. package/src/lib/meta.d.ts.map +0 -1
  69. package/src/lib/namer.d.ts.map +0 -1
  70. package/src/lib/patterns.d.ts +0 -82
  71. package/src/lib/patterns.d.ts.map +0 -1
  72. package/src/lib/patterns.js +0 -147
  73. package/src/lib/rule-levels.d.ts +0 -43
  74. package/src/lib/rule-levels.d.ts.map +0 -1
  75. package/src/lib/rule-levels.js +0 -71
  76. package/src/lib/severity.d.ts +0 -13
  77. package/src/lib/severity.d.ts.map +0 -1
  78. package/src/lib/severity.js +0 -34
  79. package/src/utils.d.ts.map +0 -1
@@ -1,127 +0,0 @@
1
- import yml from 'eslint-plugin-yml';
2
- import { namer } from '../namer.js';
3
- const topLevelKeyOrder = [
4
- 'name',
5
- 'on',
6
- 'permissions',
7
- 'env',
8
- 'defaults',
9
- 'concurrency',
10
- 'jobs',
11
- ];
12
- const jobKeyOrder = [
13
- 'strategy',
14
- 'name',
15
- 'if',
16
- 'needs',
17
- 'runs-on',
18
- 'permissions',
19
- 'environment',
20
- 'env',
21
- 'concurrency',
22
- 'timeout-minutes',
23
- 'outputs',
24
- 'defaults',
25
- 'steps',
26
- ];
27
- const stepKeyOrder = ['id', 'name', 'if', 'run', 'uses', 'with', 'env'];
28
- const topLevelAscKeys = ['on', 'permissions', 'defaults'].join('|');
29
- export default [
30
- yml.configs['flat/standard'],
31
- {
32
- files: ['cspell.config.yaml', '**/cspell.config.yaml'],
33
- name: namer('cspell-config'),
34
- rules: {
35
- 'yml/sort-keys': [
36
- 'error',
37
- {
38
- order: [
39
- 'version',
40
- 'language',
41
- 'import',
42
- 'ignorePaths',
43
- 'dictionaries',
44
- 'ignoreWords',
45
- 'words',
46
- 'languageSettings',
47
- { order: { type: 'asc' } },
48
- ],
49
- pathPattern: '^$',
50
- },
51
- {
52
- order: ['languageId', 'dictionaries', { order: { type: 'asc' } }],
53
- pathPattern: 'languageSettings$',
54
- },
55
- ],
56
- 'yml/sort-sequence-values': [
57
- 'error',
58
- {
59
- order: { type: 'asc' },
60
- pathPattern: 'dictionaries|import|ignorePaths|ignoreWords|words$',
61
- },
62
- ],
63
- },
64
- },
65
- {
66
- files: ['.github/workflows/*.yml'],
67
- name: namer('github-actions'),
68
- rules: {
69
- 'yml/no-empty-mapping-values': 'off',
70
- 'yml/sort-keys': [
71
- 'error',
72
- {
73
- order: [topLevelKeyOrder, { order: { type: 'asc' } }],
74
- pathPattern: '^$',
75
- },
76
- {
77
- order: { type: 'asc' },
78
- pathPattern: `^${topLevelAscKeys}`,
79
- },
80
- {
81
- order: [stepKeyOrder, { order: { type: 'asc' } }],
82
- pathPattern: String.raw `^jobs\..+steps`,
83
- },
84
- {
85
- order: [jobKeyOrder, { order: { type: 'asc' } }],
86
- pathPattern: '^jobs',
87
- },
88
- ],
89
- 'yml/sort-sequence-values': [
90
- 'error',
91
- {
92
- order: { type: 'asc' },
93
- pathPattern: `^${topLevelAscKeys}`,
94
- },
95
- ],
96
- },
97
- },
98
- {
99
- files: ['.markdownlint-cli2.yaml'],
100
- name: namer('markdownlint-config'),
101
- rules: {
102
- 'yml/sort-keys': [
103
- 'error',
104
- { order: ['ignores', { order: { type: 'asc' } }], pathPattern: '^$' },
105
- { order: { type: 'asc' }, pathPattern: '^configs' },
106
- ],
107
- 'yml/sort-sequence-values': [
108
- 'error',
109
- { order: { type: 'asc' }, pathPattern: '^ignores' },
110
- ],
111
- },
112
- },
113
- {
114
- files: ['.yarnrc.yml'],
115
- name: namer('yarnrc'),
116
- rules: {
117
- 'yml/sort-keys': ['error', { order: { type: 'asc' }, pathPattern: '^$' }],
118
- 'yml/sort-sequence-values': [
119
- 'error',
120
- {
121
- order: ['.env?', { order: { type: 'asc' } }],
122
- pathPattern: '^injectEnvironmentFiles',
123
- },
124
- ],
125
- },
126
- },
127
- ];
@@ -1,3 +0,0 @@
1
- import type { Linter } from 'eslint';
2
- export declare function extendConfig(...configs: (Linter.Config | Linter.Config[])[]): Linter.Config[];
3
- //# sourceMappingURL=extend-config.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"extend-config.d.ts","sourceRoot":"","sources":["../../../../../packages/eslint-plugin/src/lib/extend-config.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAEpC,wBAAgB,YAAY,CAAC,GAAG,OAAO,EAAE,CAAC,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,GAqBpC,MAAM,CAAC,MAAM,EAAE,CACtD"}
@@ -1,22 +0,0 @@
1
- import { defineConfig } from 'eslint/config';
2
- export function extendConfig(...configs) {
3
- const base = [
4
- {
5
- ignores: [
6
- '.cache',
7
- '.github',
8
- '.nx',
9
- '.pnp.*',
10
- '.yarn',
11
- 'coverage',
12
- 'dist',
13
- 'node_modules',
14
- 'pnpm-lock.yaml',
15
- 'pnpm-workspace.yaml',
16
- 'tmp',
17
- ],
18
- },
19
- { linterOptions: { reportUnusedDisableDirectives: 'error' } },
20
- ];
21
- return defineConfig(configs, base);
22
- }
@@ -1 +0,0 @@
1
- {"version":3,"file":"meta.d.ts","sourceRoot":"","sources":["../../../../../packages/eslint-plugin/src/lib/meta.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAKpC,eAAO,MAAM,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,CAAqB,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"namer.d.ts","sourceRoot":"","sources":["../../../../../packages/eslint-plugin/src/lib/namer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAIpC;;;;GAIG;AACH,wBAAgB,KAAK,CAAC,KAAK,CAAC,EAAE,MAAM,UAMnC;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,CAa/E;AAED;;GAEG;AACH,MAAM,MAAM,KAAK,CAAC,CAAC,SAAS,MAAM,IAAI,QAAQ,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC,CAAC,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAA;AAErF,KAAK,MAAM,GAAG,MAAM,CAAC,MAAM,CAAA;AAE3B,KAAK,CAAC,GAAG;IAAE,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,CAAA"}
@@ -1,82 +0,0 @@
1
- /**
2
- * Normalize an array of file extensions and combine them into a comma-separated string.
3
- * @param extensions file extensions to concatenate
4
- * @returns the comma-separated string
5
- */
6
- export declare function combineExtensions(...extensions: (string | string[])[]): string;
7
- /**
8
- * Expand a file extension into an array of file extensions that match typical Node.js module types.
9
- * @example
10
- * expandExtension('js') // -> ['js', 'cjs', 'mjs', 'jsx']
11
- * @param ext the base file extension
12
- * @returns an array of file extensions
13
- */
14
- export declare function expandExtension(ext: string): string[];
15
- /**
16
- * Convenient function to generate some common glob patterns.
17
- * @param patterns an array of file patterns or file extensions
18
- * @returns a glob pattern that matches the indicated file(s)
19
- */
20
- export declare function getFilePatterns(...patterns: (string | FilePatterns)[]): string[];
21
- /**
22
- * Get a glob pattern that recursively matches files with the specified extensions.
23
- * @param extensions file extensions to match
24
- * @returns a glob pattern that matches any of the file extensions
25
- */
26
- export declare function sourceFilePattern(...extensions: (string | string[])[]): string;
27
- /**
28
- * Create a glob pattern that recursively matches test files with the specified extensions.
29
- * @param extensions file extensions to match
30
- * @returns a glob pattern that matches test files with any of the file extensions
31
- */
32
- export declare function testFilePattern(...extensions: (string | string[])[]): string;
33
- /**
34
- * Common file patterns used in ESLint configurations.
35
- */
36
- export declare enum FilePatterns {
37
- /**
38
- * Astro-specific files ('.astro').
39
- */
40
- astro = "astro-files",
41
- /**
42
- * Scripts inside Astro files, which are parsed as virtual files under the virtual "directory" of the file.
43
- */
44
- astroScript = "astro-script-files",
45
- /**
46
- * CommonJS files ('.cjs' and '.cts').
47
- */
48
- cjs = "cjs-files",
49
- /**
50
- * ESM files ('.mjs' and '.mts').
51
- */
52
- esm = "esm-files",
53
- /**
54
- * JavaScript files.
55
- */
56
- js = "js-files",
57
- /**
58
- * JavaScript test files.
59
- */
60
- jsTest = "js-test-files",
61
- /**
62
- * React files ('.jsx' and '.tsx').
63
- */
64
- react = "react-files",
65
- /**
66
- * All JavaScript and TypeScript source files.
67
- */
68
- source = "source-files",
69
- /**
70
- * All JavaScript and TypeScript test files.
71
- */
72
- test = "test-files",
73
- /**
74
- * TypeScript files.
75
- */
76
- ts = "ts-files",
77
- /**
78
- * TypeScript test files.
79
- */
80
- tsTest = "ts-test-files"
81
- }
82
- //# sourceMappingURL=patterns.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"patterns.d.ts","sourceRoot":"","sources":["../../../../../packages/eslint-plugin/src/lib/patterns.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,UAAU,EAAE,CAAC,MAAM,GAAG,MAAM,EAAE,CAAC,EAAE,UAQrE;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,YAG1C;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,GAAG,QAAQ,EAAE,CAAC,MAAM,GAAG,YAAY,CAAC,EAAE,YAyCrE;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,UAAU,EAAE,CAAC,MAAM,GAAG,MAAM,EAAE,CAAC,EAAE,UAErE;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,GAAG,UAAU,EAAE,CAAC,MAAM,GAAG,MAAM,EAAE,CAAC,EAAE,UAEnE;AAED;;GAEG;AACH,oBAAY,YAAY;IACtB;;OAEG;IACH,KAAK,gBAAgB;IACrB;;OAEG;IACH,WAAW,uBAAuB;IAClC;;OAEG;IACH,GAAG,cAAc;IACjB;;OAEG;IACH,GAAG,cAAc;IACjB;;OAEG;IACH,EAAE,aAAa;IACf;;OAEG;IACH,MAAM,kBAAkB;IACxB;;OAEG;IACH,KAAK,gBAAgB;IACrB;;OAEG;IACH,MAAM,iBAAiB;IACvB;;OAEG;IACH,IAAI,eAAe;IACnB;;OAEG;IACH,EAAE,aAAa;IACf;;OAEG;IACH,MAAM,kBAAkB;CACzB"}
@@ -1,147 +0,0 @@
1
- /**
2
- * Normalize an array of file extensions and combine them into a comma-separated string.
3
- * @param extensions file extensions to concatenate
4
- * @returns the comma-separated string
5
- */
6
- export function combineExtensions(...extensions) {
7
- const exts = [...new Set(extensions.flat())].map(normalizeExtPattern);
8
- if (exts.length === 0) {
9
- throw new Error('No file extensions provided');
10
- }
11
- else if (exts.length === 1) {
12
- return exts[0];
13
- }
14
- return `{${exts.join(',')}}`;
15
- }
16
- /**
17
- * Expand a file extension into an array of file extensions that match typical Node.js module types.
18
- * @example
19
- * expandExtension('js') // -> ['js', 'cjs', 'mjs', 'jsx']
20
- * @param ext the base file extension
21
- * @returns an array of file extensions
22
- */
23
- export function expandExtension(ext) {
24
- ext = normalizeExtPattern(ext);
25
- return [ext, `c${ext}`, `m${ext}`, `${ext}x`];
26
- }
27
- /**
28
- * Convenient function to generate some common glob patterns.
29
- * @param patterns an array of file patterns or file extensions
30
- * @returns a glob pattern that matches the indicated file(s)
31
- */
32
- export function getFilePatterns(...patterns) {
33
- return patterns.map(pattern => {
34
- switch (pattern) {
35
- case FilePatterns.astro: {
36
- return sourceFilePattern('astro');
37
- }
38
- case FilePatterns.astroScript: {
39
- return `**/*.astro/${sourceFilePattern('js', 'ts')}`;
40
- }
41
- case FilePatterns.cjs: {
42
- return sourceFilePattern('cjs', 'cts');
43
- }
44
- case FilePatterns.esm: {
45
- return sourceFilePattern('mjs', 'mts');
46
- }
47
- case FilePatterns.js: {
48
- return sourceFilePattern(expandExtension('js'));
49
- }
50
- case FilePatterns.jsTest: {
51
- return testFilePattern('js', 'jsx');
52
- }
53
- case FilePatterns.react: {
54
- return sourceFilePattern('jsx', 'tsx');
55
- }
56
- case FilePatterns.source: {
57
- return sourceFilePattern(expandExtension('js'), expandExtension('ts'), 'astro');
58
- }
59
- case FilePatterns.test: {
60
- return testFilePattern('js', 'jsx', 'ts', 'tsx');
61
- }
62
- case FilePatterns.ts: {
63
- return sourceFilePattern(expandExtension('ts'));
64
- }
65
- case FilePatterns.tsTest: {
66
- return testFilePattern('ts', 'tsx');
67
- }
68
- default: {
69
- return sourceFilePattern(pattern);
70
- }
71
- }
72
- });
73
- }
74
- /**
75
- * Get a glob pattern that recursively matches files with the specified extensions.
76
- * @param extensions file extensions to match
77
- * @returns a glob pattern that matches any of the file extensions
78
- */
79
- export function sourceFilePattern(...extensions) {
80
- return `**/*.${combineExtensions(...extensions)}`;
81
- }
82
- /**
83
- * Create a glob pattern that recursively matches test files with the specified extensions.
84
- * @param extensions file extensions to match
85
- * @returns a glob pattern that matches test files with any of the file extensions
86
- */
87
- export function testFilePattern(...extensions) {
88
- return `**/*.{spec,test}.${combineExtensions(...extensions)}`;
89
- }
90
- /**
91
- * Common file patterns used in ESLint configurations.
92
- */
93
- export var FilePatterns;
94
- (function (FilePatterns) {
95
- /**
96
- * Astro-specific files ('.astro').
97
- */
98
- FilePatterns["astro"] = "astro-files";
99
- /**
100
- * Scripts inside Astro files, which are parsed as virtual files under the virtual "directory" of the file.
101
- */
102
- FilePatterns["astroScript"] = "astro-script-files";
103
- /**
104
- * CommonJS files ('.cjs' and '.cts').
105
- */
106
- FilePatterns["cjs"] = "cjs-files";
107
- /**
108
- * ESM files ('.mjs' and '.mts').
109
- */
110
- FilePatterns["esm"] = "esm-files";
111
- /**
112
- * JavaScript files.
113
- */
114
- FilePatterns["js"] = "js-files";
115
- /**
116
- * JavaScript test files.
117
- */
118
- FilePatterns["jsTest"] = "js-test-files";
119
- /**
120
- * React files ('.jsx' and '.tsx').
121
- */
122
- FilePatterns["react"] = "react-files";
123
- /**
124
- * All JavaScript and TypeScript source files.
125
- */
126
- FilePatterns["source"] = "source-files";
127
- /**
128
- * All JavaScript and TypeScript test files.
129
- */
130
- FilePatterns["test"] = "test-files";
131
- /**
132
- * TypeScript files.
133
- */
134
- FilePatterns["ts"] = "ts-files";
135
- /**
136
- * TypeScript test files.
137
- */
138
- FilePatterns["tsTest"] = "ts-test-files";
139
- })(FilePatterns || (FilePatterns = {}));
140
- /**
141
- * Normalize a file extension by removing leading dot or glob wildcards.
142
- * @param value the file extension to normalize
143
- * @returns the normalized file extension
144
- */
145
- function normalizeExtPattern(value) {
146
- return value.replace(/^\./, '').replace(/^[*?]+(\/[*?]+\.?)?/, '');
147
- }
@@ -1,43 +0,0 @@
1
- import type { Linter } from 'eslint';
2
- export declare class RuleLevels {
3
- /**
4
- * The numeric rule level - 0, 1, or 2.
5
- */
6
- readonly severity: Linter.Severity;
7
- /**
8
- * The text rule level - 'off', 'warn', or 'error'.
9
- */
10
- readonly severityString: Linter.StringSeverity;
11
- constructor(severity: Linter.RuleSeverity);
12
- /**
13
- * Get the severity of this instance with the same type as another severity level.
14
- * @param level the original severity
15
- * @returns the severity of this instance
16
- * @example
17
- * ```typescript
18
- * const levels = new RuleLevels('off')
19
- * const levelString = levels.matchType('error') // 'off'
20
- * const levelNumber = levels.matchType(1) // 0
21
- * ```
22
- */
23
- matchType<T extends Linter.RuleSeverity = Linter.RuleSeverity>(level: T): T;
24
- /**
25
- * Set the rule level/severity of a configuration rule, preserving the type of the original value, as well as any options specified in the rule.
26
- * @param entry a rule entry
27
- * @returns the rule entry with the updated severity
28
- */
29
- setLevel(entry: Linter.RuleEntry): Linter.RuleEntry;
30
- /**
31
- * Convert a numeric rule level (0, 1, or 2) to its string equivalent.
32
- * @param severity the numeric rule level
33
- * @returns the string equivalent of the rule level
34
- */
35
- static switchType(severity: Linter.Severity): Linter.StringSeverity;
36
- /**
37
- * Convert a severity string ('off', 'warn', or 'error') to its numeric equivalent.
38
- * @param severity the severity string
39
- * @returns the numeric equivalent of the severity
40
- */
41
- static switchType(severity: Linter.StringSeverity): Linter.Severity;
42
- }
43
- //# sourceMappingURL=rule-levels.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"rule-levels.d.ts","sourceRoot":"","sources":["../../../../../packages/eslint-plugin/src/lib/rule-levels.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAEpC,qBAAa,UAAU;IACrB;;OAEG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,QAAQ,CAAA;IAClC;;OAEG;IACH,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC,cAAc,CAAA;gBAElC,QAAQ,EAAE,MAAM,CAAC,YAAY;IAUzC;;;;;;;;;;OAUG;IACH,SAAS,CAAC,CAAC,SAAS,MAAM,CAAC,YAAY,GAAG,MAAM,CAAC,YAAY,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC;IAO3E;;;;OAIG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,SAAS,GAAG,MAAM,CAAC,SAAS;IAQnD;;;;OAIG;IACH,MAAM,CAAC,UAAU,CAAC,QAAQ,EAAE,MAAM,CAAC,QAAQ,GAAG,MAAM,CAAC,cAAc;IACnE;;;;OAIG;IACH,MAAM,CAAC,UAAU,CAAC,QAAQ,EAAE,MAAM,CAAC,cAAc,GAAG,MAAM,CAAC,QAAQ;CAuBpE"}
@@ -1,71 +0,0 @@
1
- export class RuleLevels {
2
- /**
3
- * The numeric rule level - 0, 1, or 2.
4
- */
5
- severity;
6
- /**
7
- * The text rule level - 'off', 'warn', or 'error'.
8
- */
9
- severityString;
10
- constructor(severity) {
11
- if (typeof severity === 'number') {
12
- this.severity = severity;
13
- this.severityString = RuleLevels.switchType(severity);
14
- }
15
- else {
16
- this.severityString = severity;
17
- this.severity = RuleLevels.switchType(severity);
18
- }
19
- }
20
- /**
21
- * Get the severity of this instance with the same type as another severity level.
22
- * @param level the original severity
23
- * @returns the severity of this instance
24
- * @example
25
- * ```typescript
26
- * const levels = new RuleLevels('off')
27
- * const levelString = levels.matchType('error') // 'off'
28
- * const levelNumber = levels.matchType(1) // 0
29
- * ```
30
- */
31
- matchType(level) {
32
- if (typeof level === 'string') {
33
- return this.severityString;
34
- }
35
- return this.severity;
36
- }
37
- /**
38
- * Set the rule level/severity of a configuration rule, preserving the type of the original value, as well as any options specified in the rule.
39
- * @param entry a rule entry
40
- * @returns the rule entry with the updated severity
41
- */
42
- setLevel(entry) {
43
- if (Array.isArray(entry)) {
44
- const [lvl, ...options] = entry;
45
- return [this.matchType(lvl), ...options];
46
- }
47
- return this.matchType(entry);
48
- }
49
- static switchType(severity) {
50
- switch (severity) {
51
- case 0: {
52
- return 'off';
53
- }
54
- case 1: {
55
- return 'warn';
56
- }
57
- case 2: {
58
- return 'error';
59
- }
60
- case 'error': {
61
- return 2;
62
- }
63
- case 'off': {
64
- return 0;
65
- }
66
- case 'warn': {
67
- return 1;
68
- }
69
- }
70
- }
71
- }
@@ -1,13 +0,0 @@
1
- import type { Linter } from 'eslint';
2
- /**
3
- * Set the severity of rules in an ESLint configuration. If {@link rules} is specified, only rules with a key that matches one of these values is changed.
4
- * @param severity the severity to set
5
- * @param config a configuration object
6
- * @param rules an array of rule names or rules within the configuration object
7
- * @returns the configuration object with the specified severity
8
- */
9
- export declare function setRuleLevel(severity: Severity, config: Config, rules?: string[]): Config;
10
- type Config = Linter.Config;
11
- type Severity = Linter.RuleSeverity;
12
- export {};
13
- //# sourceMappingURL=severity.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"severity.d.ts","sourceRoot":"","sources":["../../../../../packages/eslint-plugin/src/lib/severity.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAIpC;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,EAAE,UAgBhF;AAmBD,KAAK,MAAM,GAAG,MAAM,CAAC,MAAM,CAAA;AAI3B,KAAK,QAAQ,GAAG,MAAM,CAAC,YAAY,CAAA"}
@@ -1,34 +0,0 @@
1
- import { RuleLevels } from './rule-levels.js';
2
- /**
3
- * Set the severity of rules in an ESLint configuration. If {@link rules} is specified, only rules with a key that matches one of these values is changed.
4
- * @param severity the severity to set
5
- * @param config a configuration object
6
- * @param rules an array of rule names or rules within the configuration object
7
- * @returns the configuration object with the specified severity
8
- */
9
- export function setRuleLevel(severity, config, rules) {
10
- const levels = new RuleLevels(severity);
11
- const includeKey = (key) => rules?.find(e => matchKeys(e, key)) ?? true;
12
- if (config.rules) {
13
- config.rules = Object.entries(config.rules).reduce((acc, [key, rule]) => {
14
- if (rule !== undefined) {
15
- acc[key] = includeKey(key) ? levels.setLevel(rule) : rule;
16
- }
17
- return acc;
18
- }, Object.create(null));
19
- }
20
- return config;
21
- }
22
- function matchKeys(lhs, rhs) {
23
- if (lhs === rhs) {
24
- return true;
25
- }
26
- if (lhs.startsWith('@')) {
27
- const [ns, rn] = lhs.split('/');
28
- return [ns, ns.slice(1), rn].includes(rhs);
29
- }
30
- if (rhs.startsWith('@')) {
31
- return lhs.startsWith(rhs);
32
- }
33
- return false;
34
- }
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../packages/eslint-plugin/src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,KAAK,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAC/D,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA"}