Skip to content
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

Add no-unused-variable converter #422

Merged
merged 2 commits into from
Apr 29, 2020
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
16 changes: 16 additions & 0 deletions src/rules/converters/no-unused-variable.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { RuleConverter } from "../converter";

export const NO_UNUSED_VARIABLE_NOTICE =
"Please read the following article as the rule behaviour may change on the short term: " +
"https://github.com/typescript-eslint/typescript-eslint/issues/1856";

export const convertNoUnusedVariable: RuleConverter = () => {
return {
rules: [
{
ruleName: "@typescript-eslint/no-unused-vars",
notices: [NO_UNUSED_VARIABLE_NOTICE],
},
],
};
};
18 changes: 18 additions & 0 deletions src/rules/converters/tests/no-unused-variable.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { convertNoUnusedVariable, NO_UNUSED_VARIABLE_NOTICE } from "../no-unused-variable";

describe(convertNoUnusedVariable, () => {
test("conversion without arguments", () => {
const result = convertNoUnusedVariable({
ruleArguments: [],
});

expect(result).toEqual({
rules: [
{
ruleName: "@typescript-eslint/no-unused-vars",
notices: [NO_UNUSED_VARIABLE_NOTICE],
},
],
});
});
});
2 changes: 2 additions & 0 deletions src/rules/rulesConverters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ import { convertNoUnnecessarySemicolons } from "./converters/no-unnecessary-semi
import { convertNoUnnecessaryTypeAssertion } from "./converters/no-unnecessary-type-assertion";
import { convertNoUnsafeFinally } from "./converters/no-unsafe-finally";
import { convertNoUnusedExpression } from "./converters/no-unused-expression";
import { convertNoUnusedVariable } from "./converters/no-unused-variable";
import { convertNoUseBeforeDeclare } from "./converters/no-use-before-declare";
import { convertNoVarKeyword } from "./converters/no-var-keyword";
import { convertNoVarRequires } from "./converters/no-var-requires";
Expand Down Expand Up @@ -240,6 +241,7 @@ export const rulesConverters = new Map([
["no-unnecessary-type-assertion", convertNoUnnecessaryTypeAssertion],
["no-unsafe-finally", convertNoUnsafeFinally],
["no-unused-expression", convertNoUnusedExpression],
["no-unused-variable", convertNoUnusedVariable],
["no-use-before-declare", convertNoUseBeforeDeclare],
["no-var-keyword", convertNoVarKeyword],
["no-var-requires", convertNoVarRequires],
Expand Down