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:
@@ -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": []
|
||||
|
||||
6
main.ts
6
main.ts
@@ -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! });
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user