chore: update format, lint, & pre-commit scripts; fix lint error

This commit is contained in:
ayo 2026-04-27 09:38:13 +02:00
parent 44ab909ea0
commit 1957d71170
2 changed files with 10 additions and 5 deletions

View file

@ -14,6 +14,7 @@
"cli": "node ./packages/core/cli/index.js", "cli": "node ./packages/core/cli/index.js",
"test": "vitest --run", "test": "vitest --run",
"lint": "eslint . --config eslint.config.mjs --cache", "lint": "eslint . --config eslint.config.mjs --cache",
"lint:fix": "eslint . --config eslint.config.mjs --fix",
"check": "npm run format && npm run lint", "check": "npm run format && npm run lint",
"format": "prettier . --write", "format": "prettier . --write",
"prepare": "husky" "prepare": "husky"
@ -35,11 +36,11 @@
}, },
"lint-staged": { "lint-staged": {
"*.{js,ts,mjs,cjs,json,.*rc}": [ "*.{js,ts,mjs,cjs,json,.*rc}": [
"npx prettier --write", "npm run format",
"npx eslint --fix" "npm run lint:fix"
], ],
"*.json": [ "*.json": [
"npx prettier --write" "npm run format"
] ]
} }
} }

View file

@ -65,7 +65,7 @@ function replaceSlots(fragmentNode, node) {
if (n.type === ELEMENT_NODE && n.name === 'slot') { if (n.type === ELEMENT_NODE && n.name === 'slot') {
// find node child with same name attribute // find node child with same name attribute
const currentSlotName = n.attributes?.['name'] ?? null const currentSlotName = n.attributes?.['name'] ?? null
let nodeChildren = [] let nodeChildren
if (currentSlotName === null) { if (currentSlotName === null) {
nodeChildren = node.children.filter( nodeChildren = node.children.filter(
@ -78,7 +78,11 @@ function replaceSlots(fragmentNode, node) {
}) })
} }
if (nodeChildren.length > 0 && !containsAll(slotted, nodeChildren)) { if (
nodeChildren &&
nodeChildren.length > 0 &&
!containsAll(slotted, nodeChildren)
) {
slotted = [...slotted, ...nodeChildren] slotted = [...slotted, ...nodeChildren]
const index = n.parent.children.indexOf(n) const index = n.parent.children.indexOf(n)
n.parent.children.splice(index, 1, ...nodeChildren) n.parent.children.splice(index, 1, ...nodeChildren)