From 39876afbf38a640257178a1758518fded3951a68 Mon Sep 17 00:00:00 2001 From: Victorien Elvinger Date: Wed, 7 Dec 2022 23:05:55 +0100 Subject: [PATCH] docs(noConstructorReturn): fix rule description Fixes: #4005 --- .../src/analyzers/nursery/no_constructor_return.rs | 7 +++++-- crates/rome_service/src/configuration/linter/rules.rs | 2 +- editors/vscode/configuration_schema.json | 2 +- npm/backend-jsonrpc/src/workspace.ts | 2 +- npm/rome/configuration_schema.json | 2 +- website/src/pages/lint/rules/index.mdx | 2 +- website/src/pages/lint/rules/noConstructorReturn.md | 7 +++++-- 7 files changed, 15 insertions(+), 9 deletions(-) diff --git a/crates/rome_js_analyze/src/analyzers/nursery/no_constructor_return.rs b/crates/rome_js_analyze/src/analyzers/nursery/no_constructor_return.rs index bcb1765d7bd..7d272bc7e6b 100644 --- a/crates/rome_js_analyze/src/analyzers/nursery/no_constructor_return.rs +++ b/crates/rome_js_analyze/src/analyzers/nursery/no_constructor_return.rs @@ -7,12 +7,15 @@ use rome_rowan::AstNode; use crate::control_flow::AnyJsControlFlowRoot; declare_rule! { - /// Disallow returning a value from a constructor + /// Disallow returning a value from a `constructor`. /// - /// While returning a value from a constructor does not produce an error, the returned value is being ignored. Therefore, returning a value from a constructor is either unnecessary or a possible error. + /// Returning a value from a `constructor` of a class is a possible error. + /// Forbidding this pattern prevents errors resulting from unfamiliarity with JavaScript or a copy-paste error. /// /// Only returning without a value is allowed, as it’s a control flow statement. /// + /// Source: https://eslint.org/docs/latest/rules/no-constructor-return + /// /// ## Examples /// /// ### Invalid diff --git a/crates/rome_service/src/configuration/linter/rules.rs b/crates/rome_service/src/configuration/linter/rules.rs index 3143f77f005..ea7dcf4d273 100644 --- a/crates/rome_service/src/configuration/linter/rules.rs +++ b/crates/rome_service/src/configuration/linter/rules.rs @@ -731,7 +731,7 @@ struct NurserySchema { no_conditional_assignment: Option, #[doc = "Disallow TypeScript const enum"] no_const_enum: Option, - #[doc = "Disallow returning a value from a constructor"] + #[doc = "Disallow returning a value from a constructor."] no_constructor_return: Option, #[doc = "Enforces that no distracting elements are used."] no_distracting_elements: Option, diff --git a/editors/vscode/configuration_schema.json b/editors/vscode/configuration_schema.json index 9184638d564..646e4a1f07c 100644 --- a/editors/vscode/configuration_schema.json +++ b/editors/vscode/configuration_schema.json @@ -622,7 +622,7 @@ ] }, "noConstructorReturn": { - "description": "Disallow returning a value from a constructor", + "description": "Disallow returning a value from a constructor.", "anyOf": [ { "$ref": "#/definitions/RuleConfiguration" diff --git a/npm/backend-jsonrpc/src/workspace.ts b/npm/backend-jsonrpc/src/workspace.ts index 4d37342c610..8956e17006f 100644 --- a/npm/backend-jsonrpc/src/workspace.ts +++ b/npm/backend-jsonrpc/src/workspace.ts @@ -302,7 +302,7 @@ export interface Nursery { */ noConstEnum?: RuleConfiguration; /** - * Disallow returning a value from a constructor + * Disallow returning a value from a constructor. */ noConstructorReturn?: RuleConfiguration; /** diff --git a/npm/rome/configuration_schema.json b/npm/rome/configuration_schema.json index 9184638d564..646e4a1f07c 100644 --- a/npm/rome/configuration_schema.json +++ b/npm/rome/configuration_schema.json @@ -622,7 +622,7 @@ ] }, "noConstructorReturn": { - "description": "Disallow returning a value from a constructor", + "description": "Disallow returning a value from a constructor.", "anyOf": [ { "$ref": "#/definitions/RuleConfiguration" diff --git a/website/src/pages/lint/rules/index.mdx b/website/src/pages/lint/rules/index.mdx index c32c1b95559..f1a0ecff493 100644 --- a/website/src/pages/lint/rules/index.mdx +++ b/website/src/pages/lint/rules/index.mdx @@ -501,7 +501,7 @@ Disallow TypeScript const enum

noConstructorReturn

-Disallow returning a value from a constructor +Disallow returning a value from a constructor.

diff --git a/website/src/pages/lint/rules/noConstructorReturn.md b/website/src/pages/lint/rules/noConstructorReturn.md index aa98fc84dc9..41a8f98efe4 100644 --- a/website/src/pages/lint/rules/noConstructorReturn.md +++ b/website/src/pages/lint/rules/noConstructorReturn.md @@ -5,12 +5,15 @@ parent: lint/rules/index # noConstructorReturn (since v11.0.0) -Disallow returning a value from a constructor +Disallow returning a value from a `constructor`. -While returning a value from a constructor does not produce an error, the returned value is being ignored. Therefore, returning a value from a constructor is either unnecessary or a possible error. +Returning a value from a `constructor` of a class is a possible error. +Forbidding this pattern prevents errors resulting from unfamiliarity with JavaScript or a copy-paste error. Only returning without a value is allowed, as it’s a control flow statement. +Source: https://eslint.org/docs/latest/rules/no-constructor-return + ## Examples ### Invalid