Skip to content

Commit 0c57192

Browse files
authored
Fix codelyzer template-accessibility-label-for converter (#988)
Added the missing rule options
1 parent 3a4c53e commit 0c57192

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

src/converters/lintConfigs/rules/ruleConverters/codelyzer/template-accessibility-label-for.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,18 @@
11
import { RuleConverter } from "../../ruleConverter";
22

3-
export const convertTemplateAccessibilityLabelFor: RuleConverter = () => {
3+
export const convertTemplateAccessibilityLabelFor: RuleConverter = (tslintRule) => {
44
return {
55
rules: [
66
{
7+
...(tslintRule.ruleArguments.length !== 0 && {
8+
ruleArguments: [
9+
{
10+
...(tslintRule.ruleArguments[0]?.controlComponents && { controlComponents: tslintRule.ruleArguments[0]?.controlComponents }),
11+
...(tslintRule.ruleArguments[0]?.labelAttributes && { labelAttributes: tslintRule.ruleArguments[0]?.labelAttributes }),
12+
...(tslintRule.ruleArguments[0]?.labelComponents && { labelComponents: tslintRule.ruleArguments[0]?.labelComponents }),
13+
},
14+
],
15+
}),
716
ruleName: "@angular-eslint/template/accessibility-label-for",
817
},
918
],

src/converters/lintConfigs/rules/ruleConverters/codelyzer/tests/template-accessibility-label-for.test.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,30 @@ describe(convertTemplateAccessibilityLabelFor, () => {
1515
plugins: ["@angular-eslint/eslint-plugin-template"],
1616
});
1717
});
18+
19+
test("conversion with arguments", () => {
20+
const result = convertTemplateAccessibilityLabelFor({
21+
ruleArguments: [{
22+
controlComponents: ["app-input", "app-select"],
23+
labelAttributes: ["id"],
24+
labelComponents: ["app-label"],
25+
}],
26+
});
27+
28+
expect(result).toEqual({
29+
rules: [
30+
{
31+
ruleArguments: [
32+
{
33+
controlComponents: ["app-input", "app-select"],
34+
labelAttributes: ["id"],
35+
labelComponents: ["app-label"],
36+
}
37+
],
38+
ruleName: "@angular-eslint/template/accessibility-label-for",
39+
},
40+
],
41+
plugins: ["@angular-eslint/eslint-plugin-template"],
42+
});
43+
});
1844
});

0 commit comments

Comments
 (0)