-
Notifications
You must be signed in to change notification settings - Fork 19
Loosen JSDoc rules #433
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
base: main
Are you sure you want to change the base?
Loosen JSDoc rules #433
Changes from all commits
85a02f6
59a95d9
75c9356
19b7bdb
09f7e4d
58469e5
bc6ebec
86d7dd8
ec0cee3
bd1d326
140fdf5
f63d09e
d64d667
c0189d5
da3f03d
597f56c
8b75032
b702649
5b07ebc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,6 +7,72 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 | |
|
|
||
| ## [Unreleased] | ||
|
|
||
| ### Changed | ||
|
|
||
| - Update `jsdoc/require-jsdoc` to loosen requirements for various kinds of symbols ([#433](https://github.com/MetaMask/eslint-config/pull/433)) | ||
|
|
||
| - JSDoc is no longer required for arrow functions or function expressions which are values of object properties: | ||
|
|
||
| ```typescript | ||
| const foo = { | ||
| // This arrow function is no longer required to be documented | ||
| bar: () => { | ||
| // ... | ||
| }, | ||
| }; | ||
|
|
||
| const foo = { | ||
| // This function expression is no longer required to be documented | ||
| bar: function () { | ||
| // ... | ||
| }, | ||
| }; | ||
| ``` | ||
|
|
||
| - JSDoc is no longer required for arrow functions or function expressions which are arguments to functions or methods: | ||
|
|
||
| ```typescript | ||
| // This arrow function is no longer required to be documented | ||
| foo(() => { | ||
| // ... | ||
| }); | ||
|
|
||
| // This function expression is no longer required to be documented | ||
| foo(function () { | ||
| // ... | ||
| }); | ||
| ``` | ||
|
|
||
| - JSDoc is no longer required for interfaces, type aliases, or enums that appear in `declare` blocks (even if they are exported): | ||
|
|
||
| ```typescript | ||
| declare module "some-module" { | ||
| // This type is no longer required to be documented | ||
| type Bar = "baz"; | ||
|
|
||
| // This interface is no longer required to be documented, even though it | ||
| // is exported | ||
| export interface Y { | ||
| // ... | ||
| } | ||
|
|
||
| // This enum is no longer required to be documented | ||
| enum Fooz { | ||
| Bar = "baz", | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| - JSDoc is no longer required for inline object types in return types: | ||
| ```typescript | ||
| // This object type is no longer required to be documented | ||
| function foo(): { | ||
| bar: "baz"; | ||
| } { | ||
| // ... | ||
| } | ||
| ``` | ||
|
|
||
| ## [15.0.0] | ||
|
|
||
| ### Changed | ||
|
|
@@ -17,6 +83,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 | |
| - **BREAKING:** Update type import specifier rules ([#381](https://github.com/MetaMask/eslint-config/pull/381)) | ||
| - `@typescript-eslint/consistent-type-imports` has been replaced with `import-x/consistent-type-specifier-style` | ||
| - The rule now prefers "top-level" type imports over inline. e.g. `import type { a } from 'x'` over `import { type a } from 'x'` | ||
| - **BREAKING:** Update `jsdoc/require-jsdoc` to require documentation for more things ([#394](https://github.com/MetaMask/eslint-config/pull/394)) | ||
|
Contributor
Author
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. This changelog entry was missing when 15.0.0 was released. This should list TypeScript symbols for which documentation is required (not the changelog for the base config). |
||
| - New things that now require documentation are: | ||
| - Arrow functions | ||
| - Class declarations | ||
| - Function expressions | ||
| - Method definitions | ||
| - TypeScript enum declarations | ||
| - TypeScript interface declarations | ||
| - TypeScript type alias declarations | ||
| - TypeScript property signatures | ||
| - Disable `@typescript-eslint/no-unnecessary-type-arguments` ([#426](https://github.com/MetaMask/eslint-config/pull/426)) | ||
| - We decided that "unnecessary" type arguments make types easier to read sometimes, so we should allow them. | ||
| - Disable `promise/valid-params` because it's redundant in type-checked projects ([#425](https://github.com/MetaMask/eslint-config/pull/425)) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -190,7 +190,25 @@ | |
| "jsdoc/require-example": "off", | ||
| "jsdoc/require-file-overview": "off", | ||
| "jsdoc/require-hyphen-before-param-description": "off", | ||
| "jsdoc/require-jsdoc": "error", | ||
|
Contributor
Author
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. Hmm... this might be a breaking change. It seems that the I'll have to double-check this.
Member
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. Yeah, so it was. It was overwritten by That's fine, we can include this in v16 instead then
Member
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. Actually we still need a changelog update to reflect this |
||
| "jsdoc/require-jsdoc": [ | ||
| "error", | ||
| { | ||
| "require": { | ||
| "ClassDeclaration": true, | ||
| "FunctionDeclaration": true, | ||
| "MethodDefinition": true | ||
| }, | ||
| "contexts": [ | ||
| ":not(Property, NewExpression, CallExpression) > ArrowFunctionExpression", | ||
| ":not(Property, NewExpression, CallExpression) > FunctionExpression", | ||
| ":not(TSModuleBlock, TSModuleBlock > ExportNamedDeclaration) > TSInterfaceDeclaration", | ||
| ":not(TSModuleBlock, TSModuleBlock > ExportNamedDeclaration) > TSTypeAliasDeclaration", | ||
| ":not(TSModuleBlock, TSModuleBlock > ExportNamedDeclaration) > TSEnumDeclaration", | ||
| "TSInterfaceDeclaration TSPropertySignature", | ||
| "TSTypeAliasDeclaration TSPropertySignature" | ||
| ] | ||
| } | ||
| ], | ||
| "jsdoc/require-param": "error", | ||
| "jsdoc/require-param-description": "error", | ||
| "jsdoc/require-param-name": "error", | ||
|
|
||
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.
While it's true that the base config did apparently require JSDoc for TypeScript symbols, that wasn't true in practice because the JSDoc plugin within the base config doesn't know about TypeScript.