Skip to content

Commit 334d46d

Browse files
authored
Add codelyzer pipe-prefix converter (#680)
1 parent a02e11a commit 334d46d

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 convertPipePrefix: 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/pipe-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 { convertPipePrefix } from "../pipe-prefix";
2+
3+
describe(convertPipePrefix, () => {
4+
test("conversion without arguments", () => {
5+
const result = convertPipePrefix({
6+
ruleArguments: [],
7+
});
8+
9+
expect(result).toEqual({
10+
rules: [
11+
{
12+
ruleName: "@angular-eslint/pipe-prefix",
13+
},
14+
],
15+
plugins: ["@angular-eslint/eslint-plugin"],
16+
});
17+
});
18+
19+
test("conversion with arguments", () => {
20+
const result = convertPipePrefix({
21+
ruleArguments: ["ng", "sg", "mg"],
22+
});
23+
24+
expect(result).toEqual({
25+
rules: [
26+
{
27+
ruleArguments: [
28+
{
29+
prefixes: ["ng", "sg", "mg"],
30+
},
31+
],
32+
ruleName: "@angular-eslint/pipe-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
@@ -158,6 +158,7 @@ import { convertNoOutputRename } from "./converters/codelyzer/no-output-rename";
158158
import { convertNoOutputsMetadataProperty } from "./converters/codelyzer/no-outputs-metadata-property";
159159
import { convertNoPipeImpure } from "./converters/codelyzer/no-pipe-impure";
160160
import { convertNoQueriesMetadataProperty } from "./converters/codelyzer/no-queries-metadata-property";
161+
import { convertPipePrefix } from "./converters/codelyzer/pipe-prefix";
161162
import { convertPreferOnPushComponentChangeDetection } from "./converters/codelyzer/prefer-on-push-component-change-detection";
162163
import { convertPreferOutputReadonly } from "./converters/codelyzer/prefer-output-readonly";
163164
import { convertRelativeUrlPrefix } from "./converters/codelyzer/relative-url-prefix";
@@ -323,6 +324,7 @@ export const rulesConverters = new Map([
323324
["one-variable-per-declaration", convertOneVariablePerDeclaration],
324325
["only-arrow-functions", convertOnlyArrowFunctions],
325326
["ordered-imports", convertOrderedImports],
327+
["pipe-prefix", convertPipePrefix],
326328
["prefer-const", convertPreferConst],
327329
["prefer-for-of", convertPreferForOf],
328330
["prefer-function-over-method", convertPreferFunctionOverMethod],

0 commit comments

Comments
 (0)