feat(linter): eslint/max-len (#2874)

Co-authored-by: Wang Wenzhe <mysteryven@gmail.com>
This commit is contained in:
谭光志 2024-04-19 12:35:37 +08:00 committed by GitHub
parent 3f9f4670e2
commit 9b4e87a102
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 1473 additions and 0 deletions

View file

@ -45,6 +45,7 @@ mod eslint {
pub mod for_direction;
pub mod getter_return;
pub mod guard_for_in;
pub mod max_len;
pub mod max_lines;
pub mod max_params;
pub mod no_array_constructor;
@ -390,6 +391,7 @@ oxc_macros::declare_all_lint_rules! {
eslint::for_direction,
eslint::getter_return,
eslint::guard_for_in,
eslint::max_len,
eslint::max_lines,
eslint::max_params,
eslint::no_ternary,

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,458 @@
---
source: crates/oxc_linter/src/tester.rs
expression: max_len
---
⚠ This line has a length of 86. Maximum allowed is 80.
╭─[max_len.tsx:1:1]
1 │ var i = 1;
· ──────────────────────────────────────────────────────────────────────────────────────
╰────
help: Consider breaking this line into multiple lines or shortening comments/codes where applicable
⚠ This line has a length of 24. Maximum allowed is 10.
╭─[max_len.tsx:1:1]
1 │ var x = 5, y = 2, z = 5;
· ────────────────────────
╰────
help: Consider breaking this line into multiple lines or shortening comments/codes where applicable
⚠ This line has a length of 22. Maximum allowed is 15.
╭─[max_len.tsx:1:1]
1 │ var i = 1;
· ──────────────────────
╰────
help: Consider breaking this line into multiple lines or shortening comments/codes where applicable
⚠ This line has a length of 22. Maximum allowed is 15.
╭─[max_len.tsx:1:1]
1 │ var i = 1;
· ──────────────────────
2 │ var j = 1;
╰────
help: Consider breaking this line into multiple lines or shortening comments/codes where applicable
⚠ This line has a length of 22. Maximum allowed is 15.
╭─[max_len.tsx:2:1]
1 │ var i = 1;
2 │ var j = 1;
· ──────────────────────
╰────
help: Consider breaking this line into multiple lines or shortening comments/codes where applicable
⚠ This line has a length of 56. Maximum allowed is 20.
╭─[max_len.tsx:1:1]
1 │ var /*this is a long non-removed inline comment*/ i = 1;
· ────────────────────────────────────────────────────────
╰────
help: Consider breaking this line into multiple lines or shortening comments/codes where applicable
⚠ This line has a length of 54. Maximum allowed is 20.
╭─[max_len.tsx:1:1]
1 │ var foobar = 'this line isn\'t matched by the regexp';
· ──────────────────────────────────────────────────────
2 │ var fizzbuzz = 'but this one is matched by the regexp';
╰────
help: Consider breaking this line into multiple lines or shortening comments/codes where applicable
⚠ This line has a length of 30. Maximum allowed is 10.
╭─[max_len.tsx:1:1]
1 │ var longLine = 'will trigger'; // even with a comment
· ─────────────────────────────────────────────────────
╰────
help: Consider breaking this line into multiple lines or shortening comments/codes where applicable
⚠ This line has a length of 62. Maximum allowed is 40.
╭─[max_len.tsx:1:1]
1 │ var foo = module.exports = {}; // really long trailing comment
· ──────────────────────────────────────────────────────────────
╰────
help: Consider breaking this line into multiple lines or shortening comments/codes where applicable
⚠ This line has a length of 57. Maximum allowed is 40.
╭─[max_len.tsx:1:1]
1 │ foo('http://example.com/this/is/?a=longish&url=in#here');
· ─────────────────────────────────────────────────────────
╰────
help: Consider breaking this line into multiple lines or shortening comments/codes where applicable
⚠ This line has a length of 53. Maximum allowed is 40.
╭─[max_len.tsx:1:1]
1 │ foo(bar(bazz('this is a long'), 'line of'), 'stuff');
· ─────────────────────────────────────────────────────
╰────
help: Consider breaking this line into multiple lines or shortening comments/codes where applicable
⚠ This line has a comment length of 49. Maximum allowed is 20.
╭─[max_len.tsx:1:1]
1 │ // A comment that exceeds the max comment length.
· ─────────────────────────────────────────────────
╰────
help: Consider breaking this line into multiple lines or shortening comments/codes where applicable
⚠ This line has a comment length of 119. Maximum allowed is 80.
╭─[max_len.tsx:1:1]
1 │ // A comment that exceeds the max comment length and the max code length, but will fail for being too long of a comment
· ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
╰────
help: Consider breaking this line into multiple lines or shortening comments/codes where applicable
⚠ This line has a length of 49. Maximum allowed is 20.
╭─[max_len.tsx:1:1]
1 │ // A comment that exceeds the max comment length.
· ─────────────────────────────────────────────────
╰────
help: Consider breaking this line into multiple lines or shortening comments/codes where applicable
⚠ This line has a length of 73. Maximum allowed is 40.
╭─[max_len.tsx:1:1]
1 │ //This is very long comment with more than 40 characters which is invalid
· ─────────────────────────────────────────────────────────────────────────
╰────
help: Consider breaking this line into multiple lines or shortening comments/codes where applicable
⚠ This line has a comment length of 29. Maximum allowed is 28.
╭─[max_len.tsx:2:1]
1 │ function foo() {
2 │ //this line has 29 characters
· ─────────────────────────────
3 │ }
╰────
help: Consider breaking this line into multiple lines or shortening comments/codes where applicable
⚠ This line has a comment length of 33. Maximum allowed is 32.
╭─[max_len.tsx:2:1]
1 │ function foo() {
2 │ //this line has 33 characters
· ─────────────────────────────────
3 │ }
╰────
help: Consider breaking this line into multiple lines or shortening comments/codes where applicable
⚠ This line has a comment length of 29. Maximum allowed is 28.
╭─[max_len.tsx:2:1]
1 │ function foo() {
2 │ /*this line has 29 characters
· ─────────────────────────────
3 │ and this one has 32 characters*/
╰────
help: Consider breaking this line into multiple lines or shortening comments/codes where applicable
⚠ This line has a comment length of 32. Maximum allowed is 28.
╭─[max_len.tsx:3:1]
2 │ /*this line has 29 characters
3 │ and this one has 32 characters*/
· ────────────────────────────────
4 │ }
╰────
help: Consider breaking this line into multiple lines or shortening comments/codes where applicable
⚠ This line has a comment length of 33. Maximum allowed is 32.
╭─[max_len.tsx:2:1]
1 │ function foo() {
2 │ /*this line has 33 characters
· ─────────────────────────────────
3 │ and this one has 36 characters*/
╰────
help: Consider breaking this line into multiple lines or shortening comments/codes where applicable
⚠ This line has a comment length of 36. Maximum allowed is 32.
╭─[max_len.tsx:3:1]
2 │ /*this line has 33 characters
3 │ and this one has 36 characters*/
· ────────────────────────────────────
4 │ }
╰────
help: Consider breaking this line into multiple lines or shortening comments/codes where applicable
⚠ This line has a length of 40. Maximum allowed is 39.
╭─[max_len.tsx:2:1]
1 │ function foo() {
2 │ var a; /*this line has 40 characters
· ────────────────────────────────────────
3 │ and this one has 36 characters*/
╰────
help: Consider breaking this line into multiple lines or shortening comments/codes where applicable
⚠ This line has a comment length of 36. Maximum allowed is 35.
╭─[max_len.tsx:3:1]
2 │ var a; /*this line has 40 characters
3 │ and this one has 36 characters*/
· ────────────────────────────────────
4 │ }
╰────
help: Consider breaking this line into multiple lines or shortening comments/codes where applicable
⚠ This line has a comment length of 33. Maximum allowed is 32.
╭─[max_len.tsx:2:1]
1 │ function foo() {
2 │ /*this line has 33 characters
· ─────────────────────────────────
3 │ and this one has 43 characters*/ var a;
╰────
help: Consider breaking this line into multiple lines or shortening comments/codes where applicable
⚠ This line has a length of 43. Maximum allowed is 42.
╭─[max_len.tsx:3:1]
2 │ /*this line has 33 characters
3 │ and this one has 43 characters*/ var a;
· ───────────────────────────────────────────
4 │ }
╰────
help: Consider breaking this line into multiple lines or shortening comments/codes where applicable
⚠ This line has a length of 51. Maximum allowed is 20.
╭─[max_len.tsx:2:1]
1 │ // This commented line has precisely 51 characters.
2 │ var x = 'This line also has exactly 51 characters';
· ───────────────────────────────────────────────────
╰────
help: Consider breaking this line into multiple lines or shortening comments/codes where applicable
⚠ This line has a length of 39. Maximum allowed is 29.
╭─[max_len.tsx:2:1]
1 │ var foo = veryLongIdentifier;
2 │ var bar = 'this is a very long string';
· ───────────────────────────────────────
╰────
help: Consider breaking this line into multiple lines or shortening comments/codes where applicable
⚠ This line has a length of 45. Maximum allowed is 29.
╭─[max_len.tsx:2:1]
1 │ var foo = veryLongIdentifier;
2 │ var bar = /this is a very very long pattern/;
· ─────────────────────────────────────────────
╰────
help: Consider breaking this line into multiple lines or shortening comments/codes where applicable
⚠ This line has a length of 57. Maximum allowed is 29.
╭─[max_len.tsx:2:1]
1 │ var foo = veryLongIdentifier;
2 │ var bar = new RegExp('this is a very very long pattern');
· ─────────────────────────────────────────────────────────
╰────
help: Consider breaking this line into multiple lines or shortening comments/codes where applicable
⚠ This line has a length of 39. Maximum allowed is 29.
╭─[max_len.tsx:2:1]
1 │ var foo = veryLongIdentifier;
2 │ var bar = "this is a very long string";
· ───────────────────────────────────────
╰────
help: Consider breaking this line into multiple lines or shortening comments/codes where applicable
⚠ This line has a length of 39. Maximum allowed is 29.
╭─[max_len.tsx:2:1]
1 │ var foo = veryLongIdentifier;
2 │ var bar = `this is a very long string`;
· ───────────────────────────────────────
╰────
help: Consider breaking this line into multiple lines or shortening comments/codes where applicable
⚠ This line has a length of 37. Maximum allowed is 29.
╭─[max_len.tsx:2:1]
1 │ var foo = veryLongIdentifier;
2 │ var bar = `this is a very long string
· ─────────────────────────────────────
3 │ and this is another line that is very long`;
╰────
help: Consider breaking this line into multiple lines or shortening comments/codes where applicable
⚠ This line has a length of 44. Maximum allowed is 29.
╭─[max_len.tsx:3:1]
2 │ var bar = `this is a very long string
3 │ and this is another line that is very long`;
· ────────────────────────────────────────────
╰────
help: Consider breaking this line into multiple lines or shortening comments/codes where applicable
⚠ This line has a length of 58. Maximum allowed is 29.
╭─[max_len.tsx:1:1]
1 │ var foo = <div>this is a very very very long string</div>;
· ──────────────────────────────────────────────────────────
╰────
help: Consider breaking this line into multiple lines or shortening comments/codes where applicable
⚠ This line has a length of 12. Maximum allowed is 10.
╭─[max_len.tsx:1:1]
1 │ '🙁😁😟☹️😣😖😩😱👎'
· ───────────────────
╰────
help: Consider breaking this line into multiple lines or shortening comments/codes where applicable
⚠ This line has a length of 1. Maximum allowed is 0.
╭─[max_len.tsx:1:1]
1 │ a
· ─
╰────
help: Consider breaking this line into multiple lines or shortening comments/codes where applicable
⚠ This line has a comment length of 38. Maximum allowed is 37.
╭─[max_len.tsx:2:1]
1 │ var jsx = (<>
2 │ { /* this line has 38 characters */}
· ──────────────────────────────────────
3 │ </>)
╰────
help: Consider breaking this line into multiple lines or shortening comments/codes where applicable
⚠ This line has a comment length of 44. Maximum allowed is 40.
╭─[max_len.tsx:2:1]
1 │ var jsx = (<>
2 │ { /* this line has 40 characters */}
· ────────────────────────────────────────────
3 │ </>)
╰────
help: Consider breaking this line into multiple lines or shortening comments/codes where applicable
⚠ This line has a length of 38. Maximum allowed is 15.
╭─[max_len.tsx:2:1]
1 │ var jsx = (<>
2 │ { 38/* this line has 38 characters */}
· ──────────────────────────────────────
3 │ </>)
╰────
help: Consider breaking this line into multiple lines or shortening comments/codes where applicable
⚠ This line has a length of 38. Maximum allowed is 37.
╭─[max_len.tsx:2:1]
1 │ var jsx = (<>
2 │ { 38/* this line has 38 characters */}
· ──────────────────────────────────────
3 │ </>)
╰────
help: Consider breaking this line into multiple lines or shortening comments/codes where applicable
⚠ This line has a length of 38. Maximum allowed is 37.
╭─[max_len.tsx:2:1]
1 │ var jsx = (<>
2 │ { 38/* this line has 38 characters */}
· ──────────────────────────────────────
3 │ </>)
╰────
help: Consider breaking this line into multiple lines or shortening comments/codes where applicable
⚠ This line has a length of 50. Maximum allowed is 49.
╭─[max_len.tsx:2:1]
1 │ var jsx = (<>
2 │ <> 50 </>{ 50/* this line has 50 characters */}
· ──────────────────────────────────────────────────
3 │ </>)
╰────
help: Consider breaking this line into multiple lines or shortening comments/codes where applicable
⚠ This line has a length of 44. Maximum allowed is 37.
╭─[max_len.tsx:2:1]
1 │ var jsx = (<>
2 │ {/* this line has 44 characters */}
· ────────────────────────────────────────────
3 │ <> </> {/* this line has 44 characters */}
╰────
help: Consider breaking this line into multiple lines or shortening comments/codes where applicable
⚠ This line has a length of 57. Maximum allowed is 56.
╭─[max_len.tsx:2:1]
1 │ var jsx = <Foo
2 │ attr = {a && b/* this line has 57 characters */}
· ─────────────────────────────────────────────────────────
3 │ ></Foo>;
╰────
help: Consider breaking this line into multiple lines or shortening comments/codes where applicable
⚠ This line has a length of 57. Maximum allowed is 56.
╭─[max_len.tsx:2:1]
1 │ var jsx = <Foo
2 │ attr = {/* this line has 57 characters */a && b}
· ─────────────────────────────────────────────────────────
3 │ ></Foo>;
╰────
help: Consider breaking this line into multiple lines or shortening comments/codes where applicable
⚠ This line has a length of 56. Maximum allowed is 55.
╭─[max_len.tsx:2:1]
1 │ var jsx = <Foo
2 │ attr = {a & b/* this line has 56 characters */}
· ────────────────────────────────────────────────────────
3 │ ></Foo>;
╰────
help: Consider breaking this line into multiple lines or shortening comments/codes where applicable
⚠ This line has a length of 51. Maximum allowed is 30.
╭─[max_len.tsx:3:1]
2 │ attr =
3 │ {a & b /* this line has 51 characters */}
· ───────────────────────────────────────────────────
4 │ ></Foo>;
╰────
help: Consider breaking this line into multiple lines or shortening comments/codes where applicable
⚠ This line has a length of 80. Maximum allowed is 79.
╭─[max_len.tsx:3:1]
2 │ {/* this line has 37 characters */}
3 │ <> </> {/* this line with two separate comments */} {/* have 80 characters */}
· ────────────────────────────────────────────────────────────────────────────────
4 │ </>)
╰────
help: Consider breaking this line into multiple lines or shortening comments/codes where applicable
⚠ This line has a length of 87. Maximum allowed is 85.
╭─[max_len.tsx:2:1]
1 │ var jsx = (<>
2 │ <> </> {/* this line with two separate comments */} {/* have 87 characters */} <> </>
· ───────────────────────────────────────────────────────────────────────────────────────
3 │ </>)
╰────
help: Consider breaking this line into multiple lines or shortening comments/codes where applicable
⚠ This line has a length of 87. Maximum allowed is 37.
╭─[max_len.tsx:3:1]
2 │ {/* this line has 37 characters */}
3 │ <> </> {/* this line with two separate comments */} {/* have 87 characters */} <> </>
· ───────────────────────────────────────────────────────────────────────────────────────
4 │ </>)
╰────
help: Consider breaking this line into multiple lines or shortening comments/codes where applicable
⚠ This line has a length of 119. Maximum allowed is 37.
╭─[max_len.tsx:3:1]
2 │ {/* this line has 37 characters */}
3 │ <> </> {/* this line with two separate comments */} {/* have > 80 characters */ /* another comment in same braces */}
· ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
4 │ </>)
╰────
help: Consider breaking this line into multiple lines or shortening comments/codes where applicable
⚠ This line has a length of 55. Maximum allowed is 37.
╭─[max_len.tsx:3:1]
2 │ {/* this line has 37 characters */}
3 │ <> </> {/* this is not treated as a comment */ a & b} {/* trailing */ /* comments */}
· ───────────────────────────────────────────────────────────────────────────────────────
4 │ </>)
╰────
help: Consider breaking this line into multiple lines or shortening comments/codes where applicable
⚠ This line has a length of 55. Maximum allowed is 37.
╭─[max_len.tsx:3:1]
2 │ {/* this line has 37 characters */}
3 │ <> </> {/* this is not treated as a comment */ a & b} {/* trailing */ /* comments */}
· ───────────────────────────────────────────────────────────────────────────────────────
4 │ </>)
╰────
help: Consider breaking this line into multiple lines or shortening comments/codes where applicable
⚠ This line has a length of 15. Maximum allowed is 14.
╭─[max_len.tsx:2:1]
1 │ var jsx = (<>
2 │ 12345678901234{/*
· ─────────────────
3 │ */}
╰────
help: Consider breaking this line into multiple lines or shortening comments/codes where applicable
⚠ This line has a length of 31. Maximum allowed is 30.
╭─[max_len.tsx:3:1]
2 │ {/*
3 │ this line has 31 characters */}
· ───────────────────────────────
4 │ </>)
╰────
help: Consider breaking this line into multiple lines or shortening comments/codes where applicable