Skip to content

Commit 6c0f006

Browse files
docs(linter): improve the documentation of eslint/no-useless-concat (oxc-project#9179)
Relates to [oxc-project#6050](oxc-project#6050) Adds correctness and incorrectness examples following rule documentation template.
1 parent 22460a4 commit 6c0f006

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

crates/oxc_linter/src/rules/eslint/no_useless_concat.rs

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,31 @@ declare_oxc_lint!(
2525
///
2626
/// ### Why is this bad?
2727
///
28-
/// It’s unnecessary to concatenate two strings together.
28+
/// It’s unnecessary to concatenate two strings together when they could
29+
/// be combined into a single literal.
2930
///
30-
/// ### Example
31+
/// ### Examples
32+
///
33+
/// Examples of **incorrect** code for this rule:
3134
/// ```javascript
3235
/// var foo = "a" + "b";
3336
/// ```
37+
///
38+
/// ```javascript
39+
/// var foo = 'a' + 'b' + 'c';
40+
/// ```
41+
///
42+
/// Examples of **correct** code for this rule:
43+
/// ```javascript
44+
/// var foo = 'a' + bar;
45+
/// ```
46+
///
47+
/// // when the string concatenation is multiline
48+
/// ```javascript
49+
/// var foo = 'a'
50+
/// + 'b'
51+
/// + 'c';
52+
/// ```
3453
NoUselessConcat,
3554
eslint,
3655
suspicious

0 commit comments

Comments
 (0)