+
Skip to content
This repository was archived by the owner on Aug 31, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion crates/rome_service/src/configuration/linter/rules.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion editors/vscode/configuration_schema.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion npm/backend-jsonrpc/src/workspace.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion npm/rome/configuration_schema.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion website/src/pages/lint/rules/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ Disallow TypeScript <code>const enum</code>
<h3 data-toc-exclude id="noConstructorReturn">
<a href="/lint/rules/noConstructorReturn">noConstructorReturn</a>
</h3>
Disallow returning a value from a constructor
Disallow returning a value from a <code>constructor</code>.
</section>
<section class="rule">
<h3 data-toc-exclude id="noDistractingElements">
Expand Down
7 changes: 5 additions & 2 deletions website/src/pages/lint/rules/noConstructorReturn.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载