Skip to content
This repository was archived by the owner on Aug 7, 2023. It is now read-only.

Commit cff8996

Browse files
committed
Check against invalid TextEditors
Guard against invalid `TextEditor`s, and ones without a path. Fixes #162.
1 parent d8dc5b7 commit cff8996

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

lib/index.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,23 @@ export function provideLinter() {
5151
scope: 'file',
5252
lintOnFly: true,
5353
lint: async (editor) => {
54-
const { HTMLHint } = require('htmlhint');
54+
if (!atom.workspace.isTextEditor(editor)) {
55+
return null;
56+
}
5557

56-
const fileText = editor.getText();
5758
const filePath = editor.getPath();
59+
if (!filePath) {
60+
// Invalid path
61+
return null;
62+
}
5863

64+
const fileText = editor.getText();
5965
if (!fileText) {
6066
return [];
6167
}
6268

69+
const { HTMLHint } = require('htmlhint');
70+
6371
const ruleset = await getConfig(filePath);
6472

6573
const messages = HTMLHint.verify(fileText, ruleset || undefined);

0 commit comments

Comments
 (0)