Skip to content

Commit 1b3212f

Browse files
committedFeb 9, 2022
fix(empty-tags): prevent tag content for interface in Closure mode
1 parent cc773c7 commit 1b3212f

File tree

3 files changed

+34
-0
lines changed

3 files changed

+34
-0
lines changed
 

‎README.md

+6
Original file line numberDiff line numberDiff line change
@@ -6177,6 +6177,12 @@ function quux () {
61776177
}
61786178
// Message: @abstract should be empty.
61796179
6180+
/**
6181+
* @interface extra text
6182+
*/
6183+
// Settings: {"jsdoc":{"mode":"closure"}}
6184+
// Message: @interface should be empty.
6185+
61806186
class Test {
61816187
/**
61826188
* @abstract extra text

‎src/rules/emptyTags.js

+5
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ const emptyIfNotClosure = new Set([
1919
'inheritdoc',
2020
]);
2121

22+
const emptyIfClosure = new Set([
23+
'interface',
24+
]);
25+
2226
export default iterateJsdoc(({
2327
settings,
2428
jsdoc,
@@ -33,6 +37,7 @@ export default iterateJsdoc(({
3337
}) => {
3438
return tag === tagName;
3539
}) ||
40+
settings.mode === 'closure' && emptyIfClosure.has(tagName) ||
3641
settings.mode !== 'closure' && emptyIfNotClosure.has(tagName);
3742
});
3843
for (const tag of emptyTags) {

‎test/rules/assertions/emptyTags.js

+23
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,29 @@ export default {
2424
}
2525
`,
2626
},
27+
{
28+
code: `
29+
/**
30+
* @interface extra text
31+
*/
32+
`,
33+
errors: [
34+
{
35+
line: 3,
36+
message: '@interface should be empty.',
37+
},
38+
],
39+
output: `
40+
/**
41+
* @interface
42+
*/
43+
`,
44+
settings: {
45+
jsdoc: {
46+
mode: 'closure',
47+
},
48+
},
49+
},
2750
{
2851
code: `
2952
class Test {

0 commit comments

Comments
 (0)
Please sign in to comment.