From d78d2681281eb2112c73e8d8969dcb188b7df2cd Mon Sep 17 00:00:00 2001 From: Dylan Piercey Date: Tue, 11 Aug 2026 14:27:41 -0700 Subject: [PATCH 1/2] feat: support async shorthand methods Thread the parser's new `async` flag through the AST and the script extractor, so the body of ` \ No newline at end of file diff --git a/packages/language-server/src/__tests__/fixtures/script/attr-method-async/__snapshots__/attr-method-async.expected/index.md b/packages/language-server/src/__tests__/fixtures/script/attr-method-async/__snapshots__/attr-method-async.expected/index.md new file mode 100644 index 00000000..e69de29b diff --git a/packages/language-server/src/__tests__/fixtures/script/attr-method-async/__snapshots__/attr-method-async.expected/index.ts b/packages/language-server/src/__tests__/fixtures/script/attr-method-async/__snapshots__/attr-method-async.expected/index.ts new file mode 100644 index 00000000..61a81f20 --- /dev/null +++ b/packages/language-server/src/__tests__/fixtures/script/attr-method-async/__snapshots__/attr-method-async.expected/index.ts @@ -0,0 +1,96 @@ +export interface Input {} +(function (this: void) { + const input = Marko._.any as Input; + const $signal = Marko._.any as AbortSignal; + const $global = Marko._.getGlobal( + // @ts-expect-error We expect the compiler to error because we are checking if the MarkoRun.Context is defined. + (Marko._.error, Marko._.any as MarkoRun.Context), + ); + const count = Marko._.hoist(() => __marko_internal_hoist__count); + const __marko_internal_tag_1 = Marko._.resolveTemplate( + import("@marko/runtime-tags/tags/let.d.marko"), + ); + { + const count = Marko._.returned(() => __marko_internal_rendered_1); + const __marko_internal_rendered_1 = Marko._.renderTemplate( + __marko_internal_tag_1, + )()()({ + value: 0, + }); + const __marko_internal_change__count = Marko._.change( + "count", + "value", + __marko_internal_rendered_1.return, + ); + Marko._.renderNativeTag("button")()()({ + async onClick() { + __marko_internal_change__count.count = await Promise.resolve(1); + }, + [Marko._.content]: (() => { + return () => { + return Marko._.voidReturn; + }; + })(), + }); + Marko._.renderNativeTag("button")()()({ + async onClick(event: T) { + __marko_internal_change__count.count = await Promise.resolve( + event.detail, + ); + }, + [Marko._.content]: (() => { + return () => { + return Marko._.voidReturn; + }; + })(), + }); + const __marko_internal_tag_2 = Marko._.resolveTemplate( + import("./components/my-tag.marko"), + ); + Marko._.renderTemplate(__marko_internal_tag_2)()()({ + async value(value: number) { + __marko_internal_change__count.count = await Promise.resolve(value); + }, + }); + var __marko_internal_hoist__count = count; + } + Marko._.noop({ count, input, $global, $signal }); + return; +})(); +const __marko_internal_api = "tags"; +export { __marko_internal_api as "~api" }; +export default new (class Template extends Marko._.Template<{ + render( + input: Marko.TemplateInput, + stream?: { + write: (chunk: string) => void; + end: (chunk?: string) => void; + }, + ): Marko.Out; + + render( + input: Marko.TemplateInput, + cb?: (err: Error | null, result: Marko.RenderResult) => void, + ): Marko.Out; + + renderSync(input: Marko.TemplateInput): Marko.RenderResult; + + renderToString(input: Marko.TemplateInput): string; + + stream( + input: Marko.TemplateInput, + ): ReadableStream & NodeJS.ReadableStream; + + mount( + input: Marko.TemplateInput, + reference: Node, + position?: "afterbegin" | "afterend" | "beforebegin" | "beforeend", + ): Marko.MountedTemplate; + + api: typeof __marko_internal_api; + _(): () => <__marko_internal_input extends unknown>( + input: Marko.Directives & + Input & + Marko._.Relate<__marko_internal_input, Marko.Directives & Input>, + ) => Marko._.ReturnWithScope<__marko_internal_input, void>; +}> {})(); diff --git a/packages/language-server/src/__tests__/fixtures/script/attr-method-async/components/my-tag.marko b/packages/language-server/src/__tests__/fixtures/script/attr-method-async/components/my-tag.marko new file mode 100644 index 00000000..55cf815f --- /dev/null +++ b/packages/language-server/src/__tests__/fixtures/script/attr-method-async/components/my-tag.marko @@ -0,0 +1,5 @@ +export interface Input { + value(v: number): Promise; +} + +
diff --git a/packages/language-server/src/__tests__/fixtures/script/attr-method-async/index.marko b/packages/language-server/src/__tests__/fixtures/script/attr-method-async/index.marko new file mode 100644 index 00000000..b8789dca --- /dev/null +++ b/packages/language-server/src/__tests__/fixtures/script/attr-method-async/index.marko @@ -0,0 +1,13 @@ + + + + + + + diff --git a/packages/language-tools/package.json b/packages/language-tools/package.json index 79103ed6..fb9485d9 100644 --- a/packages/language-tools/package.json +++ b/packages/language-tools/package.json @@ -39,7 +39,7 @@ "dependencies": { "@luxass/strip-json-comments": "^1.4.0", "@marko/compiler": "^5.41.7", - "htmljs-parser": "^5.12.1", + "htmljs-parser": "^5.14.0", "relative-import-path": "^1.0.1" }, "devDependencies": { diff --git a/packages/language-tools/src/extractors/script/index.ts b/packages/language-tools/src/extractors/script/index.ts index df9024dd..0ed56408 100644 --- a/packages/language-tools/src/extractors/script/index.ts +++ b/packages/language-tools/src/extractors/script/index.ts @@ -1055,6 +1055,7 @@ constructor(_) {} if (value) { switch (value.type) { case NodeType.AttrMethod: + if (value.async) this.#extractor.write("async "); this.#extractor .write('"') .anchor(defaultMapPosition) diff --git a/packages/language-tools/src/extractors/script/util/script-parser.ts b/packages/language-tools/src/extractors/script/util/script-parser.ts index 06d8e642..9b58c441 100644 --- a/packages/language-tools/src/extractors/script/util/script-parser.ts +++ b/packages/language-tools/src/extractors/script/util/script-parser.ts @@ -103,12 +103,14 @@ export class ScriptParser { } attrMethod(node: Node.AttrMethod): t.ObjectMethod | undefined { - const start = node.params.start - 2; + // Padded so that the params and body keep their source offsets. + const prefix = node.async ? "{async _" : "{_"; + const start = node.params.start - prefix.length; const expr = this.#cache.get(start) ?? this.#expressionAt( start, - `{_${this.#parsed.read({ start: node.params.start, end: node.body.end })}}`, + `${prefix}${this.#parsed.read({ start: node.params.start, end: node.body.end })}}`, ); if (expr) { return (expr as t.ObjectExpression).properties[0] as diff --git a/packages/language-tools/src/parser.ts b/packages/language-tools/src/parser.ts index 8d121e74..f9020f66 100644 --- a/packages/language-tools/src/parser.ts +++ b/packages/language-tools/src/parser.ts @@ -266,6 +266,7 @@ export namespace Node { typeParams: undefined | Ranges.Value; params: Range; body: Range; + async: boolean; } export interface AttrSpread extends Ranges.Value { @@ -764,6 +765,7 @@ class Builder { typeParams: range.typeParams, params: range.params, body: range.body, + async: range.async, start: range.start, end: range.end, }; diff --git a/packages/vscode/syntaxes/marko.tmLanguage.json b/packages/vscode/syntaxes/marko.tmLanguage.json index 5f41865c..c2c5df0c 100644 --- a/packages/vscode/syntaxes/marko.tmLanguage.json +++ b/packages/vscode/syntaxes/marko.tmLanguage.json @@ -83,6 +83,11 @@ "attrs": { "patterns": [ { "include": "#javascript-comments" }, + { + "comment": "The async modifier, which only applies when a method follows it", + "match": "\\basync(?=(?:[ \\t]+[a-zA-Z0-9_$][a-zA-Z0-9_$-]*|[ \\t]*)[ \\t]*(?:<[^<>]*>)?[ \\t]*\\([^()]*\\)[ \\t]*\\{)", + "name": "storage.modifier.async.marko" + }, { "comment": "Attribute with optional value", "name": "meta.marko-attribute", @@ -105,7 +110,7 @@ "name": "meta.marko-spread-attribute", "contentName": "source.ts", "begin": "(\\.\\.\\.)", - "end": "(?=[,;\\]]|/>|(?<=[^=>])>|(?+=-]=|[=>]>|[^.]\\.|[^-]-|[^+]\\+|[a-zA-Z0-9%).<\\]}]\\s/|[^.$\\w]await|[^.$\\w]async|[^.$\\w]class|[^.$\\w]function|[^.$\\w]keyof|[^.$\\w]new|[^.$\\w]readonly|[^.$\\w]infer|[^.$\\w]typeof|[^.$\\w]void)\\s+(?![\\n{(+!~*%&^|?:]|[<>/=-]=|[=>]>|\\.[^.]|-[^-]|/[^>]|(?:in|instanceof|satisfies|as|extends)\\s+[^:=/,;>]))", + "end": "(?=[,;\\]]|/>|(?<=[^=>])(?:(?|>(?!=))|(?+=-]=|[=>]>|[^.]\\.|[^-]-|[^+]\\+|[a-zA-Z0-9%).<\\]}]\\s/|[^.$\\w]await|[^.$\\w]async|[^.$\\w]class|[^.$\\w]function|[^.$\\w]keyof|[^.$\\w]new|[^.$\\w]readonly|[^.$\\w]infer|[^.$\\w]typeof|[^.$\\w]void)\\s+(?![\\n{(+!~*%&^|?:]|[<>/=-]=|[=>]>|\\.[^.]|-[^-]|/[^>]|(?:in|instanceof|satisfies|as|extends)\\s+[^:=/,;>]))", "patterns": [{ "include": "#javascript-expression" }], "beginCaptures": { "1": { "name": "keyword.operator.spread.marko" } } }, @@ -123,7 +128,7 @@ "name": "meta.embedded.ts", "contentName": "source.ts", "begin": "\\s*(:?=)\\s*", - "end": "(?=[,;\\]]|/>|(?<=[^=>])>|(?+=-]=|[=>]>|[^.]\\.|[^-]-|[^+]\\+|[a-zA-Z0-9%).<\\]}]\\s/|[^.$\\w]await|[^.$\\w]async|[^.$\\w]class|[^.$\\w]function|[^.$\\w]keyof|[^.$\\w]new|[^.$\\w]readonly|[^.$\\w]infer|[^.$\\w]typeof|[^.$\\w]void)\\s+(?![\\n{(+!~*%&^|?:]|[<>/=-]=|[=>]>|\\.[^.]|-[^-]|/[^>]|(?:in|instanceof|satisfies|as|extends)\\s+[^:=/,;>]))", + "end": "(?=[,;\\]]|/>|(?<=[^=>])(?:(?|>(?!=))|(?+=-]=|[=>]>|[^.]\\.|[^-]-|[^+]\\+|[a-zA-Z0-9%).<\\]}]\\s/|[^.$\\w]await|[^.$\\w]async|[^.$\\w]class|[^.$\\w]function|[^.$\\w]keyof|[^.$\\w]new|[^.$\\w]readonly|[^.$\\w]infer|[^.$\\w]typeof|[^.$\\w]void)\\s+(?![\\n{(+!~*%&^|?:]|[<>/=-]=|[=>]>|\\.[^.]|-[^-]|/[^>]|(?:in|instanceof|satisfies|as|extends)\\s+[^:=/,;>]))", "patterns": [{ "include": "#javascript-expression" }], "beginCaptures": { "1": { "patterns": [{ "include": "source.ts" }] } } }, @@ -758,7 +763,7 @@ { "comment": "Match type", "begin": "\\s*(:)(?!=)", - "end": "(?=[,;\\](]|/>|(?<=[^=>])>|(?+=-]=|[=>]>|[^.]\\.|[^-]-|[^+]\\+|[a-zA-Z0-9%).<\\]}]\\s/|[^.$\\w]await|[^.$\\w]async|[^.$\\w]class|[^.$\\w]function|[^.$\\w]keyof|[^.$\\w]new|[^.$\\w]readonly|[^.$\\w]infer|[^.$\\w]typeof|[^.$\\w]void)\\s+(?![\\n{+!~*%&^|?:]|[<>/=-]=|[=>]>|\\.[^.]|-[^-]|/[^>]|(?:in|instanceof|satisfies|as|extends)\\s+[^:=/,;>]))", + "end": "(?=[,;\\](]|/>|(?<=[^=>])(?:(?|>(?!=))|(?+=-]=|[=>]>|[^.]\\.|[^-]-|[^+]\\+|[a-zA-Z0-9%).<\\]}]\\s/|[^.$\\w]await|[^.$\\w]async|[^.$\\w]class|[^.$\\w]function|[^.$\\w]keyof|[^.$\\w]new|[^.$\\w]readonly|[^.$\\w]infer|[^.$\\w]typeof|[^.$\\w]void)\\s+(?![\\n{+!~*%&^|?:]|[<>/=-]=|[=>]>|\\.[^.]|-[^-]|/[^>]|(?:in|instanceof|satisfies|as|extends)\\s+[^:=/,;>]))", "patterns": [ { "include": "source.ts#type" }, { "include": "#javascript-expression" } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index f09b6f47..24a4ad3b 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -94,8 +94,8 @@ importers: specifier: ^4.12.1 version: 4.12.1 htmljs-parser: - specifier: ^5.12.1 - version: 5.12.1 + specifier: ^5.14.0 + version: 5.14.0 jsdom: specifier: ^29.1.1 version: 29.1.1(patch_hash=63260bcabe348afac2b14cafcd725106f132adbad0fab0328f16e5a9c6a1a1e4) @@ -143,8 +143,8 @@ importers: specifier: ^5.41.7 version: 5.41.7 htmljs-parser: - specifier: ^5.12.1 - version: 5.12.1 + specifier: ^5.14.0 + version: 5.14.0 relative-import-path: specifier: ^1.0.1 version: 1.0.1 @@ -2024,8 +2024,8 @@ packages: resolution: {integrity: sha512-CV9TW3Y3f8/wT0BRFc1/KAVQ3TUHiXmaAb6VW9vtiMFf7SLoMd1PdAc4W3KFOFETBJUb90KatHqlsZMWV+R9Gg==} engines: {node: ^20.19.0 || ^22.12.0 || >=24.0.0} - htmljs-parser@5.12.1: - resolution: {integrity: sha512-QnHLg5SWqoH5o8MD4iOWJFtdKSS2lXxtNgyznFXvEeeCK0CTi6URdYtFGkFGDANdq8RZzkuc91KaBgLx2WAhSA==} + htmljs-parser@5.14.0: + resolution: {integrity: sha512-cGHMvzufiWAcQl11UM8HwxxpFkVicgtJ5RniyFHTClT0WfwMWSxAc7QMAlqpKet+xTsrr7QOOeShOENBMvCPVg==} htmlparser2@10.1.0: resolution: {integrity: sha512-VTZkM9GWRAtEpveh7MSF6SjjrpNVNNVJfFup7xTY3UpFtm67foy9HDVXneLtFVt4pMz5kZtgNcvCniNFb1hlEQ==} @@ -3996,7 +3996,7 @@ snapshots: '@luxass/strip-json-comments': 2.0.1 complain: 1.6.1 he: 1.2.0 - htmljs-parser: 5.12.1 + htmljs-parser: 5.14.0 jsesc: 3.1.0 kleur: 4.1.5 lasso-package-root: 1.0.1 @@ -5273,7 +5273,7 @@ snapshots: transitivePeerDependencies: - '@noble/hashes' - htmljs-parser@5.12.1: {} + htmljs-parser@5.14.0: {} htmlparser2@10.1.0: dependencies: @@ -5916,7 +5916,7 @@ snapshots: prettier-plugin-marko@4.0.10: dependencies: - htmljs-parser: 5.12.1 + htmljs-parser: 5.14.0 prettier-plugin-packagejson@3.0.2(prettier@3.8.4): dependencies: From fe9b102db21ff55635e4173df99eefbde5255f8e Mon Sep 17 00:00:00 2001 From: Dylan Piercey Date: Tue, 11 Aug 2026 15:56:28 -0700 Subject: [PATCH 2/2] chore: update marko dependencies @marko/compiler 5.42 carries the async shorthand method support. The snapshot churn is its new deprecation diagnostic for the `` tag, which seven fixtures still use. --- packages/language-server/package.json | 4 +- .../abort-signal.expected/index.md | 39 ++ .../attr-tags-dynamic-for.expected/index.md | 514 +++++++++++++++++ .../attr-tags-dynamic-if.expected/index.md | 194 +++++++ .../attr-tags-static.expected/index.md | 48 ++ .../__snapshots__/for-tag.expected/index.md | 539 ++++++++++++++++++ .../index.md | 72 +++ .../simple-hoist.expected/index.md | 50 ++ packages/language-tools/package.json | 4 +- packages/ts-plugin/package.json | 2 +- packages/type-check/package.json | 2 +- pnpm-lock.yaml | 80 ++- 12 files changed, 1530 insertions(+), 18 deletions(-) diff --git a/packages/language-server/package.json b/packages/language-server/package.json index 9316ea82..f7c3ec2d 100644 --- a/packages/language-server/package.json +++ b/packages/language-server/package.json @@ -44,12 +44,12 @@ }, "dependencies": { "@luxass/strip-json-comments": "^1.4.0", - "@marko/compiler": "^5.41.7", + "@marko/compiler": "^5.42.0", "@marko/language-tools": "^2.6.8", "axe-core": "^4.12.1", "htmljs-parser": "^5.14.0", "jsdom": "^29.1.1", - "marko": "^5.39.27", + "marko": "^5.39.33", "prettier": "^3.8.4", "prettier-plugin-marko": "^4.0.10", "relative-import-path": "^1.0.1", diff --git a/packages/language-server/src/__tests__/fixtures/script/abort-signal/__snapshots__/abort-signal.expected/index.md b/packages/language-server/src/__tests__/fixtures/script/abort-signal/__snapshots__/abort-signal.expected/index.md index c8cdb24f..8250f1ad 100644 --- a/packages/language-server/src/__tests__/fixtures/script/abort-signal/__snapshots__/abort-signal.expected/index.md +++ b/packages/language-server/src/__tests__/fixtures/script/abort-signal/__snapshots__/abort-signal.expected/index.md @@ -9,3 +9,42 @@ 5 | }; ``` +## Diagnostics +### Ln 1, Col 1 +```marko +> 1 | 2 | $signal.onabort = () => { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +> 3 | // ^? + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +> 4 | console.log('aborted'); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +> 5 | }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +> 6 | }/> + | ^^^^ The 'effect' tag has been replaced by the 'script' tag. + 7 | +``` + +## Code Actions +### The 'effect' tag has been replaced by the 'script' tag. +```marko + +``` + +### Fix all auto-fixable Marko issues +```marko + +``` + diff --git a/packages/language-server/src/__tests__/fixtures/script/attr-tags-dynamic-for/__snapshots__/attr-tags-dynamic-for.expected/index.md b/packages/language-server/src/__tests__/fixtures/script/attr-tags-dynamic-for/__snapshots__/attr-tags-dynamic-for.expected/index.md index d5771585..994def6b 100644 --- a/packages/language-server/src/__tests__/fixtures/script/attr-tags-dynamic-for/__snapshots__/attr-tags-dynamic-for.expected/index.md +++ b/packages/language-server/src/__tests__/fixtures/script/attr-tags-dynamic-for/__snapshots__/attr-tags-dynamic-for.expected/index.md @@ -161,6 +161,55 @@ ``` ## Diagnostics +### Ln 51, Col 1 +```marko + 49 | + 50 | +> 51 | 52 | hoistedFromForOf; + | ^^^^^^^^^^^^^^^^^^^ +> 53 | //^? + | ^^^^^^^^^^^^^^^^^^^ +> 54 | }/> + | ^^^^ The 'effect' tag has been replaced by the 'script' tag. + 55 | + 56 | + 57 | +``` + +### Ln 75, Col 1 +```marko + 73 | + 74 | +> 75 | 76 | hoistedFromForIn; + | ^^^^^^^^^^^^^^^^^^^ +> 77 | //^? + | ^^^^^^^^^^^^^^^^^^^ +> 78 | }/> + | ^^^^ The 'effect' tag has been replaced by the 'script' tag. + 79 | + 80 | <${custom}> + 81 | +``` + +### Ln 116, Col 1 +```marko + 114 | + 115 | +> 116 | 117 | hoistedFromForTo; + | ^^^^^^^^^^^^^^^^^^^ +> 118 | //^? + | ^^^^^^^^^^^^^^^^^^^ +> 119 | }/> + | ^^^^ The 'effect' tag has been replaced by the 'script' tag. + 120 | +``` + ### Ln 1, Col 4 ```marko > 1 | <${custom}> @@ -290,3 +339,468 @@ 111 | ``` +## Code Actions +### The 'effect' tag has been replaced by the 'script' tag. +```marko +<${custom}> + + <@a/> + + + +<${custom}> + + <@a/> + + +<${custom}> + + <@a> + ${item} ${index} ${all} + + + + +<${custom}> + + <@a> + ${item} + + + <@b> + ${index} + + + + +<${custom}> + + <@a> + + + + + + +<${custom}> + + <@a> + ${key} ${value} + + + + +<${custom}> + + <@a> + + + + + +<${custom}> + + <@a> + ${index} + + + + +<${custom}> + + <@a> + ${index} + + + + +<${custom}> + + <@a> + ${index} + + + + +<${custom}> + + <@a> + + + + + +``` + +### The 'effect' tag has been replaced by the 'script' tag. +```marko +<${custom}> + + <@a/> + + + +<${custom}> + + <@a/> + + +<${custom}> + + <@a> + ${item} ${index} ${all} + + + + +<${custom}> + + <@a> + ${item} + + + <@b> + ${index} + + + + +<${custom}> + + <@a> + + + + + + +<${custom}> + + <@a> + ${key} ${value} + + + + +<${custom}> + + <@a> + + + + + +<${custom}> + + <@a> + ${index} + + + + +<${custom}> + + <@a> + ${index} + + + + +<${custom}> + + <@a> + ${index} + + + + +<${custom}> + + <@a> + + + + + +``` + +### The 'effect' tag has been replaced by the 'script' tag. +```marko +<${custom}> + + <@a/> + + + +<${custom}> + + <@a/> + + +<${custom}> + + <@a> + ${item} ${index} ${all} + + + + +<${custom}> + + <@a> + ${item} + + + <@b> + ${index} + + + + +<${custom}> + + <@a> + + + + + + +<${custom}> + + <@a> + ${key} ${value} + + + + +<${custom}> + + <@a> + + + + + +<${custom}> + + <@a> + ${index} + + + + +<${custom}> + + <@a> + ${index} + + + + +<${custom}> + + <@a> + ${index} + + + + +<${custom}> + + <@a> + + + + + +``` + +### Fix all auto-fixable Marko issues +```marko +<${custom}> + + <@a/> + + + +<${custom}> + + <@a/> + + +<${custom}> + + <@a> + ${item} ${index} ${all} + + + + +<${custom}> + + <@a> + ${item} + + + <@b> + ${index} + + + + +<${custom}> + + <@a> + + + + + + +<${custom}> + + <@a> + ${key} ${value} + + + + +<${custom}> + + <@a> + + + + + +<${custom}> + + <@a> + ${index} + + + + +<${custom}> + + <@a> + ${index} + + + + +<${custom}> + + <@a> + ${index} + + + + +<${custom}> + + <@a> + + + + + +``` + diff --git a/packages/language-server/src/__tests__/fixtures/script/attr-tags-dynamic-if/__snapshots__/attr-tags-dynamic-if.expected/index.md b/packages/language-server/src/__tests__/fixtures/script/attr-tags-dynamic-if/__snapshots__/attr-tags-dynamic-if.expected/index.md index edc82e44..51afa08c 100644 --- a/packages/language-server/src/__tests__/fixtures/script/attr-tags-dynamic-if/__snapshots__/attr-tags-dynamic-if.expected/index.md +++ b/packages/language-server/src/__tests__/fixtures/script/attr-tags-dynamic-if/__snapshots__/attr-tags-dynamic-if.expected/index.md @@ -22,6 +22,25 @@ ``` ## Diagnostics +### Ln 92, Col 1 +```marko + 90 | + 91 | +> 92 | 93 | hoistedFromStaticMember; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +> 94 | //^? + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +> 95 | hoistedFromDynamicMember; // TODO: this should be better and include `undefined` as a possible value + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +> 96 | //^? + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +> 97 | }/> + | ^^^^ The 'effect' tag has been replaced by the 'script' tag. + 98 | +``` + ### Ln 4, Col 4 ```marko 2 | static const y = 2; @@ -121,3 +140,178 @@ 75 | 1 as const/> ``` +## Code Actions +### The 'effect' tag has been replaced by the 'script' tag. +```marko +static const x = 1; +static const y = 2; +<${custom} x=1> + + <@a/> + + +<${custom} x=1> + + + <@a/> + + +<${custom} x=1> + + <@a/> + + + <@b/> + + +<${custom} x=1> + + <@a/> + + + <@b/> + + + <@c/> + + + <@d/> + + +<${custom} x=1> + + <@a/> + + + <@b/> + + +<${custom} x=1> + + <@a/> + + +<${custom} x=1> + + <@a/> + + +<${custom} x=1> + + <@a/> + + + <@b/> + + +<${custom} x=1> + + <@a b=1> + 1 as const)/> + hi! + + <@b/> + + <@b> + 2 as const)/> + + + + <@a/> + + + +``` + +### Fix all auto-fixable Marko issues +```marko +static const x = 1; +static const y = 2; +<${custom} x=1> + + <@a/> + + +<${custom} x=1> + + + <@a/> + + +<${custom} x=1> + + <@a/> + + + <@b/> + + +<${custom} x=1> + + <@a/> + + + <@b/> + + + <@c/> + + + <@d/> + + +<${custom} x=1> + + <@a/> + + + <@b/> + + +<${custom} x=1> + + <@a/> + + +<${custom} x=1> + + <@a/> + + +<${custom} x=1> + + <@a/> + + + <@b/> + + +<${custom} x=1> + + <@a b=1> + 1 as const)/> + hi! + + <@b/> + + <@b> + 2 as const)/> + + + + <@a/> + + + +``` + diff --git a/packages/language-server/src/__tests__/fixtures/script/attr-tags-static/__snapshots__/attr-tags-static.expected/index.md b/packages/language-server/src/__tests__/fixtures/script/attr-tags-static/__snapshots__/attr-tags-static.expected/index.md index f5afbb85..7525f71a 100644 --- a/packages/language-server/src/__tests__/fixtures/script/attr-tags-static/__snapshots__/attr-tags-static.expected/index.md +++ b/packages/language-server/src/__tests__/fixtures/script/attr-tags-static/__snapshots__/attr-tags-static.expected/index.md @@ -11,6 +11,21 @@ ``` ## Diagnostics +### Ln 12, Col 1 +```marko + 10 | + 11 | +> 12 | 13 | hoistedFromStaticMember; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +> 14 | //^? + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +> 15 | }/> + | ^^^^ The 'effect' tag has been replaced by the 'script' tag. + 16 | +``` + ### Ln 1, Col 4 ```marko > 1 | <${custom}> @@ -20,3 +35,36 @@ 4 | <@a b=1> ``` +## Code Actions +### The 'effect' tag has been replaced by the 'script' tag. +```marko +<${custom}> + <@b/> + <@a b=1> + 1 as const)/> + hi! + + <@b c=2/> + + +``` + +### Fix all auto-fixable Marko issues +```marko +<${custom}> + <@b/> + <@a b=1> + 1 as const)/> + hi! + + <@b c=2/> + + +``` + diff --git a/packages/language-server/src/__tests__/fixtures/script/for-tag/__snapshots__/for-tag.expected/index.md b/packages/language-server/src/__tests__/fixtures/script/for-tag/__snapshots__/for-tag.expected/index.md index 1d9e5a0b..15956713 100644 --- a/packages/language-server/src/__tests__/fixtures/script/for-tag/__snapshots__/for-tag.expected/index.md +++ b/packages/language-server/src/__tests__/fixtures/script/for-tag/__snapshots__/for-tag.expected/index.md @@ -249,6 +249,74 @@ ``` ## Diagnostics +### Ln 28, Col 1 +```marko + 26 | + 27 | +> 28 | 29 | hoistedFromForOf; + | ^^^^^^^^^^^^^^^^^^^ +> 30 | //^? + | ^^^^^^^^^^^^^^^^^^^ +> 31 | }/> + | ^^^^ The 'effect' tag has been replaced by the 'script' tag. + 32 | + 33 | + 34 | +``` + +### Ln 48, Col 1 +```marko + 46 | + 47 | +> 48 | 49 | hoistedFromForIn; + | ^^^^^^^^^^^^^^^^^^^ +> 50 | //^? + | ^^^^^^^^^^^^^^^^^^^ +> 51 | }/> + | ^^^^ The 'effect' tag has been replaced by the 'script' tag. + 52 | + 53 | + 54 | ${index} +``` + +### Ln 76, Col 1 +```marko + 74 | + 75 | +> 76 | 77 | hoistedFromForUntil; + | ^^^^^^^^^^^^^^^^^^^^^^ +> 78 | //^? + | ^^^^^^^^^^^^^^^^^^^^^^ +> 79 | }/> + | ^^^^ The 'effect' tag has been replaced by the 'script' tag. + 80 | + 81 | + 82 | ${index} +``` + +### Ln 104, Col 1 +```marko + 102 | + 103 | +> 104 | 105 | hoistedFromForUntil; + | ^^^^^^^^^^^^^^^^^^^^^^ +> 106 | //^? + | ^^^^^^^^^^^^^^^^^^^^^^ +> 107 | }/> + | ^^^^ The 'effect' tag has been replaced by the 'script' tag. + 108 | + 109 | + 110 | +``` + ### Ln 26, Col 6 ```marko 24 | @@ -282,3 +350,474 @@ 113 | ``` +## Code Actions +### The 'effect' tag has been replaced by the 'script' tag. +```marko + + + Repeated! + + + ${item} ${index} ${all} + + + `${item}-${index}`)> + + + + item.value)/> + + + + + + ${key} ${value} + + + `${value}-${key}`)> + + + + key)/> + + + + ${index} + + + `${index}`)> + + + + ${index} + + + + ${index} + + + + index)/> + + + + ${index} + + + `${index}`)> + + + + ${index} + + + + ${index} + + + + index)/> + + + + Should error + +``` + +### The 'effect' tag has been replaced by the 'script' tag. +```marko + + + Repeated! + + + ${item} ${index} ${all} + + + `${item}-${index}`)> + + + + item.value)/> + + + + + + ${key} ${value} + + + `${value}-${key}`)> + + + + key)/> + + + + ${index} + + + `${index}`)> + + + + ${index} + + + + ${index} + + + + index)/> + + + + ${index} + + + `${index}`)> + + + + ${index} + + + + ${index} + + + + index)/> + + + + Should error + +``` + +### The 'effect' tag has been replaced by the 'script' tag. +```marko + + + Repeated! + + + ${item} ${index} ${all} + + + `${item}-${index}`)> + + + + item.value)/> + + + + + + ${key} ${value} + + + `${value}-${key}`)> + + + + key)/> + + + + ${index} + + + `${index}`)> + + + + ${index} + + + + ${index} + + + + index)/> + + + + ${index} + + + `${index}`)> + + + + ${index} + + + + ${index} + + + + index)/> + + + + Should error + +``` + +### The 'effect' tag has been replaced by the 'script' tag. +```marko + + + Repeated! + + + ${item} ${index} ${all} + + + `${item}-${index}`)> + + + + item.value)/> + + + + + + ${key} ${value} + + + `${value}-${key}`)> + + + + key)/> + + + + ${index} + + + `${index}`)> + + + + ${index} + + + + ${index} + + + + index)/> + + + + ${index} + + + `${index}`)> + + + + ${index} + + + + ${index} + + + + index)/> + + + + Should error + +``` + +### Fix all auto-fixable Marko issues +```marko + + + Repeated! + + + ${item} ${index} ${all} + + + `${item}-${index}`)> + + + + item.value)/> + + + + + + ${key} ${value} + + + `${value}-${key}`)> + + + + key)/> + + + + ${index} + + + `${index}`)> + + + + ${index} + + + + ${index} + + + + index)/> + + + + ${index} + + + `${index}`)> + + + + ${index} + + + + ${index} + + + + index)/> + + + + Should error + +``` + diff --git a/packages/language-server/src/__tests__/fixtures/script/recursive-input-scope-hoist/__snapshots__/recursive-input-scope-hoist.expected/index.md b/packages/language-server/src/__tests__/fixtures/script/recursive-input-scope-hoist/__snapshots__/recursive-input-scope-hoist.expected/index.md index 42fc7222..4db7fbe6 100644 --- a/packages/language-server/src/__tests__/fixtures/script/recursive-input-scope-hoist/__snapshots__/recursive-input-scope-hoist.expected/index.md +++ b/packages/language-server/src/__tests__/fixtures/script/recursive-input-scope-hoist/__snapshots__/recursive-input-scope-hoist.expected/index.md @@ -42,3 +42,75 @@ 21 | }/> ``` +## Diagnostics +### Ln 14, Col 1 +```marko + 12 | + 13 | +> 14 | 15 | a; + | ^^^^ +> 16 | //^? + | ^^^^ +> 17 | b; + | ^^^^ +> 18 | //^? + | ^^^^ +> 19 | c; + | ^^^^ +> 20 | //^? + | ^^^^ +> 21 | }/> + | ^^^^ The 'effect' tag has been replaced by the 'script' tag. +``` + +## Code Actions +### The 'effect' tag has been replaced by the 'script' tag. +```marko + + <@comment id="a"> + <@comment id="b"> + + "b" as const)/> + + "a" as const)/> + + <@comment id="c"> + "c" as const)/> + + + +``` + +### Fix all auto-fixable Marko issues +```marko + + <@comment id="a"> + <@comment id="b"> + + "b" as const)/> + + "a" as const)/> + + <@comment id="c"> + "c" as const)/> + + + +``` + diff --git a/packages/language-server/src/__tests__/fixtures/script/simple-hoist/__snapshots__/simple-hoist.expected/index.md b/packages/language-server/src/__tests__/fixtures/script/simple-hoist/__snapshots__/simple-hoist.expected/index.md index d67d278c..81663be8 100644 --- a/packages/language-server/src/__tests__/fixtures/script/simple-hoist/__snapshots__/simple-hoist.expected/index.md +++ b/packages/language-server/src/__tests__/fixtures/script/simple-hoist/__snapshots__/simple-hoist.expected/index.md @@ -11,6 +11,21 @@ ``` ## Diagnostics +### Ln 13, Col 1 +```marko + 11 |
+ 12 | +> 13 | 14 | console.log(el()) + | ^^^^^^^^^^^^^^^^^^^ +> 15 | // ^? + | ^^^^^^^^^^^^^^^^^^^ +> 16 | }/> + | ^^^^ The 'effect' tag has been replaced by the 'script' tag. + 17 | +``` + ### Ln 4, Col 4 ```marko 2 | @@ -29,3 +44,38 @@ 7 | ++x; ``` +## Code Actions +### The 'effect' tag has been replaced by the 'script' tag. +```marko +
+ + ${x} +
+ +``` + +### Fix all auto-fixable Marko issues +```marko +
+ + ${x} +
+ +``` + diff --git a/packages/language-tools/package.json b/packages/language-tools/package.json index fb9485d9..216ad582 100644 --- a/packages/language-tools/package.json +++ b/packages/language-tools/package.json @@ -38,14 +38,14 @@ }, "dependencies": { "@luxass/strip-json-comments": "^1.4.0", - "@marko/compiler": "^5.41.7", + "@marko/compiler": "^5.42.0", "htmljs-parser": "^5.14.0", "relative-import-path": "^1.0.1" }, "devDependencies": { "@types/babel__code-frame": "^7.27.0", "@typescript/vfs": "^1.6.4", - "marko": "^5.39.27", + "marko": "^5.39.33", "mitata": "^1.0.34", "tsx": "^4.22.4" } diff --git a/packages/ts-plugin/package.json b/packages/ts-plugin/package.json index 0405e5b7..36714380 100644 --- a/packages/ts-plugin/package.json +++ b/packages/ts-plugin/package.json @@ -28,7 +28,7 @@ "devDependencies": { "@marko/language-server": "^3.3.6", "@marko/language-tools": "^2.6.8", - "marko": "^5.39.27", + "marko": "^5.39.33", "tsx": "^4.22.4", "typescript": "^6.0.3" } diff --git a/packages/type-check/package.json b/packages/type-check/package.json index 5fd50530..63d9e72b 100644 --- a/packages/type-check/package.json +++ b/packages/type-check/package.json @@ -32,7 +32,7 @@ }, "dependencies": { "@luxass/strip-json-comments": "^1.4.0", - "@marko/compiler": "^5.41.7", + "@marko/compiler": "^5.42.0", "@marko/language-tools": "^2.6.8", "arg": "^5.0.2", "kleur": "^4.1.5", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 24a4ad3b..e9e5c105 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -85,8 +85,8 @@ importers: specifier: ^1.4.0 version: 1.4.0 '@marko/compiler': - specifier: ^5.41.7 - version: 5.41.7 + specifier: ^5.42.0 + version: 5.42.0 '@marko/language-tools': specifier: ^2.6.8 version: link:../language-tools @@ -100,8 +100,8 @@ importers: specifier: ^29.1.1 version: 29.1.1(patch_hash=63260bcabe348afac2b14cafcd725106f132adbad0fab0328f16e5a9c6a1a1e4) marko: - specifier: ^5.39.27 - version: 5.39.27 + specifier: ^5.39.33 + version: 5.39.33 prettier: specifier: ^3.8.4 version: 3.8.4 @@ -140,8 +140,8 @@ importers: specifier: ^1.4.0 version: 1.4.0 '@marko/compiler': - specifier: ^5.41.7 - version: 5.41.7 + specifier: ^5.42.0 + version: 5.42.0 htmljs-parser: specifier: ^5.14.0 version: 5.14.0 @@ -156,8 +156,8 @@ importers: specifier: ^1.6.4 version: 1.6.4(supports-color@8.1.1)(typescript@6.0.3) marko: - specifier: ^5.39.27 - version: 5.39.27 + specifier: ^5.39.33 + version: 5.39.33 mitata: specifier: ^1.0.34 version: 1.0.34 @@ -174,8 +174,8 @@ importers: specifier: ^2.6.8 version: link:../language-tools marko: - specifier: ^5.39.27 - version: 5.39.27 + specifier: ^5.39.33 + version: 5.39.33 tsx: specifier: ^4.22.4 version: 4.22.4 @@ -189,8 +189,8 @@ importers: specifier: ^1.4.0 version: 1.4.0 '@marko/compiler': - specifier: ^5.41.7 - version: 5.41.7 + specifier: ^5.42.0 + version: 5.42.0 '@marko/language-tools': specifier: ^2.6.8 version: link:../language-tools @@ -909,10 +909,18 @@ packages: resolution: {integrity: sha512-8NtJhMzMlAL4p5ml+KFyCou/MjSQEoNEikARnBaR3nJv7zROruFo6eegtR6qb9y09zbO1FERq2eBmRQ7LGvXXw==} engines: {node: 18 || 20 || >=22} + '@marko/compiler@5.42.0': + resolution: {integrity: sha512-w9awaOlrqIBpjX1hMz0fllOnRCa3IaY2ZeoD0+lp8Yo/EmTs2LxJHc6RxXwZsEMcj22fCCVh7yGcylRhhJNTQw==} + engines: {node: '>=22'} + '@marko/runtime-tags@6.3.21': resolution: {integrity: sha512-ehZ6vvj7kX6HfVKGHJu8TtImnvEbrgWMAES267rlC4HF1cSYSxzx3LDXpyqtZB0bASKAshgrf4lnepqLHH7JHQ==} engines: {node: '>=22'} + '@marko/runtime-tags@6.3.35': + resolution: {integrity: sha512-Tx0NjH5uMpkm84uRmsR0B+VbUQs26a9TlMzc5z6eWxvKpQYFtAC0vVRCMW5Ds0Rg4L9+NZG4PAIijxXF7zEIpw==} + engines: {node: '>=22'} + '@napi-rs/wasm-runtime@0.2.12': resolution: {integrity: sha512-ZVWUcfwY4E/yPitQJl481FjFo3K22D6qF0DuFH6Y/nbnE11GY5uguDxZMGXPQ8WQ0128MXQD7TnfHyK4oWoIJQ==} @@ -2371,6 +2379,11 @@ packages: engines: {node: 18 || 20 || >=22} hasBin: true + marko@5.39.33: + resolution: {integrity: sha512-LJ1M2gyopR9n8RfriwdpzevlSEk8ny6t5uRkOX1pJCQvwmaMls4xRPs7yCzzYEcjtBKlDewHI1HLVSYRFPsKAg==} + engines: {node: '>=22'} + hasBin: true + math-intrinsics@1.1.0: resolution: {integrity: sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==} engines: {node: '>= 0.4'} @@ -4008,6 +4021,23 @@ snapshots: self-closing-tags: 1.0.1 source-map-support: 0.5.21 + '@marko/compiler@5.42.0': + dependencies: + '@luxass/strip-json-comments': 2.0.1 + complain: 1.6.1 + he: 1.2.0 + htmljs-parser: 5.14.0 + jsesc: 3.1.0 + kleur: 4.1.5 + lasso-package-root: 1.0.1 + magic-string: 0.30.21 + raptor-regexp: 1.0.1 + raptor-util: 3.2.0 + relative-import-path: 1.0.1 + resolve-from: 5.0.0 + self-closing-tags: 1.0.1 + source-map-support: 0.5.21 + '@marko/runtime-tags@6.3.21': dependencies: '@marko/compiler': 5.41.7 @@ -4015,6 +4045,13 @@ snapshots: fastest-levenshtein: 1.0.16 magic-string: 0.30.21 + '@marko/runtime-tags@6.3.35': + dependencies: + '@marko/compiler': 5.42.0 + csstype: 3.2.3 + fastest-levenshtein: 1.0.16 + magic-string: 0.30.21 + '@napi-rs/wasm-runtime@0.2.12': dependencies: '@emnapi/core': 1.11.2 @@ -5636,6 +5673,25 @@ snapshots: self-closing-tags: 1.0.1 warp10: 2.1.0 + marko@5.39.33: + dependencies: + '@marko/compiler': 5.42.0 + '@marko/runtime-tags': 6.3.35 + app-module-path: 2.2.0 + argly: 1.2.0 + browser-refresh-client: 1.1.4 + complain: 1.6.1 + csstype: 3.2.3 + events-light: 1.0.5 + he: 1.2.0 + listener-tracker: 2.0.0 + magic-string: 0.30.21 + minimatch: 10.2.5 + raptor-util: 3.2.0 + resolve-from: 5.0.0 + self-closing-tags: 1.0.1 + warp10: 2.1.0 + math-intrinsics@1.1.0: {} mdn-data@2.27.1: {}