Skip to content

Commit 0712920

Browse files
committed
add no-import-side-effect converter
1 parent e408e53 commit 0712920

File tree

2 files changed

+56
-0
lines changed

2 files changed

+56
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { RuleConverter } from "../converter";
2+
3+
export const convertNoImportSideEffect: RuleConverter = tsLintRule => {
4+
const rules = [];
5+
const notices = [];
6+
7+
if (tsLintRule.ruleArguments.length > 0) {
8+
rules.push({ allow: tsLintRule.ruleArguments[1]["ignore-module"] });
9+
notices.push("This now accepts a glob pattern, so your regex may need converted");
10+
}
11+
12+
return {
13+
rules: [
14+
{
15+
ruleArguments: rules,
16+
ruleName: "no-import-side-effect",
17+
notices: notices,
18+
},
19+
],
20+
};
21+
};
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { convertNoImportSideEffect } from "../no-import-side-effect";
2+
3+
describe(convertNoImportSideEffect, () => {
4+
test("conversion without arguments", () => {
5+
const result = convertNoImportSideEffect({
6+
ruleArguments: [],
7+
});
8+
9+
expect(result).toEqual({
10+
rules: [
11+
{
12+
ruleArguments: [],
13+
ruleName: "no-import-side-effect",
14+
notices: [],
15+
},
16+
],
17+
});
18+
});
19+
20+
test("conversion with arguments", () => {
21+
const result = convertNoImportSideEffect({
22+
ruleArguments: [true, { "ignore-module": "(\\.html|\\.css)$" }],
23+
});
24+
25+
expect(result).toEqual({
26+
rules: [
27+
{
28+
ruleArguments: [{ allow: "(\\.html|\\.css)$" }],
29+
ruleName: "no-import-side-effect",
30+
notices: ["This now accepts a glob pattern, so your regex may need converted"],
31+
},
32+
],
33+
});
34+
});
35+
});

0 commit comments

Comments
 (0)