@tsslint/config 3.0.1 → 3.0.3
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/lib/eslint.d.ts +3 -4
- package/lib/eslint.js +6 -3
- package/lib/tsl.d.ts +1 -1
- package/lib/tslint.d.ts +2 -3
- package/lib/tslint.js +2 -0
- package/lib/utils.d.ts +7 -0
- package/lib/utils.js +21 -0
- package/package.json +3 -3
package/lib/eslint.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type * as TSSLint from '@tsslint/types';
|
|
2
2
|
import type * as ESLint from 'eslint';
|
|
3
3
|
import type { ESLintRulesConfig } from './eslint-types.js';
|
|
4
|
-
|
|
4
|
+
import { type RuleSeverity } from './utils.js';
|
|
5
5
|
/**
|
|
6
6
|
* Converts an ESLint rules configuration to TSSLint rules.
|
|
7
7
|
*
|
|
@@ -10,6 +10,5 @@ type Severity = boolean | 'error' | 'warn';
|
|
|
10
10
|
* Please run `npx tsslint-docgen` to update them.
|
|
11
11
|
*/
|
|
12
12
|
export declare function importESLintRules(config: {
|
|
13
|
-
[K in keyof ESLintRulesConfig]:
|
|
14
|
-
}, context?: Partial<ESLint.Rule.RuleContext>): Promise<TSSLint.Rules>;
|
|
15
|
-
export {};
|
|
13
|
+
[K in keyof ESLintRulesConfig]: RuleSeverity | [RuleSeverity, ...ESLintRulesConfig[K]];
|
|
14
|
+
}, context?: Partial<ESLint.Rule.RuleContext>, getConvertRule?: () => Promise<typeof import("@tsslint/compat-eslint").convertRule>): Promise<TSSLint.Rules>;
|
package/lib/eslint.js
CHANGED
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.importESLintRules = importESLintRules;
|
|
4
4
|
const fs = require("fs");
|
|
5
5
|
const path = require("path");
|
|
6
|
+
const utils_js_1 = require("./utils.js");
|
|
6
7
|
const noop = () => { };
|
|
7
8
|
const plugins = {};
|
|
8
9
|
const loader = async (moduleName) => {
|
|
@@ -27,14 +28,15 @@ const loader = async (moduleName) => {
|
|
|
27
28
|
*
|
|
28
29
|
* Please run `npx tsslint-docgen` to update them.
|
|
29
30
|
*/
|
|
30
|
-
async function importESLintRules(config, context = {}) {
|
|
31
|
-
let convertRule;
|
|
31
|
+
async function importESLintRules(config, context = {}, getConvertRule = async () => {
|
|
32
32
|
try {
|
|
33
|
-
(
|
|
33
|
+
return (await import('@tsslint/compat-eslint')).convertRule;
|
|
34
34
|
}
|
|
35
35
|
catch {
|
|
36
36
|
throw new Error('Please install @tsslint/compat-eslint to use importESLintRules().');
|
|
37
37
|
}
|
|
38
|
+
}) {
|
|
39
|
+
const convertRule = await getConvertRule();
|
|
38
40
|
const rules = {};
|
|
39
41
|
for (const [rule, severityOrOptions] of Object.entries(config)) {
|
|
40
42
|
let severity;
|
|
@@ -46,6 +48,7 @@ async function importESLintRules(config, context = {}) {
|
|
|
46
48
|
severity = severityOrOptions;
|
|
47
49
|
options = [];
|
|
48
50
|
}
|
|
51
|
+
severity = (0, utils_js_1.normalizeRuleSeverity)(severity);
|
|
49
52
|
if (!severity) {
|
|
50
53
|
rules[rule] = noop;
|
|
51
54
|
continue;
|
package/lib/tsl.d.ts
CHANGED
package/lib/tslint.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type * as TSSLint from '@tsslint/types';
|
|
2
2
|
import type { TSLintRulesConfig } from './tslint-types.js';
|
|
3
|
-
|
|
3
|
+
import { type RuleSeverity } from './utils.js';
|
|
4
4
|
/**
|
|
5
5
|
* Converts a TSLint rules configuration to TSSLint rules.
|
|
6
6
|
*
|
|
@@ -9,7 +9,6 @@ type Severity = boolean | 'error' | 'warn';
|
|
|
9
9
|
* Please run `npx tsslint-docgen` to update them.
|
|
10
10
|
*/
|
|
11
11
|
export declare function importTSLintRules(config: {
|
|
12
|
-
[K in keyof TSLintRulesConfig]:
|
|
12
|
+
[K in keyof TSLintRulesConfig]: RuleSeverity | [RuleSeverity, ...TSLintRulesConfig[K]];
|
|
13
13
|
}): Promise<TSSLint.Rules>;
|
|
14
14
|
export declare function getTSLintRulesDirectories(): [string, string][];
|
|
15
|
-
export {};
|
package/lib/tslint.js
CHANGED
|
@@ -4,6 +4,7 @@ exports.importTSLintRules = importTSLintRules;
|
|
|
4
4
|
exports.getTSLintRulesDirectories = getTSLintRulesDirectories;
|
|
5
5
|
const fs = require("fs");
|
|
6
6
|
const path = require("path");
|
|
7
|
+
const utils_js_1 = require("./utils.js");
|
|
7
8
|
const noop = () => { };
|
|
8
9
|
/**
|
|
9
10
|
* Converts a TSLint rules configuration to TSSLint rules.
|
|
@@ -25,6 +26,7 @@ async function importTSLintRules(config) {
|
|
|
25
26
|
severity = severityOrOptions;
|
|
26
27
|
options = [];
|
|
27
28
|
}
|
|
29
|
+
severity = (0, utils_js_1.normalizeRuleSeverity)(severity);
|
|
28
30
|
if (!severity) {
|
|
29
31
|
rules[ruleName] = noop;
|
|
30
32
|
continue;
|
package/lib/utils.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export type RuleSeverity = boolean | 'error' | 'warn';
|
|
2
|
+
type ESLintStringSeverity = 'off' | 'warn' | 'error';
|
|
3
|
+
type ESLintNumericSeverity = 0 | 1 | 2;
|
|
4
|
+
type TSLintStringSeverity = 'default' | 'warning' | 'warn' | 'error' | 'off' | 'none';
|
|
5
|
+
type TSLintBooleanSeverity = true | false;
|
|
6
|
+
export declare function normalizeRuleSeverity(severity: RuleSeverity | ESLintStringSeverity | ESLintNumericSeverity | TSLintStringSeverity | TSLintBooleanSeverity): RuleSeverity;
|
|
7
|
+
export {};
|
package/lib/utils.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.normalizeRuleSeverity = normalizeRuleSeverity;
|
|
4
|
+
function normalizeRuleSeverity(severity) {
|
|
5
|
+
switch (severity) {
|
|
6
|
+
case 'default':
|
|
7
|
+
return true;
|
|
8
|
+
case 0:
|
|
9
|
+
case 'off':
|
|
10
|
+
case 'none':
|
|
11
|
+
return false;
|
|
12
|
+
case 1:
|
|
13
|
+
case 'warning':
|
|
14
|
+
return 'warn';
|
|
15
|
+
case 2:
|
|
16
|
+
return 'error';
|
|
17
|
+
default:
|
|
18
|
+
return severity;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=utils.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsslint/config",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.3",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=22.6.0"
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"directory": "packages/config"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@tsslint/types": "3.0.
|
|
21
|
+
"@tsslint/types": "3.0.3",
|
|
22
22
|
"minimatch": "^10.0.1",
|
|
23
23
|
"ts-api-utils": "^2.0.0"
|
|
24
24
|
},
|
|
@@ -38,5 +38,5 @@
|
|
|
38
38
|
"optional": true
|
|
39
39
|
}
|
|
40
40
|
},
|
|
41
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "0f465c4bd0705530fb6edb1ce1c287e2461cb388"
|
|
42
42
|
}
|