Skip to content

Commit

Permalink
test: demo checking of observer call; #1144
Browse files Browse the repository at this point in the history
  • Loading branch information
brettz9 committed Aug 16, 2023
1 parent 6bc21aa commit f6946a5
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
4 changes: 4 additions & 0 deletions docs/rules/require-jsdoc.md
Original file line number Diff line number Diff line change
Expand Up @@ -1003,6 +1003,10 @@ export class MyClass {
}
// "jsdoc/require-jsdoc": ["error"|"warn", {"contexts":["PropertyDefinition"],"publicOnly":true}]
// Message: Missing JSDoc comment.

export const Comp = observer(() => <>Hello</>);
// "jsdoc/require-jsdoc": ["error"|"warn", {"contexts":["CallExpression[callee.name=\"observer\"]"],"enableFixer":false,"publicOnly":true,"require":{"ArrowFunctionExpression":true,"ClassDeclaration":true,"ClassExpression":true,"FunctionDeclaration":true,"FunctionExpression":true,"MethodDefinition":true}}]
// Message: Missing JSDoc comment.
````


Expand Down
34 changes: 34 additions & 0 deletions test/rules/assertions/requireJsdoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -4125,6 +4125,40 @@ function quux (foo) {
`,
parser: require.resolve('@typescript-eslint/parser'),
},
{
code: `
export const Comp = observer(() => <>Hello</>);
`,
errors: [
{
line: 2,
message: 'Missing JSDoc comment.',
},
],
options: [
{
contexts: [
'CallExpression[callee.name="observer"]',
],
enableFixer: false,
publicOnly: true,
require: {
ArrowFunctionExpression: true,
ClassDeclaration: true,
ClassExpression: true,
FunctionDeclaration: true,
FunctionExpression: true,
MethodDefinition: true,
},
},
],
parser: require.resolve('@typescript-eslint/parser'),
parserOptions: {
ecmaFeatures: {
jsx: true,
},
},
},
],
valid: [
{
Expand Down

0 comments on commit f6946a5

Please sign in to comment.