Skip to content

Commit bef17a2

Browse files
KingDarBojaJosh Goldberg
andauthored
Add codelyzer directive-class-suffix converter (#457)
Co-authored-by: Josh Goldberg <[email protected]>
1 parent 5be49eb commit bef17a2

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 convertDirectiveClassSuffix: RuleConverter = (tslintRule) => {
4+
return {
5+
rules: [
6+
{
7+
...(tslintRule.ruleArguments.length !== 0 && {
8+
ruleArguments: [
9+
{
10+
suffixes: tslintRule.ruleArguments,
11+
},
12+
],
13+
}),
14+
ruleName: "@angular-eslint/directive-class-suffix",
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 { convertDirectiveClassSuffix } from "../directive-class-suffix";
2+
3+
describe(convertDirectiveClassSuffix, () => {
4+
test("conversion without arguments", () => {
5+
const result = convertDirectiveClassSuffix({
6+
ruleArguments: [],
7+
});
8+
9+
expect(result).toEqual({
10+
rules: [
11+
{
12+
ruleName: "@angular-eslint/directive-class-suffix",
13+
},
14+
],
15+
plugins: ["@angular-eslint/eslint-plugin"],
16+
});
17+
});
18+
19+
test("conversion with arguments", () => {
20+
const result = convertDirectiveClassSuffix({
21+
ruleArguments: ["Directive", "View"],
22+
});
23+
24+
expect(result).toEqual({
25+
rules: [
26+
{
27+
ruleArguments: [
28+
{
29+
suffixes: ["Directive", "View"],
30+
},
31+
],
32+
ruleName: "@angular-eslint/directive-class-suffix",
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
@@ -142,6 +142,7 @@ import { convertComponentClassSuffix } from "./converters/codelyzer/component-cl
142142
import { convertComponentMaxInlineDeclarations } from "./converters/codelyzer/component-max-inline-declarations";
143143
import { convertComponentSelector } from "./converters/codelyzer/component-selector";
144144
import { convertContextualLifecycle } from "./converters/codelyzer/contextual-lifecycle";
145+
import { convertDirectiveClassSuffix } from "./converters/codelyzer/directive-class-suffix";
145146
import { convertNoAttributeDecorator } from "./converters/codelyzer/no-attribute-decorator";
146147
import { convertUsePipeDecorator } from "./converters/codelyzer/use-pipe-decorator";
147148

@@ -169,6 +170,7 @@ export const rulesConverters = new Map([
169170
["curly", convertCurly],
170171
["cyclomatic-complexity", convertCyclomaticComplexity],
171172
["deprecation", convertDeprecation],
173+
["directive-class-suffix", convertDirectiveClassSuffix],
172174
["eofline", convertEofline],
173175
["file-name-casing", convertFileNameCasing],
174176
["forin", convertForin],

0 commit comments

Comments
 (0)