Skip to content

Allowed converters to specify output rule severity #1044

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/converters/lintConfigs/rules/ruleConverter.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { TSLintRuleOptions } from "./types";
import { ESLintRuleSeverity, TSLintRuleOptions } from "./types";
import { ConversionError } from "../../../errors/conversionError";

/**
Expand Down Expand Up @@ -51,4 +51,9 @@ export type ConvertedRuleChanges = {
* Equivalent ESLint rule name that should be enabled.
*/
ruleName: string;

/**
* Custom severity for the output rule.
*/
ruleSeverity?: ESLintRuleSeverity;
};
25 changes: 13 additions & 12 deletions src/converters/lintConfigs/rules/ruleConverters/variable-name.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { RuleConverter } from "../ruleConverter";
import { ESLintRuleSeverity } from "../types";

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

const getUnderscoreDangleRuleOptions = () => {
let underscoreDangleOptionSeverity: string | null = null;
let underscoreDangleOptionSeverity: ESLintRuleSeverity | undefined;
const underscoreDangleOptionNotice: string[] = [];

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

return {
notices: underscoreDangleOptionNotice,
...(underscoreDangleOptionSeverity !== null && {
...(underscoreDangleOptionSeverity !== undefined && {
ruleSeverity: underscoreDangleOptionSeverity,
}),
ruleName: "no-underscore-dangle",
Expand All @@ -79,16 +80,16 @@ export const convertVariableName: RuleConverter = (tslintRule) => {
const getBlackListRuleOptions = () => {
const blackListOptionArguments = tslintRule.ruleArguments.includes("ban-keywords")
? [
"any",
"Number",
"number",
"String",
"string",
"Boolean",
"boolean",
"Undefined",
"undefined",
]
"any",
"Number",
"number",
"String",
"string",
"Boolean",
"boolean",
"Undefined",
"undefined",
]
: [];

return {
Expand Down