-
-
Notifications
You must be signed in to change notification settings - Fork 158
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Target property with decorator #662
Comments
As per the docs, you can explore the AST, being sure to specify your parser (in this case Using an esquery expression such as ESLint uses, this appears to work:
Closing as that should resolve, but feel free to comment further as needed. |
Note that the jsdoc block will be expected above the decorator. |
Thank you @brettz9 for your answer. I finally had time to test this, but it appears to not be working correctly. SetupMy config looks like this: {
"parser": "@typescript-eslint/parser",
"plugins": ["jsdoc"],
"rules": {
"jsdoc/require-jsdoc": [
"warn",
{
"require": {
"ArrowFunctionExpression": true,
"ClassDeclaration": false, // Overridden below.
"ClassExpression": true,
"FunctionDeclaration": true,
"FunctionExpression": true,
"MethodDefinition": false // Overridden below.
},
"checkConstructors": false,
"checkGetters": true,
"checkSetters": true,
"contexts": [
"MethodDefinition:not([key.name=/(ngAfterContentChecked|ngAfterContentInit|ngAfterViewChecked|ngAfterViewInit|ngDoBootstrap|ngDoCheck|ngOnChanges|ngOnDestroy|ngOnInit)/])", // Exclude Angular methods.
"ClassDeclaration:not([id.name=/.*(Component|Module)/])", // Exclude Angular components.
"TSInterfaceDeclaration", // Include interfaces.
"TSEnumDeclaration", // Include enums.
"ClassProperty:has(Decorator[expression.callee.name=\"Input\"])"
]
}
]
}
} Tested with latest versions of all ESLint related packages. Except TypeScript, which is pinned on v4.0.5, because of Angular. Inputexport class MyComponentComponent {
@Output()
public changed = new EventEmitter();
public test = 'test';
@Input()
public value = new EventEmitter();
} ResultIt now throws warnings on all properties, once it matches with one decorator that is In the screenshot above you can see that it also shows an warning for the It doesn't matter if I put NotesIt also highlights another issue: the warning doesn't stop at the end of the property. Again you can see the warning underline and gradient doesn't stop at the end of the property. This configuration is part of getting JSDoc to work for Angular project. If you are interested I can post the whole config. |
It turns out the problem is that ESLint's selectors are not as expressive as esquery's current ones, so despite a couple tests using
In the meantime, you might be able to get away with this approach:
The reason for steps 1 and 2 is that our built-in var foo = { [function() {}]: 1 }; ...whereas the built-in one ignores them in such a context. May be a bug or a feature anyways. |
…te differential behavior of selectors; gajus#662 `:has()` is a selector only available to esquery, not to the current selector engine in ESLint.
FWIW, ESLint 7.20.0 has now fixed support for |
How can I make the rule
jsdoc/require-jsdoc
work with properties that have a specific decorator/annotation in TypeScript?Configuration: https://repl.it/@jerone/eslint-jsdoc-requiredoc-decorator#.eslintrc.json
The text was updated successfully, but these errors were encountered: