Skip to content

Commit 89d728e

Browse files
committed
docs: modify some docs
1 parent 6eb5172 commit 89d728e

File tree

3 files changed

+14
-59
lines changed

3 files changed

+14
-59
lines changed

.changeset/mighty-regions-begin.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
---
44

55
Added the rule [noExcessiveLinesPerFunction](https://biomejs.dev/linter/rules/no-excessive-lines-per-function/).
6-
This rule restrict a maximum number of lines of code in a function.
6+
This rule restrict a maximum number of lines of code in a function body.
77

8-
The following code is now reported as invalid when the limit of maximum lines is set to 4:
8+
The following code is now reported as invalid when the limit of maximum lines is set to 2:
99

1010
```js
1111
function foo() {
@@ -15,7 +15,7 @@ function foo() {
1515
}
1616
```
1717

18-
The following code is now reported as valid when the limit of maximum lines is set to 4:
18+
The following code is now reported as valid when the limit of maximum lines is set to 3:
1919

2020
```jsx
2121
const bar = () => {

crates/biome_cli/src/execute/migrate/eslint_any_rule_to_biome.rs

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/biome_js_analyze/src/lint/nursery/no_excessive_lines_per_function.rs

Lines changed: 7 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -16,80 +16,31 @@ use std::num::NonZeroU8;
1616
declare_lint_rule! {
1717
/// Restrict the number of lines of code in a function.
1818
///
19-
/// This rule checks the number of lines in a function body and reports a diagnostic if it exceeds a specified limit.
19+
/// This rule checks the number of lines in a function body and reports a diagnostic if it exceeds a specified limit. Remember that this rule only counts the lines of code in the function body, not the entire function declaration.
2020
/// Some people consider large functions a code smell. Large functions tend to do a lot of things and can make it hard following what’s going on. Many coding style guides dictate a limit of the number of lines that a function can comprise of. This rule can help enforce that style.
2121
///
2222
/// ## Examples
2323
///
24-
/// When maximum number of lines is set to `2` with the following option, the following code will be considered invalid:
25-
/// ```json,options
26-
/// {
27-
/// "options": {
28-
/// "maxLines": 2
29-
/// }
30-
/// }
31-
/// ```
32-
///
3324
/// ### Invalid
3425
///
35-
/// ```js,expect_diagnostic,use_options
36-
/// function foo () {
37-
/// const x = 0;
38-
/// const y = 1;
39-
/// const z = 2;
40-
/// };
41-
/// ```
26+
/// The following example will show diagnostic when you set the maxLines limit to 3, however the default value is 50.
4227
///
43-
/// ```js,expect_diagnostic,use_options
44-
/// const bar = () => {
28+
/// ```js
29+
/// function foo () {
4530
/// const x = 0;
4631
/// const y = 1;
4732
/// const z = 2;
33+
/// return x + y + z;
4834
/// };
4935
/// ```
5036
///
51-
/// ```js,expect_diagnostic,use_options
52-
/// class Baz {
53-
/// foo() {
54-
/// const x = 0;
55-
/// const y = 0;
56-
/// const z = 2;
57-
/// };
58-
/// };
59-
/// ```
60-
///
61-
/// ```js,expect_diagnostic,use_options
62-
/// (() => {
63-
/// const x = 0;
64-
/// const y = 0;
65-
/// const z = 0;
66-
/// })();
67-
/// ```
68-
///
6937
/// ### Valid
7038
///
71-
/// ```js,use_options
39+
/// ```js
7240
/// function foo () {
7341
/// const x = 0;
7442
/// const y = 1;
7543
/// };
76-
///
77-
/// const bar = () => {
78-
/// const x = 0;
79-
/// const y = 1;
80-
/// };
81-
///
82-
/// class Baz {
83-
/// foo() {
84-
/// const x = 0;
85-
/// const y = 0;
86-
/// };
87-
/// };
88-
///
89-
/// (() => {
90-
/// const x = 0;
91-
/// const y = 0;
92-
/// })();
9344
/// ```
9445
///
9546
/// ## Options
@@ -181,7 +132,7 @@ declare_lint_rule! {
181132
language: "js",
182133
recommended: false,
183134
sources: &[RuleSource::Eslint("max-lines-per-function")],
184-
source_kind: RuleSourceKind::SameLogic,
135+
source_kind: RuleSourceKind::Inspired,
185136
}
186137
}
187138

0 commit comments

Comments
 (0)