Fix TypeScript errors and build plugin

- Add proper type annotation for node variable
- Add null check in forEach callback
- Plugin now builds successfully

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-11-26 10:21:46 +01:00
parent ff1298c7d3
commit 5f5f2f63ba
2 changed files with 6 additions and 4 deletions

View File

@@ -4,7 +4,9 @@
"Bash(git init:*)",
"Bash(git add:*)",
"Bash(git commit:*)",
"Bash(git remote add:*)"
"Bash(git remote add:*)",
"Bash(npm install:*)",
"Bash(npm run build:*)"
],
"deny": [],
"ask": []

View File

@@ -28,14 +28,14 @@ export default class CounterPlugin extends Plugin {
const walker = document.createTreeWalker(element, NodeFilter.SHOW_TEXT);
const nodesToReplace: Array<{ node: Node; parent: Node }> = [];
let node;
while ((node = walker.nextNode())) {
let node: Node | null;
while ((node = walker.nextNode()) !== null) {
const text = node.textContent || '';
const lines = text.split('\n');
lines.forEach((line, index) => {
const match = line.match(counterRegex);
if (match) {
if (match && node) {
nodesToReplace.push({ node, parent: node.parentNode! });
}
});