Skip to content

Commit 4df302a

Browse files
author
Josh Goldberg
authored
Added rule converter for react-a11y-anchors (#1090)
1 parent d97173e commit 4df302a

File tree

3 files changed

+57
-0
lines changed

3 files changed

+57
-0
lines changed

src/converters/lintConfigs/rules/ruleConverters.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@ import { convertPreferTemplate } from "./ruleConverters/prefer-template";
244244
import { convertPromiseFunctionAsync } from "./ruleConverters/promise-function-async";
245245
import { convertQuotemark } from "./ruleConverters/quotemark";
246246
import { convertRadix } from "./ruleConverters/radix";
247+
import { convertReactA11yAnchors } from "./ruleConverters/react-a11y-anchors";
247248
import { convertRestrictPlusOperands } from "./ruleConverters/restrict-plus-operands";
248249
import { convertSemicolon } from "./ruleConverters/semicolon";
249250
import { convertSpaceBeforeFunctionParen } from "./ruleConverters/space-before-function-paren";
@@ -469,6 +470,7 @@ export const ruleConverters = new Map([
469470
["quotemark", convertQuotemark],
470471
["radix", convertRadix],
471472
["relative-url-prefix", convertRelativeUrlPrefix],
473+
["react-a11y-anchors", convertReactA11yAnchors],
472474
["restrict-plus-operands", convertRestrictPlusOperands],
473475
["rxjs-no-async-subscribe", convertNoAsyncSubscribe],
474476
["rxjs-no-create", convertNoCreate],
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { RuleConverter } from "../ruleConverter";
2+
3+
export const convertReactA11yAnchors: RuleConverter = (tslintRule) => {
4+
return {
5+
...(tslintRule.ruleArguments.length > 0 && ({
6+
notices: Object.keys(tslintRule.ruleArguments[0] as Record<string, unknown>).map(key => `jsx-a11y/anchor-is-valid does not support the '${key}' option.`)
7+
})),
8+
plugins: ["jsx-a11y"],
9+
rules: [
10+
{
11+
ruleName: "jsx-a11y/anchor-is-valid",
12+
},
13+
],
14+
};
15+
};
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import { convertReactA11yAnchors } from "../react-a11y-anchors";
2+
3+
describe(convertReactA11yAnchors, () => {
4+
test("conversion without arguments", () => {
5+
const result = convertReactA11yAnchors({
6+
ruleArguments: [],
7+
});
8+
9+
expect(result).toEqual({
10+
plugins: ["jsx-a11y"],
11+
rules: [
12+
{
13+
ruleName: "jsx-a11y/anchor-is-valid",
14+
},
15+
],
16+
});
17+
});
18+
19+
test("conversion with arguments", () => {
20+
const result = convertReactA11yAnchors({
21+
ruleArguments: [{
22+
'ignore-case': true,
23+
'ignore-whitespace': 'trim'
24+
}],
25+
});
26+
27+
expect(result).toEqual({
28+
notices: [
29+
`jsx-a11y/anchor-is-valid does not support the 'ignore-case' option.`,
30+
`jsx-a11y/anchor-is-valid does not support the 'ignore-whitespace' option.`
31+
],
32+
plugins: ["jsx-a11y"],
33+
rules: [
34+
{
35+
ruleName: "jsx-a11y/anchor-is-valid",
36+
},
37+
],
38+
});
39+
});
40+
});

0 commit comments

Comments
 (0)