Skip to content

Commit

Permalink
fix(require-jsdoc): avoid erring on static blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
brettz9 committed Sep 13, 2024
1 parent 288f0ae commit 8222262
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
7 changes: 7 additions & 0 deletions docs/rules/require-jsdoc.md
Original file line number Diff line number Diff line change
Expand Up @@ -1894,5 +1894,12 @@ export class MyClass {
#myPrivateProp = 5;
}
// "jsdoc/require-jsdoc": ["error"|"warn", {"publicOnly":true,"contexts":["PropertyDefinition"],"require":{"MethodDefinition":true}}]

class Abc {
static {
this.x = '2'
}
}
// "jsdoc/require-jsdoc": ["error"|"warn", {"publicOnly":true,"require":{"ClassDeclaration":true}}]
````

3 changes: 3 additions & 0 deletions src/exportParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,9 @@ const getSymbol = function (node, globals, scope, opt) {
case 'ClassBody': {
const val = createNode();
for (const method of node.body) {
if (!('key' in method)) { // StaticBlock
continue;
}
val.props[
/** @type {import('estree').Identifier} */ (
/** @type {import('estree').MethodDefinition} */ (
Expand Down
20 changes: 20 additions & 0 deletions test/rules/assertions/requireJsdoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -6293,5 +6293,25 @@ function quux (foo) {
},
],
},
{
code: `
class Abc {
static {
this.x = '2'
}
}
`,
languageOptions: {
parser: babelEslintParser,
},
options: [
{
publicOnly: true,
require: {
ClassDeclaration: true
}
}
],
}
],
};

0 comments on commit 8222262

Please sign in to comment.