Skip to content

Commit a99478c

Browse files
cthompson527Josh Goldberg
authored and
Josh Goldberg
committed
added no-void-expression converter and unit tests (#198)
1 parent 089de81 commit a99478c

File tree

3 files changed

+49
-0
lines changed

3 files changed

+49
-0
lines changed

src/rules/converters.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ import { convertNoUnsafeFinally } from "./converters/no-unsafe-finally";
8080
import { convertNoUseBeforeDeclare } from "./converters/no-use-before-declare";
8181
import { convertNoVarKeyword } from "./converters/no-var-keyword";
8282
import { convertNoVarRequires } from "./converters/no-var-requires";
83+
import { convertNoVoidExpression } from "./converters/no-void-expression";
8384
import { convertObjectLiteralKeyQuotes } from "./converters/object-literal-key-quotes";
8485
import { convertObjectLiteralShorthand } from "./converters/object-literal-shorthand";
8586
import { convertOneVariablePerDeclaration } from "./converters/one-variable-per-declaration";
@@ -168,6 +169,7 @@ export const converters = new Map([
168169
["no-use-before-declare", convertNoUseBeforeDeclare],
169170
["no-var-keyword", convertNoVarKeyword],
170171
["no-var-requires", convertNoVarRequires],
172+
["no-void-expression", convertNoVoidExpression],
171173
["prefer-for-of", convertPreferForOf],
172174
["prefer-object-spread", convertPreferObjectSpread],
173175
["promise-function-async", convertPromiseFunctionAsync],
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { RuleConverter } from "../converter";
2+
3+
export const convertNoVoidExpression: RuleConverter = tslintRule => {
4+
return {
5+
rules: [
6+
{
7+
...(tslintRule.ruleArguments.length > 0 &&
8+
tslintRule.ruleArguments.includes("ignore-arrow-function-shorthand") && {
9+
notices: ["ESLint does not support ignoring arrow function shorthand."],
10+
}),
11+
ruleName: "no-void",
12+
},
13+
],
14+
};
15+
};
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { convertNoVoidExpression } from "../no-void-expression";
2+
3+
describe(convertNoVoidExpression, () => {
4+
test("conversion without arguments", () => {
5+
const result = convertNoVoidExpression({
6+
ruleArguments: [],
7+
});
8+
9+
expect(result).toEqual({
10+
rules: [
11+
{
12+
ruleName: "no-void",
13+
},
14+
],
15+
});
16+
});
17+
18+
test("conversion with ignore-arrow-function-shorthand argument", () => {
19+
const result = convertNoVoidExpression({
20+
ruleArguments: ["ignore-arrow-function-shorthand"],
21+
});
22+
23+
expect(result).toEqual({
24+
rules: [
25+
{
26+
notices: ["ESLint does not support ignoring arrow function shorthand."],
27+
ruleName: "no-void",
28+
},
29+
],
30+
});
31+
});
32+
});

0 commit comments

Comments
 (0)