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
35 changes: 16 additions & 19 deletions biome.jsonc
Original file line number Diff line number Diff line change
@@ -1,27 +1,24 @@
{
"$schema": "https://biomejs.dev/schemas/2.4.7/schema.json",
"vcs": {
"enabled": true,
"clientKind": "git",
"useIgnoreFile": true
},
"formatter": {
"enabled": true,
"indentStyle": "space",
"lineEnding": "lf"
},
"assist": {
"actions": {
"source": {
"organizeImports": "on"
}
}
"$schema": "https://biomejs.dev/schemas/2.4.9/schema.json",
"extends": ["@gameroman/config/biome"],
"files": {
"includes": ["**", "!!tests/fixtures"]
},
"linter": {
"rules": {
"a11y": "off",
"suspicious": {
"noEmptyInterface": "off",
"noImplicitAnyLet": "warn",
"noAssignInExpressions": "warn",
"noExplicitAny": "warn",
"useIterableCallbackReturn": "warn",
"noDoubleEquals": "warn",
"noThenProperty": "warn",
"noShadowRestrictedNames": "warn",
"noFallthroughSwitchClause": "warn"
},
"style": {
"useNodejsImportProtocol": "error"
"useShorthandFunctionType": "off"
}
}
}
Expand Down
159 changes: 81 additions & 78 deletions bun.lock

Large diffs are not rendered by default.

53 changes: 27 additions & 26 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,50 +22,51 @@
},
"scripts": {
"build": "tsdown",
"lint": "biome lint",
"lint": "biome check",
"format": "biome check --write --linter-enabled=false",
"test": "bun run build && bun test --coverage",
"typecheck": "tsc --noEmit",
"prepublishOnly": "bun run build"
},
"dependencies": {
"@babel/helper-plugin-utils": "^8.0.0-rc.2",
"@babel/helper-validator-option": "^8.0.0-rc.2",
"@babel/core": "^8.0.0-rc.2",
"@babel/helper-module-imports": "^8.0.0-rc.2",
"@babel/template": "^8.0.0-rc.2",
"@babel/traverse": "^8.0.0-rc.2",
"@babel/types": "^8.0.0-rc.2",
"@babel/helper-plugin-utils": "^8.0.0-rc.3",
"@babel/helper-validator-option": "^8.0.0-rc.3",
"@babel/core": "^8.0.0-rc.3",
"@babel/helper-module-imports": "^8.0.0-rc.3",
"@babel/template": "^8.0.0-rc.3",
"@babel/traverse": "^8.0.0-rc.3",
"@babel/types": "^8.0.0-rc.3",
"html-entities": "2.6.0",
"parse5": "^8.0.0"
},
"devDependencies": {
"@biomejs/biome": "2.4.7",
"@types/bun": "^1.3.10",
"@biomejs/biome": "2.4.9",
"@gameroman/config": "^0.0.5",
"@types/bun": "^1.3.11",
"@types/node": "^25.5.0",
"solid-js": "1.9.11",
"tsdown": "^0.21.3",
"typescript": "^5.9.3"
"solid-js": "1.9.12",
"tsdown": "^0.21.7",
"typescript": "^6.0.2"
},
"peerDependencies": {
"csstype": "^3.1.0",
"rolldown": "^1.0.0-rc.9 || ^1.0.0",
"seroval": "~1.3.0 || ~1.5.0",
"solid-js": ">=1.9.0"
"rolldown": "^1.0.0-rc.12",
"seroval": "~1.5.0",
"solid-js": ">=1.9.12"
},
"engines": {
"node": ">=22.12.0"
},
"overrides": {
"@babel/helper-plugin-utils": "8.0.0-rc.2",
"@babel/helper-validator-identifier": "8.0.0-rc.2",
"@babel/helper-validator-option": "8.0.0-rc.2",
"@babel/code-frame": "8.0.0-rc.2",
"@babel/core": "8.0.0-rc.2",
"@babel/helper-module-imports": "8.0.0-rc.2",
"@babel/parser": "8.0.0-rc.2",
"@babel/template": "8.0.0-rc.2",
"@babel/traverse": "8.0.0-rc.2",
"@babel/types": "8.0.0-rc.2"
"@babel/helper-plugin-utils": "8.0.0-rc.3",
"@babel/helper-validator-identifier": "8.0.0-rc.3",
"@babel/helper-validator-option": "8.0.0-rc.3",
"@babel/code-frame": "8.0.0-rc.3",
"@babel/core": "8.0.0-rc.3",
"@babel/helper-module-imports": "8.0.0-rc.3",
"@babel/parser": "8.0.0-rc.3",
"@babel/template": "8.0.0-rc.3",
"@babel/traverse": "8.0.0-rc.3",
"@babel/types": "8.0.0-rc.3"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ export function transformElement(path, info) {
results.templateWithClosingTags += `</${tagName}>`;
}
if (info.topLevel && config.hydratable && results.hasHydratableEvent) {
let runHydrationEvents = registerImportMethod(
const runHydrationEvents = registerImportMethod(
path,
"runHydrationEvents",
getRendererConfig(path, "dom").moduleName,
Expand Down Expand Up @@ -320,7 +320,7 @@ export function setAttr(
);
}

let isNameSpaced = name.indexOf(":") > -1;
const isNameSpaced = name.indexOf(":") > -1;
name = Aliases[name] || name;
!isSVG && (name = name.toLowerCase());
const ns = isNameSpaced && SVGNamespace[name.split(":")[0]];
Expand Down Expand Up @@ -668,7 +668,7 @@ function transformAttributes(path, results) {
}

for (let i = 0, len = text.length; i < len; i++) {
let char = text[i];
const char = text[i];

if (
char === "'" ||
Expand Down Expand Up @@ -1281,7 +1281,7 @@ function transformChildren(path, results, config) {
nextPlaceholder = null;
i++;
} else if (child.exprs.length) {
let insert = registerImportMethod(
const insert = registerImportMethod(
path,
"insert",
getRendererConfig(path, "dom").moduleName,
Expand Down Expand Up @@ -1525,7 +1525,7 @@ function processSpreads(
});
if (dynamic) {
const id = convertJSXIdentifier(node.name);
let expr =
const expr =
wrapConditionals &&
(t.isLogicalExpression(node.value.expression) ||
t.isConditionalExpression(node.value.expression))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ function transformComponentChildren(children, config) {
const filteredChildren = filterChildren(children);
if (!filteredChildren.length) return;
let dynamic = false;
let pathNodes = [];
const pathNodes = [];

let transformedChildren = filteredChildren.reduce((memo, path) => {
if (t.isJSXText(path.node)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ export default (path, state) => {
}
}
}
let domTemplates = path.scope.data.templates.filter(
const domTemplates = path.scope.data.templates.filter(
(temp) => temp.renderer === "dom",
);
let ssrTemplates = path.scope.data.templates.filter(
const ssrTemplates = path.scope.data.templates.filter(
(temp) => temp.renderer === "ssr",
);
domTemplates.length > 0 && appendTemplatesDOM(path, domTemplates);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ export function transformNode(path, info = {}) {
if (t.isJSXElement(node)) {
return transformElement(config, path, info);
} else if (t.isJSXFragment(node)) {
let results = { template: "", declarations: [], exprs: [], dynamics: [] };
const results = { template: "", declarations: [], exprs: [], dynamics: [] };
// <><div /><Component /></>
transformFragmentChildren(path.get("children"), results, config);
return results;
Expand Down Expand Up @@ -229,7 +229,7 @@ export function getCreateTemplate(config, path, result) {

function transformElement(config, path, info = {}) {
const node = path.node;
let tagName = getTagName(node);
const tagName = getTagName(node);
// <Component ...></Component>
if (isComponent(tagName)) return transformComponent(path);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import * as parse5 from "parse5";

/** `bodyElement` will be used as a `context` (The place where we run `innerHTML`) */
// biome-ignore lint/style/noNonNullAssertion: it will be always defined
const bodyElement = parse5.parse(
`<!DOCTYPE html><html><head></head><body></body></html>`,
// @ts-expect-error
// @ts-expect-error: it will be always defined
).childNodes[1]!.childNodes[1];

function innerHTML(htmlFragment: string) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,7 @@ function createElement(path, { topLevel, hydratable }) {
checkTags: true,
})
) {
let expr = t.arrowFunctionExpression([], value.expression);
const expr = t.arrowFunctionExpression([], value.expression);
runningObject.push(
t.objectMethod(
"get",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
} from "../shared/utils";

export function transformElement(path, info) {
let tagName = getTagName(path.node),
const tagName = getTagName(path.node),
results = {
id: path.scope.generateUidIdentifier("el$"),
declarations: [],
Expand Down Expand Up @@ -254,14 +254,14 @@ function transformChildren(path, results) {
Wrap the usage with a component that would render this element, eg. Canvas`);
}
if (child.id) {
let insertNode = registerImportMethod(
const insertNode = registerImportMethod(
path,
"insertNode",
getRendererConfig(path, "universal").moduleName,
);
let insert = child.id;
if (child.text) {
let createTextNode = registerImportMethod(
const createTextNode = registerImportMethod(
path,
"createTextNode",
getRendererConfig(path, "universal").moduleName,
Expand Down Expand Up @@ -303,7 +303,7 @@ function transformChildren(path, results) {
results.exprs.push(...child.exprs);
results.dynamics.push(...child.dynamics);
} else if (child.exprs.length) {
let insert = registerImportMethod(
const insert = registerImportMethod(
path,
"insert",
getRendererConfig(path, "universal").moduleName,
Expand Down Expand Up @@ -389,7 +389,7 @@ function processSpreads(
});
if (dynamic) {
const id = convertJSXIdentifier(node.name);
let expr =
const expr =
wrapConditionals &&
(t.isLogicalExpression(node.value.expression) ||
t.isConditionalExpression(node.value.expression))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ export function clearDelegatedEvents(d?: Document): void;
export function spread<T>(
node: Element,
accessor: T,
isSVG?: Boolean,
skipChildren?: Boolean,
isSVG?: boolean,
skipChildren?: boolean,
): void;
export function assign(
node: Element,
props: any,
isSVG?: Boolean,
skipChildren?: Boolean,
isSVG?: boolean,
skipChildren?: boolean,
): void;
export function setAttribute(node: Element, name: string, value: string): void;
export function setAttributeNS(
Expand Down
13 changes: 6 additions & 7 deletions src/babel-plugin-jsx-dom-expressions/dom-expressions/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export {
};

export function render(code, element, init, options = {}) {
if ("_DX_DEV_" && !element) {
if (!element) {
throw new Error(
"The `element` passed to `render(..., element)` doesn't exist. Make sure `element` exists in the document.",
);
Expand All @@ -68,7 +68,7 @@ export function render(code, element, init, options = {}) {
export function template(html, isImportNode, isSVG, isMathML) {
let node;
const create = () => {
if ("_DX_DEV_" && isHydrating())
if (isHydrating())
throw new Error(
"Failed attempt to create new DOM elements during hydration. Check that the libraries you are using support hydration.",
);
Expand Down Expand Up @@ -108,7 +108,7 @@ export function delegateEvents(eventNames, document = window.document) {

export function clearDelegatedEvents(document = window.document) {
if (document[$$EVENTS]) {
for (let name of document[$$EVENTS].keys())
for (const name of document[$$EVENTS].keys())
document.removeEventListener(name, eventHandler);
delete document[$$EVENTS];
}
Expand Down Expand Up @@ -324,7 +324,7 @@ export function getNextElement(template) {
!hydrating ||
!(node = sharedConfig.registry.get((key = getHydrationKey())))
) {
if ("_DX_DEV_" && hydrating) {
if (hydrating) {
sharedConfig.done = true;
throw new Error(
`Hydration Mismatch. Unable to find DOM nodes for hydration key: ${key}\n${template ? template().outerHTML : ""}`,
Expand Down Expand Up @@ -531,7 +531,7 @@ function insertExpression(parent, value, current, marker, unwrapArray) {
const hydrating = isHydrating(parent);
if (hydrating) {
!current && (current = [...parent.childNodes]);
let cleaned = [];
const cleaned = [];
for (let i = 0; i < current.length; i++) {
const node = current[i];
if (node.nodeType === 8 && node.data.slice(0, 2) === "!$") node.remove();
Expand Down Expand Up @@ -614,8 +614,7 @@ function insertExpression(parent, value, current, marker, unwrapArray) {
parent.appendChild(value);
} else parent.replaceChild(value, parent.firstChild);
current = value;
} else if ("_DX_DEV_")
console.warn(`Unrecognized value. Skipped inserting`, value);
}

return current;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
* @see https://github.com/ryansolid/dom-expressions/issues/408
*/

import { execSync as $ } from "child_process";
import fs from "fs";
import { execSync as $ } from "node:child_process";
import fs from "node:fs";

process.chdir("packages/dom-expressions/src");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,8 @@ export function insert<T>(
export function spread<T>(
node: Element,
accessor: T,
isSVG?: Boolean,
skipChildren?: Boolean,
isSVG?: boolean,
skipChildren?: boolean,
): void;

/** @deprecated not supported on the server side */
Expand Down Expand Up @@ -196,8 +196,8 @@ export function className(node: Element, value: string): void;
export function assign(
node: Element,
props: any,
isSVG?: Boolean,
skipChildren?: Boolean,
isSVG?: boolean,
skipChildren?: boolean,
): void;

/** @deprecated not supported on the server side */
Expand Down
Loading