Skip to content

Commit

Permalink
refactor(lint/useGetterReturn): improve rule docs (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
Conaclos authored Aug 22, 2023
1 parent 0b5a3fd commit 653f942
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 13 deletions.
17 changes: 13 additions & 4 deletions crates/rome_js_analyze/src/analyzers/nursery/use_getter_return.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@ use rome_rowan::{AstNode, NodeOrToken, TextRange};
use rustc_hash::FxHashSet;

declare_rule! {
/// Enforces the presence of non-empty `return` statements in getters.
///
/// A _getter_ allows defining a property which is dynamically computed.
/// Thus, it is desirable that a _getter_ returns a value.
/// Enforce `get` methods to always return a value.
///
/// Source: https://eslint.org/docs/latest/rules/getter-return
///
Expand All @@ -32,6 +29,18 @@ declare_rule! {
/// }
/// ```
///
/// ```js,expect_diagnostic
/// class Option {
/// get value() {
/// if (this.hasValue) {
/// log();
/// } else {
/// return null;
/// }
/// },
/// }
/// ```
///
/// ## Valid
///
/// ```js
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 packages/@biomejs/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 packages/@biomejs/biome/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 @@ -1081,7 +1081,7 @@ Enforce all dependencies are correctly specified.
<h3 data-toc-exclude id="useGetterReturn">
<a href="/lint/rules/useGetterReturn">useGetterReturn</a>
</h3>
Enforces the presence of non-empty <code>return</code> statements in getters.
Enforce <code>get</code> methods to always return a value.
</section>
<section class="rule">
<h3 data-toc-exclude id="useGroupedTypeImport">
Expand Down
39 changes: 35 additions & 4 deletions website/src/pages/lint/rules/useGetterReturn.md

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

0 comments on commit 653f942

Please sign in to comment.