Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/cool-days-attack.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"prettier-plugin-marko": patch
---

Require htmljs-parser ^5.12.1, which fixes attribute-value trailing line comments being treated as self-enclosed and leaking past the tag.
874 changes: 448 additions & 426 deletions package-lock.json

Large diffs are not rendered by default.

30 changes: 15 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,26 +43,26 @@
"test:update": "vitest run --update"
},
"dependencies": {
"htmljs-parser": "^5.10.2"
"htmljs-parser": "^5.12.1"
},
"devDependencies": {
"@changesets/changelog-github": "^0.6.0",
"@changesets/cli": "^2.30.0",
"@changesets/changelog-github": "^0.7.0",
"@changesets/cli": "^2.31.0",
"@eslint/js": "^10.0.1",
"@marko/compiler": "^5.39.62",
"@types/node": "^25.6.0",
"@vitest/coverage-v8": "^4.1.4",
"eslint": "^10.2.0",
"@marko/compiler": "^5.40.0",
"@types/node": "^26.1.0",
"@vitest/coverage-v8": "^4.1.9",
"eslint": "^10.6.0",
"eslint-plugin-simple-import-sort": "^13.0.0",
"globals": "^17.5.0",
"globals": "^17.7.0",
"husky": "^9.1.7",
"lint-staged": "^16.4.0",
"marko": "^6.0.160",
"prettier": "^3.8.2",
"lint-staged": "^17.0.8",
"marko": "^6.2.1",
"prettier": "^3.9.4",
"prettier-plugin-packagejson": "^3.0.2",
"rolldown": "^1.0.0-rc.15",
"typescript": "^6.0.2",
"typescript-eslint": "^8.58.2",
"vitest": "^4.1.4"
"rolldown": "^1.1.4",
"typescript": "^6.0.3",
"typescript-eslint": "^8.62.1",
"vitest": "^4.1.9"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@
<my-tag <
T extends
keyof (typeof SuperLongImportedVariableName)["member1"]["member2"]["member3"],
K extends T extends string
K extends (T extends string
? MyType["member1"]["member2"]["member3"]
: MyOtherType,
: MyOtherType),
>|x|/>
<my-tag<{
foo: number;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ my-tag<
my-tag <
T extends
keyof (typeof SuperLongImportedVariableName)["member1"]["member2"]["member3"],
K extends T extends string
K extends (T extends string
? MyType["member1"]["member2"]["member3"]
: MyOtherType,
: MyOtherType),
>|x|
my-tag<{
foo: number;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@
<my-tag <
T extends
keyof (typeof SuperLongImportedVariableName)["member1"]["member2"]["member3"],
K extends T extends string
K extends (T extends string
? MyType["member1"]["member2"]["member3"]
: MyOtherType,
: MyOtherType),
>|x|/>
<my-tag<{
foo: number;
Expand Down
7 changes: 6 additions & 1 deletion src/__tests__/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@ import * as plugin from "..";

const fixtures = path.join(import.meta.dirname, "fixtures");
const { traverseFast } = compiler.types;
const skip = (traverseFast as any).skip as symbol;
// `traverseFast.skip` is a `unique symbol`, but the `@marko/compiler` re-export
// widens it to `symbol`; recover the precise type from the visitor signature.
const skip = traverseFast.skip as Exclude<
ReturnType<Parameters<typeof traverseFast>[1]>,
void
>;
const compileOpts: compiler.Config = {
output: "source",
ast: true,
Expand Down
6 changes: 3 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ const embedHandlers: EmbedHandlers = {
Array.isArray(varPart.contents)
) {
const varContents = varPart.contents;
for (let i = varContents.length; i--; ) {
for (let i = varContents.length; i--;) {
const item = varContents[i];
if (typeof item === "string") {
// Walks back until we find the equals sign.
Expand Down Expand Up @@ -969,7 +969,7 @@ function trimText(text: string, path: AstPath<Node.Text>) {
let prev: Node.ChildNode | undefined;
let next: Node.ChildNode | undefined;

for (let i = path.index!; --i >= 0; ) {
for (let i = path.index!; --i >= 0;) {
const sibling = siblings[i];
if (
sibling.type !== NodeType.Scriptlet &&
Expand All @@ -980,7 +980,7 @@ function trimText(text: string, path: AstPath<Node.Text>) {
}
}

for (let i = path.index!; ++i < siblings.length; ) {
for (let i = path.index!; ++i < siblings.length;) {
const sibling = siblings[i];
if (
sibling.type !== NodeType.Scriptlet &&
Expand Down
8 changes: 4 additions & 4 deletions src/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export namespace Node {
export type AttrNode = AttrNamed | AttrSpread;
export type ControlFlowTag = Tag & {
nameText: "if" | "else" | "else-if" | "for" | "while";
bodyType: TagType.html;
bodyType: typeof TagType.html;
};
export type ChildNode =
| Tag
Expand Down Expand Up @@ -122,7 +122,7 @@ export namespace Node {
open: Range;
close: Range | undefined;
nameText: string | undefined;
bodyType: Exclude<TagType, "statement">;
bodyType: Exclude<TagType, typeof TagType.statement>;
name: OpenTagName;
var: TagVar | undefined;
args: TagArgs | undefined;
Expand All @@ -145,7 +145,7 @@ export namespace Node {
open: Range;
close: Range | undefined;
nameText: string;
bodyType: TagType.html;
bodyType: typeof TagType.html;
name: OpenTagName;
var: TagVar | undefined;
args: TagArgs | undefined;
Expand Down Expand Up @@ -419,7 +419,7 @@ class Builder {
let concise = true;
let start = range.start;
let type = NodeType.Tag;
let bodyType = TagType.html;
let bodyType: TagType = TagType.html;
let nameText: string | undefined = undefined;

if (this.#openTagStart) {
Expand Down