From 04f51c96c8c2f8adf41b0f6c5256b7aa1a363989 Mon Sep 17 00:00:00 2001 From: Karl Horky Date: Wed, 6 Aug 2025 11:08:58 +0200 Subject: [PATCH 01/12] Ignore `eslint-disable-next-line` + `eslint-disable-line` line comments --- core/Parsers.fs | 8 ++++++++ core/Parsing.Documents.fs | 7 +++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/core/Parsers.fs b/core/Parsers.fs index 79e6d25e..44b6a1bd 100644 --- a/core/Parsers.fs +++ b/core/Parsers.fs @@ -35,6 +35,14 @@ let dartdoc : ContentParser -> ContentParser = let dartdoc_markdown ctx = dartdoc markdown_noHeader ctx +/// ESLint configuration comments parser that prevents wrapping of eslint-disable lines +/// https://github.com/dnut/Rewrap/issues/33 +let eslintConfigComments : ContentParser -> ContentParser = + fun content ctx line -> + if isMatch (regex @"^\s*//\s*eslint-(disable|enable)") line then + finished_ line noWrapBlock + else content ctx line + let ignoreAll ctx = Parsing_Internal.ignoreAll ctx let godoc : ContentParser = fun _ctx -> diff --git a/core/Parsing.Documents.fs b/core/Parsing.Documents.fs index 63805909..76ab80be 100644 --- a/core/Parsing.Documents.fs +++ b/core/Parsing.Documents.fs @@ -46,6 +46,9 @@ let private configFile = sc [line "#"] let java : DocumentProcessor = sc [ jsDocBlock; cBlock; line' "//[/!]" jsdoc_markdown; line "//" ] +let javascript : DocumentProcessor = + sc [ jsDocBlock; cBlock; line' "//[/!]" (eslintConfigComments jsdoc_markdown); line "//" ] + // Takes 4 args to create a Language: // 1. display name (used only in VS) // 2. string of aliases (language IDs used by the client. Not needed if they only differ @@ -129,7 +132,7 @@ let mutable languages = [ lang "INI" "" ".ini" <| sc [line "[#;]"] lang "J" "" ".ijs" <| sc [line @"NB\."] lang "Java" "" ".java" java - lang "JavaScript" "javascriptreact|js" ".js|.jsx" java + lang "JavaScript" "javascriptreact|js" ".js|.jsx" javascript lang "Julia" "" ".jl" <| sc [block ("#=", "=#"); line "#"; block (@".*?""""""", "\"\"\"")] lang "JSON" "json5|jsonc" ".json|.json5|.jsonc" java lang "LaTeX" "tex" ".bbx|.cbx|.cls|.sty|.tex" @@ -182,7 +185,7 @@ let mutable languages = [ lang "Tcl" "" ".tcl" <| configFile lang "Textile" "" ".textile" <| docOf markdown lang "TOML" "" ".toml" <| configFile - lang "TypeScript" "typescriptreact" ".ts|.tsx" java + lang "TypeScript" "typescriptreact" ".ts|.tsx" javascript lang "Verilog/SystemVerilog" "systemverilog|verilog" ".sv|.svh|.v|.vh|.vl" java lang "XAML" "" ".xaml" html From c2dc3d9546ec3805e376992f815024e3a671a49f Mon Sep 17 00:00:00 2001 From: Karl Horky Date: Wed, 6 Aug 2025 11:19:46 +0200 Subject: [PATCH 02/12] Ignore only the line disables --- core/Parsers.fs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/Parsers.fs b/core/Parsers.fs index 44b6a1bd..e74fae1b 100644 --- a/core/Parsers.fs +++ b/core/Parsers.fs @@ -39,7 +39,7 @@ let dartdoc_markdown ctx = dartdoc markdown_noHeader ctx /// https://github.com/dnut/Rewrap/issues/33 let eslintConfigComments : ContentParser -> ContentParser = fun content ctx line -> - if isMatch (regex @"^\s*//\s*eslint-(disable|enable)") line then + if isMatch (regex @"^\s*//\s*eslint-(disable-next-line|disable-line)") line then finished_ line noWrapBlock else content ctx line From 38659ff22319adb781f52e3ed8a9f770b61a29a8 Mon Sep 17 00:00:00 2001 From: Karl Horky Date: Wed, 6 Aug 2025 11:34:39 +0200 Subject: [PATCH 03/12] Fix indentation --- core/Parsers.fs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/Parsers.fs b/core/Parsers.fs index e74fae1b..615cf249 100644 --- a/core/Parsers.fs +++ b/core/Parsers.fs @@ -39,9 +39,9 @@ let dartdoc_markdown ctx = dartdoc markdown_noHeader ctx /// https://github.com/dnut/Rewrap/issues/33 let eslintConfigComments : ContentParser -> ContentParser = fun content ctx line -> - if isMatch (regex @"^\s*//\s*eslint-(disable-next-line|disable-line)") line then - finished_ line noWrapBlock - else content ctx line + if isMatch (regex @"^\s*//\s*eslint-(disable-next-line|disable-line)") line then + finished_ line noWrapBlock + else content ctx line let ignoreAll ctx = Parsing_Internal.ignoreAll ctx From 81edd6abba6dbcc62a4d7a695c3deeb529620fea Mon Sep 17 00:00:00 2001 From: Karl Horky Date: Wed, 6 Aug 2025 11:47:04 +0200 Subject: [PATCH 04/12] Switch to single compilation of regex --- core/Parsers.fs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/core/Parsers.fs b/core/Parsers.fs index 615cf249..5a3fa3a9 100644 --- a/core/Parsers.fs +++ b/core/Parsers.fs @@ -38,10 +38,15 @@ let dartdoc_markdown ctx = dartdoc markdown_noHeader ctx /// ESLint configuration comments parser that prevents wrapping of eslint-disable lines /// https://github.com/dnut/Rewrap/issues/33 let eslintConfigComments : ContentParser -> ContentParser = - fun content ctx line -> - if isMatch (regex @"^\s*//\s*eslint-(disable-next-line|disable-line)") line then + fun content ctx -> + + let rx = regex @"^\s*//\s*eslint-(disable-next-line|disable-line)" + + fun line -> + if isMatch rx line then finished_ line noWrapBlock - else content ctx line + else + content ctx line let ignoreAll ctx = Parsing_Internal.ignoreAll ctx From 3a50118bdcb499aac1011385425105f3f5245a28 Mon Sep 17 00:00:00 2001 From: Drew Nutter Date: Tue, 24 Feb 2026 20:28:27 -0700 Subject: [PATCH 05/12] fix(Parsers): redundant // in js regex --- core/Parsers.fs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/Parsers.fs b/core/Parsers.fs index 5a3fa3a9..90aef352 100644 --- a/core/Parsers.fs +++ b/core/Parsers.fs @@ -40,7 +40,7 @@ let dartdoc_markdown ctx = dartdoc markdown_noHeader ctx let eslintConfigComments : ContentParser -> ContentParser = fun content ctx -> - let rx = regex @"^\s*//\s*eslint-(disable-next-line|disable-line)" + let rx = regex @"^\s*eslint-(disable-next-line|disable-line)" fun line -> if isMatch rx line then From f7800d5a0088602c65199d27e2fd50570a25d0b3 Mon Sep 17 00:00:00 2001 From: Drew Nutter Date: Tue, 24 Feb 2026 20:29:02 -0700 Subject: [PATCH 06/12] fix(Parsing.Documents): eslint only applied to special comments /// and //! not // --- core/Parsing.Documents.fs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/Parsing.Documents.fs b/core/Parsing.Documents.fs index 76ab80be..a1191134 100644 --- a/core/Parsing.Documents.fs +++ b/core/Parsing.Documents.fs @@ -47,7 +47,7 @@ let java : DocumentProcessor = sc [ jsDocBlock; cBlock; line' "//[/!]" jsdoc_markdown; line "//" ] let javascript : DocumentProcessor = - sc [ jsDocBlock; cBlock; line' "//[/!]" (eslintConfigComments jsdoc_markdown); line "//" ] + sc [ jsDocBlock; cBlock; line' "//[/!]" (eslintConfigComments jsdoc_markdown); line' "//" (eslintConfigComments markdown) ] // Takes 4 args to create a Language: // 1. display name (used only in VS) From c82b6dd92badef1c1c6dbfbea83e5ae2fccab937 Mon Sep 17 00:00:00 2001 From: Karl Horky Date: Wed, 25 Feb 2026 13:58:50 +0100 Subject: [PATCH 07/12] Add tests --- docs/specs/features/line-comments.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/docs/specs/features/line-comments.md b/docs/specs/features/line-comments.md index e35cda65..e7e41709 100644 --- a/docs/specs/features/line-comments.md +++ b/docs/specs/features/line-comments.md @@ -92,3 +92,20 @@ All blank lines are trimmed at the end. (This is true of all non-wrapping lines) //·· ¦ -> // ¦ -or- // ¦ //···· ¦ // ¦ // ¦ + +## ESLint directive comments + +ESLint line directives in JavaScript/TypeScript must stay on a single line to keep their +effect. + +> language: javascript + + // eslint-disable-next-line @typescript-eslint/no-base-to-string -- ModuleSource returns useful information from .toString() + nextLoad(url).source ¦ -> // eslint-disable-next-line @typescript-eslint/no-base-to-string -- ModuleSource returns useful information from .toString() + nextLoad(url).source nextLoad(url).source ¦ + +> language: typescript + + // eslint-disable-line @typescript-eslint/no-base-to-string -- ModuleSource returns useful information from .toString() + nextLoad(url).source ¦ -> // eslint-disable-line @typescript-eslint/no-base-to-string -- ModuleSource returns useful information from .toString() + nextLoad(url).source nextLoad(url).source ¦ From 22cc3eadfdf09cdf3be412be153f878b0f8ac185 Mon Sep 17 00:00:00 2001 From: Karl Horky Date: Wed, 25 Feb 2026 14:40:08 +0100 Subject: [PATCH 08/12] Ignore eslint-disable and eslint-enable in JS/TS block comments --- core/Parsers.fs | 4 ++-- core/Parsing.Documents.fs | 8 +++++++- docs/specs/features/block-comments.md | 15 +++++++++++++++ docs/specs/features/line-comments.md | 8 ++++++++ 4 files changed, 32 insertions(+), 3 deletions(-) diff --git a/core/Parsers.fs b/core/Parsers.fs index 90aef352..bd1c6869 100644 --- a/core/Parsers.fs +++ b/core/Parsers.fs @@ -35,12 +35,12 @@ let dartdoc : ContentParser -> ContentParser = let dartdoc_markdown ctx = dartdoc markdown_noHeader ctx -/// ESLint configuration comments parser that prevents wrapping of eslint-disable lines +/// ESLint configuration comments parser that prevents wrapping of disable/enable lines /// https://github.com/dnut/Rewrap/issues/33 let eslintConfigComments : ContentParser -> ContentParser = fun content ctx -> - let rx = regex @"^\s*eslint-(disable-next-line|disable-line)" + let rx = regex @"^\s*eslint-(disable(?:-(?:next-line|line))?|enable)\b" fun line -> if isMatch rx line then diff --git a/core/Parsing.Documents.fs b/core/Parsing.Documents.fs index a1191134..c7e0efcd 100644 --- a/core/Parsing.Documents.fs +++ b/core/Parsing.Documents.fs @@ -46,8 +46,14 @@ let private configFile = sc [line "#"] let java : DocumentProcessor = sc [ jsDocBlock; cBlock; line' "//[/!]" jsdoc_markdown; line "//" ] +let private cBlockWithEslint = + block' ("*", "") (@"/\*", @"\*/") (eslintConfigComments markdown) + +let private jsDocBlockWithEslint = + block' ("*", " * ") javadocMarkers (eslintConfigComments jsdoc_markdown) + let javascript : DocumentProcessor = - sc [ jsDocBlock; cBlock; line' "//[/!]" (eslintConfigComments jsdoc_markdown); line' "//" (eslintConfigComments markdown) ] + sc [ jsDocBlockWithEslint; cBlockWithEslint; line' "//[/!]" (eslintConfigComments jsdoc_markdown); line' "//" (eslintConfigComments markdown) ] // Takes 4 args to create a Language: // 1. display name (used only in VS) diff --git a/docs/specs/features/block-comments.md b/docs/specs/features/block-comments.md index 16c43c60..61bdf8a0 100644 --- a/docs/specs/features/block-comments.md +++ b/docs/specs/features/block-comments.md @@ -81,3 +81,18 @@ used for created lines. ··/** Foo bar¦baz */ -> ··/** Foo bar¦ ¦ * baz */ ¦ + +## ESLint directive comments + +ESLint disable/enable directives in JavaScript/TypeScript block comments should remain +single-line when wrapping comments. + +> language: javascript + + /* eslint-disable no-console, @typescript-eslint/no-base-to-string -- temporary exception for migration script with long explanation that should stay intact on one line */ + nextLoad(url).source ¦ -> /* eslint-disable no-console, @typescript-eslint/no-base-to-string -- temporary exception for migration script with long explanation that should stay intact on one line */ + nextLoad(url).source nextLoad(url).source ¦ + + /* eslint-enable no-console, @typescript-eslint/no-base-to-string -- restore lint checks after migration script with long explanation that should stay intact on one line */ + nextLoad(url).source ¦ -> /* eslint-enable no-console, @typescript-eslint/no-base-to-string -- restore lint checks after migration script with long explanation that should stay intact on one line */ + nextLoad(url).source nextLoad(url).source ¦ diff --git a/docs/specs/features/line-comments.md b/docs/specs/features/line-comments.md index e7e41709..af000f96 100644 --- a/docs/specs/features/line-comments.md +++ b/docs/specs/features/line-comments.md @@ -109,3 +109,11 @@ effect. // eslint-disable-line @typescript-eslint/no-base-to-string -- ModuleSource returns useful information from .toString() nextLoad(url).source ¦ -> // eslint-disable-line @typescript-eslint/no-base-to-string -- ModuleSource returns useful information from .toString() nextLoad(url).source nextLoad(url).source ¦ + + // eslint-disable no-console, @typescript-eslint/no-base-to-string -- temporary exception for migration script + nextLoad(url).source ¦ -> // eslint-disable no-console, @typescript-eslint/no-base-to-string -- temporary exception for migration script + nextLoad(url).source nextLoad(url).source ¦ + + // eslint-enable no-console, @typescript-eslint/no-base-to-string -- restore lint checks after migration script + nextLoad(url).source ¦ -> // eslint-enable no-console, @typescript-eslint/no-base-to-string -- restore lint checks after migration script + nextLoad(url).source nextLoad(url).source ¦ From b0083ba87e3ace2caf64e821da16dcbcb953962e Mon Sep 17 00:00:00 2001 From: Karl Horky Date: Wed, 25 Feb 2026 15:03:36 +0100 Subject: [PATCH 09/12] Simplify legibility of regex --- core/Parsers.fs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/Parsers.fs b/core/Parsers.fs index bd1c6869..e14679a8 100644 --- a/core/Parsers.fs +++ b/core/Parsers.fs @@ -40,7 +40,7 @@ let dartdoc_markdown ctx = dartdoc markdown_noHeader ctx let eslintConfigComments : ContentParser -> ContentParser = fun content ctx -> - let rx = regex @"^\s*eslint-(disable(?:-(?:next-line|line))?|enable)\b" + let rx = regex @"^\s*(eslint-disable-next-line|eslint-disable-line|eslint-disable|eslint-enable)\b" fun line -> if isMatch rx line then From 4f911cabdb3ef7f1d80b91e203d70510d619f0bf Mon Sep 17 00:00:00 2001 From: Karl Horky Date: Fri, 22 May 2026 16:19:37 +0200 Subject: [PATCH 10/12] Fix ESLint directive spec columns --- docs/specs/features/block-comments.md | 10 ++++------ docs/specs/features/line-comments.md | 20 ++++++++------------ 2 files changed, 12 insertions(+), 18 deletions(-) diff --git a/docs/specs/features/block-comments.md b/docs/specs/features/block-comments.md index 61bdf8a0..d435c085 100644 --- a/docs/specs/features/block-comments.md +++ b/docs/specs/features/block-comments.md @@ -89,10 +89,8 @@ single-line when wrapping comments. > language: javascript - /* eslint-disable no-console, @typescript-eslint/no-base-to-string -- temporary exception for migration script with long explanation that should stay intact on one line */ - nextLoad(url).source ¦ -> /* eslint-disable no-console, @typescript-eslint/no-base-to-string -- temporary exception for migration script with long explanation that should stay intact on one line */ - nextLoad(url).source nextLoad(url).source ¦ + /* eslint-disable no-console, @typescript-eslint/no-base-to-string -- temporary exception for migration script with long explanation that should stay intact on one line */ -> /* eslint-disable no-console, @typescript-eslint/no-base-to-string -- temporary exception for migration script with long explanation that should stay intact on one line */ + nextLoad(url).source ¦ nextLoad(url).source ¦ - /* eslint-enable no-console, @typescript-eslint/no-base-to-string -- restore lint checks after migration script with long explanation that should stay intact on one line */ - nextLoad(url).source ¦ -> /* eslint-enable no-console, @typescript-eslint/no-base-to-string -- restore lint checks after migration script with long explanation that should stay intact on one line */ - nextLoad(url).source nextLoad(url).source ¦ + /* eslint-enable no-console, @typescript-eslint/no-base-to-string -- restore lint checks after migration script with long explanation that should stay intact on one line */ -> /* eslint-enable no-console, @typescript-eslint/no-base-to-string -- restore lint checks after migration script with long explanation that should stay intact on one line */ + nextLoad(url).source ¦ nextLoad(url).source ¦ diff --git a/docs/specs/features/line-comments.md b/docs/specs/features/line-comments.md index af000f96..24bb28c3 100644 --- a/docs/specs/features/line-comments.md +++ b/docs/specs/features/line-comments.md @@ -100,20 +100,16 @@ effect. > language: javascript - // eslint-disable-next-line @typescript-eslint/no-base-to-string -- ModuleSource returns useful information from .toString() - nextLoad(url).source ¦ -> // eslint-disable-next-line @typescript-eslint/no-base-to-string -- ModuleSource returns useful information from .toString() - nextLoad(url).source nextLoad(url).source ¦ + // eslint-disable-next-line @typescript-eslint/no-base-to-string -- ModuleSource returns useful information from .toString() -> // eslint-disable-next-line @typescript-eslint/no-base-to-string -- ModuleSource returns useful information from .toString() + nextLoad(url).source ¦ nextLoad(url).source ¦ > language: typescript - // eslint-disable-line @typescript-eslint/no-base-to-string -- ModuleSource returns useful information from .toString() - nextLoad(url).source ¦ -> // eslint-disable-line @typescript-eslint/no-base-to-string -- ModuleSource returns useful information from .toString() - nextLoad(url).source nextLoad(url).source ¦ + // eslint-disable-line @typescript-eslint/no-base-to-string -- ModuleSource returns useful information from .toString() -> // eslint-disable-line @typescript-eslint/no-base-to-string -- ModuleSource returns useful information from .toString() + nextLoad(url).source ¦ nextLoad(url).source ¦ - // eslint-disable no-console, @typescript-eslint/no-base-to-string -- temporary exception for migration script - nextLoad(url).source ¦ -> // eslint-disable no-console, @typescript-eslint/no-base-to-string -- temporary exception for migration script - nextLoad(url).source nextLoad(url).source ¦ + // eslint-disable no-console, @typescript-eslint/no-base-to-string -- temporary exception for migration script -> // eslint-disable no-console, @typescript-eslint/no-base-to-string -- temporary exception for migration script + nextLoad(url).source ¦ nextLoad(url).source ¦ - // eslint-enable no-console, @typescript-eslint/no-base-to-string -- restore lint checks after migration script - nextLoad(url).source ¦ -> // eslint-enable no-console, @typescript-eslint/no-base-to-string -- restore lint checks after migration script - nextLoad(url).source nextLoad(url).source ¦ + // eslint-enable no-console, @typescript-eslint/no-base-to-string -- restore lint checks after migration script -> // eslint-enable no-console, @typescript-eslint/no-base-to-string -- restore lint checks after migration script + nextLoad(url).source ¦ nextLoad(url).source ¦ From 485d28aa948fc2ec293c8700bcfc029fcafc3dc6 Mon Sep 17 00:00:00 2001 From: Karl Horky Date: Fri, 22 May 2026 16:33:43 +0200 Subject: [PATCH 11/12] Detect ESLint directives after comment text --- core/Parsers.fs | 27 +++++++++++++++++++++------ docs/specs/features/block-comments.md | 6 ++++++ docs/specs/features/line-comments.md | 4 ++++ 3 files changed, 31 insertions(+), 6 deletions(-) diff --git a/core/Parsers.fs b/core/Parsers.fs index e14679a8..5dabf592 100644 --- a/core/Parsers.fs +++ b/core/Parsers.fs @@ -40,13 +40,28 @@ let dartdoc_markdown ctx = dartdoc markdown_noHeader ctx let eslintConfigComments : ContentParser -> ContentParser = fun content ctx -> - let rx = regex @"^\s*(eslint-disable-next-line|eslint-disable-line|eslint-disable|eslint-enable)\b" - - fun line -> - if isMatch rx line then + let tryMatchDirective : Line -> Option = + tryMatch' (regex @"^\s*(eslint-disable-next-line|eslint-disable-line|eslint-disable|eslint-enable)\b") <>>> fun (_, line) -> finished_ line noWrapBlock - else - content ctx line + + let rec wrapFLR : FirstLineRes -> FirstLineRes = function + | Pending r -> Pending ^| wrapResultParser nlpWrapper r + | Finished r -> Finished ^| wrapResultParser (fun p -> Some (flpWrapper p)) r + + and flpWrapper maybeInnerParser : FirstLineParser = + (tryMatchDirective |? (maybeInnerParser |? content ctx)) >> wrapFLR + + and nlpWrapper innerParser : NextLineParser = + fun line -> + tryMatchDirective line + |> map (FinishedOnPrev << Some) + |> Option.defaultWith ^| fun _ -> + match innerParser line with + | ThisLine r -> ThisLine (wrapFLR r) + | FinishedOnPrev maybeR -> + FinishedOnPrev (wrapFLR <<|> (maybeR <|> (fun _ -> Some (content ctx line)))) + + (tryMatchDirective |? content ctx) >> wrapFLR let ignoreAll ctx = Parsing_Internal.ignoreAll ctx diff --git a/docs/specs/features/block-comments.md b/docs/specs/features/block-comments.md index d435c085..c27ee7fb 100644 --- a/docs/specs/features/block-comments.md +++ b/docs/specs/features/block-comments.md @@ -94,3 +94,9 @@ single-line when wrapping comments. /* eslint-enable no-console, @typescript-eslint/no-base-to-string -- restore lint checks after migration script with long explanation that should stay intact on one line */ -> /* eslint-enable no-console, @typescript-eslint/no-base-to-string -- restore lint checks after migration script with long explanation that should stay intact on one line */ nextLoad(url).source ¦ nextLoad(url).source ¦ + + /* -> /* + * Some comment text * Some comment text + * eslint-disable no-console -- more comment text * eslint-disable no-console -- more comment text + */ */ + nextLoad(url).source ¦ nextLoad(url).source ¦ diff --git a/docs/specs/features/line-comments.md b/docs/specs/features/line-comments.md index 24bb28c3..eaba741c 100644 --- a/docs/specs/features/line-comments.md +++ b/docs/specs/features/line-comments.md @@ -113,3 +113,7 @@ effect. // eslint-enable no-console, @typescript-eslint/no-base-to-string -- restore lint checks after migration script -> // eslint-enable no-console, @typescript-eslint/no-base-to-string -- restore lint checks after migration script nextLoad(url).source ¦ nextLoad(url).source ¦ + + // Some comment text -> // Some comment text + // eslint-disable-next-line @typescript-eslint/no-base-to-string -- more comment text // eslint-disable-next-line @typescript-eslint/no-base-to-string -- more comment text + nextLoad(url).source ¦ nextLoad(url).source ¦ From c47291b3b259c49e3b07671f62784f59b381dced Mon Sep 17 00:00:00 2001 From: Drew Nutter Date: Sat, 23 May 2026 14:02:11 -0400 Subject: [PATCH 12/12] fix: eslint tests, and move to own file for content type --- docs/specs/content-types/eslint.md | 44 +++++++++++++++++++++++++++ docs/specs/features/block-comments.md | 19 ------------ docs/specs/features/line-comments.md | 25 --------------- mkdocs.yml | 1 + 4 files changed, 45 insertions(+), 44 deletions(-) create mode 100644 docs/specs/content-types/eslint.md diff --git a/docs/specs/content-types/eslint.md b/docs/specs/content-types/eslint.md new file mode 100644 index 00000000..2479c8ac --- /dev/null +++ b/docs/specs/content-types/eslint.md @@ -0,0 +1,44 @@ +# ESLint Directives + +JavaScript and TypeScript ESLint directives must remain on a single line to preserve their +effect, so Rewrap does not wrap them. + + +## Line Comments + +> language: javascript + + // eslint-disable-next-line @typescript-eslint/no-base-to-string -- ModuleSource returns -> // eslint-disable-next-line @typescript-eslint/no-base-to-string -- ModuleSource returns + nextLoad(url).source ¦ nextLoad(url).source ¦ + +> language: typescript + + // eslint-disable-line @typescript-eslint/no-base-to-string -- ModuleSource returns -> // eslint-disable-line @typescript-eslint/no-base-to-string -- ModuleSource returns + nextLoad(url).source ¦ nextLoad(url).source ¦ + + // eslint-disable no-console, @typescript-eslint/no-base-to-string -- temporary exception -> // eslint-disable no-console, @typescript-eslint/no-base-to-string -- temporary exception + nextLoad(url).source ¦ nextLoad(url).source ¦ + + // eslint-enable no-console, @typescript-eslint/no-base-to-string -- restore lint checks -> // eslint-enable no-console, @typescript-eslint/no-base-to-string -- restore lint checks + nextLoad(url).source ¦ nextLoad(url).source ¦ + + // Some comment text ¦ -> // Some comment text ¦ + // eslint-disable-next-line @typescript-eslint/no-base-to-string -- more comment text // eslint-disable-next-line @typescript-eslint/no-base-to-string -- more comment text + nextLoad(url).source ¦ nextLoad(url).source ¦ + + +## Block Comments + +> language: javascript + + /* eslint-disable no-console, @typescript-eslint/no-base-to-string -- temporary exception */ -> /* eslint-disable no-console, @typescript-eslint/no-base-to-string -- temporary exception */ + nextLoad(url).source ¦ nextLoad(url).source ¦ + + /* eslint-enable no-console, @typescript-eslint/no-base-to-string -- restore lint checks */ -> /* eslint-enable no-console, @typescript-eslint/no-base-to-string -- restore lint checks */ + nextLoad(url).source ¦ nextLoad(url).source ¦ + + /* ¦ -> /* ¦ + * Some comment text ¦ * Some comment text ¦ + * eslint-disable no-console -- more comment text * eslint-disable no-console -- more comment text + */ ¦ */ ¦ + nextLoad(url).source ¦ nextLoad(url).source ¦ diff --git a/docs/specs/features/block-comments.md b/docs/specs/features/block-comments.md index c27ee7fb..16c43c60 100644 --- a/docs/specs/features/block-comments.md +++ b/docs/specs/features/block-comments.md @@ -81,22 +81,3 @@ used for created lines. ··/** Foo bar¦baz */ -> ··/** Foo bar¦ ¦ * baz */ ¦ - -## ESLint directive comments - -ESLint disable/enable directives in JavaScript/TypeScript block comments should remain -single-line when wrapping comments. - -> language: javascript - - /* eslint-disable no-console, @typescript-eslint/no-base-to-string -- temporary exception for migration script with long explanation that should stay intact on one line */ -> /* eslint-disable no-console, @typescript-eslint/no-base-to-string -- temporary exception for migration script with long explanation that should stay intact on one line */ - nextLoad(url).source ¦ nextLoad(url).source ¦ - - /* eslint-enable no-console, @typescript-eslint/no-base-to-string -- restore lint checks after migration script with long explanation that should stay intact on one line */ -> /* eslint-enable no-console, @typescript-eslint/no-base-to-string -- restore lint checks after migration script with long explanation that should stay intact on one line */ - nextLoad(url).source ¦ nextLoad(url).source ¦ - - /* -> /* - * Some comment text * Some comment text - * eslint-disable no-console -- more comment text * eslint-disable no-console -- more comment text - */ */ - nextLoad(url).source ¦ nextLoad(url).source ¦ diff --git a/docs/specs/features/line-comments.md b/docs/specs/features/line-comments.md index eaba741c..e35cda65 100644 --- a/docs/specs/features/line-comments.md +++ b/docs/specs/features/line-comments.md @@ -92,28 +92,3 @@ All blank lines are trimmed at the end. (This is true of all non-wrapping lines) //·· ¦ -> // ¦ -or- // ¦ //···· ¦ // ¦ // ¦ - -## ESLint directive comments - -ESLint line directives in JavaScript/TypeScript must stay on a single line to keep their -effect. - -> language: javascript - - // eslint-disable-next-line @typescript-eslint/no-base-to-string -- ModuleSource returns useful information from .toString() -> // eslint-disable-next-line @typescript-eslint/no-base-to-string -- ModuleSource returns useful information from .toString() - nextLoad(url).source ¦ nextLoad(url).source ¦ - -> language: typescript - - // eslint-disable-line @typescript-eslint/no-base-to-string -- ModuleSource returns useful information from .toString() -> // eslint-disable-line @typescript-eslint/no-base-to-string -- ModuleSource returns useful information from .toString() - nextLoad(url).source ¦ nextLoad(url).source ¦ - - // eslint-disable no-console, @typescript-eslint/no-base-to-string -- temporary exception for migration script -> // eslint-disable no-console, @typescript-eslint/no-base-to-string -- temporary exception for migration script - nextLoad(url).source ¦ nextLoad(url).source ¦ - - // eslint-enable no-console, @typescript-eslint/no-base-to-string -- restore lint checks after migration script -> // eslint-enable no-console, @typescript-eslint/no-base-to-string -- restore lint checks after migration script - nextLoad(url).source ¦ nextLoad(url).source ¦ - - // Some comment text -> // Some comment text - // eslint-disable-next-line @typescript-eslint/no-base-to-string -- more comment text // eslint-disable-next-line @typescript-eslint/no-base-to-string -- more comment text - nextLoad(url).source ¦ nextLoad(url).source ¦ diff --git a/mkdocs.yml b/mkdocs.yml index 280971e7..e9388309 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -68,6 +68,7 @@ nav: - specs/content-types/dart.md - specs/content-types/doxygen.md - specs/content-types/elixir.md + - specs/content-types/eslint.md - specs/content-types/go.md - specs/content-types/graphql.md - specs/content-types/html.md