-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Add eslint-plugin-jsdoc for better JSDoc linting #16869
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -73,30 +73,6 @@ module.exports = { | |
'!': true, | ||
}, | ||
} ], | ||
'valid-jsdoc': [ 'error', { | ||
prefer: { | ||
arg: 'param', | ||
argument: 'param', | ||
extends: 'augments', | ||
returns: 'return', | ||
}, | ||
preferType: { | ||
array: 'Array', | ||
bool: 'boolean', | ||
Boolean: 'boolean', | ||
float: 'number', | ||
Float: 'number', | ||
int: 'number', | ||
integer: 'number', | ||
Integer: 'number', | ||
Number: 'number', | ||
object: 'Object', | ||
String: 'string', | ||
Void: 'void', | ||
}, | ||
requireParamDescription: false, | ||
requireReturn: false, | ||
} ], | ||
'valid-typeof': 'error', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does it mean that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Correct. If that's the intention also, you'd have to have es5.js Good catch. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Based on the previous implementation and knowing that sometimes we want to explicitly use ES5 I guess you are all correct. |
||
'vars-on-top': 'error', | ||
'wrap-iife': 'error', | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
const globals = require( 'globals' ); | ||
|
||
module.exports = { | ||
extends: [ | ||
'plugin:jsdoc/recommended', | ||
], | ||
settings: { | ||
jsdoc: { | ||
preferredTypes: { | ||
object: 'Object', | ||
}, | ||
tagNamePreference: { | ||
returns: 'return', | ||
yields: 'yield', | ||
}, | ||
}, | ||
}, | ||
rules: { | ||
'jsdoc/no-undefined-types': [ 'warning', { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there any desire or intention to eventually increase this severity to "error" ? I understand there's a number of existing issues which would need to be resolved first, but my experience with "warning" is that they're often overlooked (in many cases by lack of installed tooling on the part of new contributors) and that the number of issues present can still trend upward. (Noting this also applies to every rule defined in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I brought the number to 0 last week, it's up to 2 now. We should enforce the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For tracking, I created an issue at #18458 |
||
// Required to reference browser types because we don't have the `browser` environment enabled for the project. | ||
// Here we filter out all browser globals that don't begin with an uppercase letter because those | ||
// generally refer to window-level event listeners and are not a valid type to reference (e.g. `onclick`). | ||
definedTypes: Object.keys( globals.browser ).filter( ( k ) => /^[A-Z]/.test( k ) ), | ||
} ], | ||
'jsdoc/require-jsdoc': 'off', | ||
'jsdoc/require-param-description': 'off', | ||
'jsdoc/require-returns': 'off', | ||
}, | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did we lose most of these preferred types and tags with the transition? I only see "Object" type being enforced in the current configuration, and
return
andyield
tags:gutenberg/packages/eslint-plugin/configs/jsdoc.js
Lines 72 to 78 in da54d11
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This something I did?
I may have deleted those that were set to the default value. Hindsight, that may have been wrong because doing that may have loosened the enforcement.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, I guess it may work just as well still. I haven't tested all of the previous values, but I do see a warning (as expected) when trying to capitalize a
{String}
type.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://github.com/gajus/eslint-plugin-jsdoc#default-preferred-aliases