Skip to content

Commit 1410dd3

Browse files
authored
Add codelyzer no-input-prefix converter (#531)
1 parent a0228c2 commit 1410dd3

File tree

3 files changed

+59
-0
lines changed

3 files changed

+59
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { RuleConverter } from "../../converter";
2+
3+
export const convertNoInputPrefix: RuleConverter = (tslintRule) => {
4+
return {
5+
rules: [
6+
{
7+
...(tslintRule.ruleArguments.length !== 0 && {
8+
ruleArguments: [
9+
{
10+
prefixes: tslintRule.ruleArguments,
11+
},
12+
],
13+
}),
14+
ruleName: "@angular-eslint/no-input-prefix",
15+
},
16+
],
17+
plugins: ["@angular-eslint/eslint-plugin"],
18+
};
19+
};
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import { convertNoInputPrefix } from "../no-input-prefix";
2+
3+
describe(convertNoInputPrefix, () => {
4+
test("conversion without arguments", () => {
5+
const result = convertNoInputPrefix({
6+
ruleArguments: [],
7+
});
8+
9+
expect(result).toEqual({
10+
rules: [
11+
{
12+
ruleName: "@angular-eslint/no-input-prefix",
13+
},
14+
],
15+
plugins: ["@angular-eslint/eslint-plugin"],
16+
});
17+
});
18+
19+
test("conversion with arguments", () => {
20+
const result = convertNoInputPrefix({
21+
ruleArguments: ["can", "is", "should"],
22+
});
23+
24+
expect(result).toEqual({
25+
rules: [
26+
{
27+
ruleArguments: [
28+
{
29+
prefixes: ["can", "is", "should"],
30+
},
31+
],
32+
ruleName: "@angular-eslint/no-input-prefix",
33+
},
34+
],
35+
plugins: ["@angular-eslint/eslint-plugin"],
36+
});
37+
});
38+
});

src/rules/rulesConverters.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ import { convertNoAttributeDecorator } from "./converters/codelyzer/no-attribute
148148
import { convertUsePipeDecorator } from "./converters/codelyzer/use-pipe-decorator";
149149
import { convertNoForwardRef } from "./converters/codelyzer/no-forward-ref";
150150
import { convertNoHostMetadataProperty } from "./converters/codelyzer/no-host-metadata-property";
151+
import { convertNoInputPrefix } from "./converters/codelyzer/no-input-prefix";
151152

152153
/**
153154
* Keys TSLint rule names to their ESLint rule converters.
@@ -226,6 +227,7 @@ export const rulesConverters = new Map([
226227
["no-implicit-dependencies", convertNoImplicitDependencies],
227228
["no-import-side-effect", convertNoImportSideEffect],
228229
["no-inferrable-types", convertNoInferrableTypes],
230+
["no-input-prefix", convertNoInputPrefix],
229231
["no-internal-module", convertNoInternalModule],
230232
["no-invalid-regexp", convertNoInvalidRegexp],
231233
["no-invalid-template-strings", convertNoInvalidTemplateStrings],

0 commit comments

Comments
 (0)