Skip to content

Commit 80ec918

Browse files
author
Josh Goldberg
authored
Allowed converters to specify output rule severity (#1044)
1 parent f89c046 commit 80ec918

File tree

2 files changed

+19
-13
lines changed

2 files changed

+19
-13
lines changed

src/converters/lintConfigs/rules/ruleConverter.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { TSLintRuleOptions } from "./types";
1+
import { ESLintRuleSeverity, TSLintRuleOptions } from "./types";
22
import { ConversionError } from "../../../errors/conversionError";
33

44
/**
@@ -51,4 +51,9 @@ export type ConvertedRuleChanges = {
5151
* Equivalent ESLint rule name that should be enabled.
5252
*/
5353
ruleName: string;
54+
55+
/**
56+
* Custom severity for the output rule.
57+
*/
58+
ruleSeverity?: ESLintRuleSeverity;
5459
};

src/converters/lintConfigs/rules/ruleConverters/variable-name.ts

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { RuleConverter } from "../ruleConverter";
2+
import { ESLintRuleSeverity } from "../types";
23

34
export const ConstRequiredForAllCapsMsg =
45
"typescript-eslint does not enforce uppercase for const only.";
@@ -57,7 +58,7 @@ export const convertVariableName: RuleConverter = (tslintRule) => {
5758
};
5859

5960
const getUnderscoreDangleRuleOptions = () => {
60-
let underscoreDangleOptionSeverity: string | null = null;
61+
let underscoreDangleOptionSeverity: ESLintRuleSeverity | undefined;
6162
const underscoreDangleOptionNotice: string[] = [];
6263

6364
if (hasCheckFormat && (allowedLeadingUnderscore || allowedTrailingUnderscore)) {
@@ -69,7 +70,7 @@ export const convertVariableName: RuleConverter = (tslintRule) => {
6970

7071
return {
7172
notices: underscoreDangleOptionNotice,
72-
...(underscoreDangleOptionSeverity !== null && {
73+
...(underscoreDangleOptionSeverity !== undefined && {
7374
ruleSeverity: underscoreDangleOptionSeverity,
7475
}),
7576
ruleName: "no-underscore-dangle",
@@ -79,16 +80,16 @@ export const convertVariableName: RuleConverter = (tslintRule) => {
7980
const getBlackListRuleOptions = () => {
8081
const blackListOptionArguments = tslintRule.ruleArguments.includes("ban-keywords")
8182
? [
82-
"any",
83-
"Number",
84-
"number",
85-
"String",
86-
"string",
87-
"Boolean",
88-
"boolean",
89-
"Undefined",
90-
"undefined",
91-
]
83+
"any",
84+
"Number",
85+
"number",
86+
"String",
87+
"string",
88+
"Boolean",
89+
"boolean",
90+
"Undefined",
91+
"undefined",
92+
]
9293
: [];
9394

9495
return {

0 commit comments

Comments
 (0)