Skip to content

Commit a1e1c4c

Browse files
authored
[Feature] Add jsdoc-format converter (#238)
* Add jsdoc-format converter * Replace jsdoc format rule with check indentation * Add notice for multiline comments in jsdoc rule * Provide jsdoc format notice closer to TSLint docs
1 parent 2761bbb commit a1e1c4c

File tree

3 files changed

+49
-0
lines changed

3 files changed

+49
-0
lines changed

src/rules/converters/jsdoc-format.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { RuleConverter, ConvertedRuleChanges } from "../converter";
2+
3+
export const JSDocNoticeMsg =
4+
"ESLint does not support enforcing the first line of multiline JSDoc comments be empty.";
5+
6+
export const convertJSDocFormat: RuleConverter = () => {
7+
const ruleNames = [
8+
"jsdoc/check-alignment",
9+
"jsdoc/check-indentation",
10+
"jsdoc/newline-after-description",
11+
];
12+
13+
const mappedRuleNames: ConvertedRuleChanges[] = ruleNames.map(ruleName => {
14+
return { ruleName };
15+
});
16+
17+
return {
18+
rules: [...mappedRuleNames],
19+
notices: [JSDocNoticeMsg],
20+
plugins: ["eslint-plugin-jsdoc"],
21+
};
22+
};
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { convertJSDocFormat, JSDocNoticeMsg } from "../jsdoc-format";
2+
3+
describe(convertJSDocFormat, () => {
4+
test("conversion without arguments", () => {
5+
const result = convertJSDocFormat({
6+
ruleArguments: [],
7+
});
8+
9+
expect(result).toEqual({
10+
rules: [
11+
{
12+
ruleName: "jsdoc/check-alignment",
13+
},
14+
{
15+
ruleName: "jsdoc/check-indentation",
16+
},
17+
{
18+
ruleName: "jsdoc/newline-after-description",
19+
},
20+
],
21+
notices: [JSDocNoticeMsg],
22+
plugins: ["eslint-plugin-jsdoc"],
23+
});
24+
});
25+
});

src/rules/rulesConverters.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import { convertIncrementDecrement } from "./converters/increment-decrement";
2323
import { convertIndent } from "./converters/indent";
2424
import { convertInterfaceName } from "./converters/interface-name";
2525
import { convertInterfaceOverTypeLiteral } from "./converters/interface-over-type-literal";
26+
import { convertJSDocFormat } from "./converters/jsdoc-format";
2627
import { convertLabelPosition } from "./converters/label-position";
2728
import { convertLinebreakStyle } from "./converters/linebreak-style";
2829
import { convertMaxClassesPerFile } from "./converters/max-classes-per-file";
@@ -162,6 +163,7 @@ export const rulesConverters = new Map([
162163
["indent", convertIndent],
163164
["interface-name", convertInterfaceName],
164165
["interface-over-type-literal", convertInterfaceOverTypeLiteral],
166+
["jsdoc-format", convertJSDocFormat],
165167
["label-position", convertLabelPosition],
166168
["linebreak-style", convertLinebreakStyle],
167169
["max-classes-per-file", convertMaxClassesPerFile],

0 commit comments

Comments
 (0)