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

Commit

Permalink
Guard against invalid TextEditor and empty paths
Browse files Browse the repository at this point in the history
Occasionally `lint()` somehow gets called with invalid `TextEditor`s, or
ones without a path. When these cases are hit simply return `null`
instead of trying to process them.

Fixes #527.
  • Loading branch information
Arcanemagus committed Dec 6, 2017
1 parent 4311397 commit f0e03bb
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,11 +179,21 @@ export default {
scope: 'file',
lintOnFly: true,
lint: async (textEditor) => {
loadDeps();
if (!atom.workspace.isTextEditor(textEditor)) {
// Invalid TextEditor
return null;
}

const filePath = textEditor.getPath();
if (!filePath) {
// Invalid path
return null;
}
const fileText = textEditor.getText();

// Load dependencies if they aren't already
loadDeps();

const parameters = ['--format=default'];

const projectPath = atom.project.relativizePath(filePath)[0];
Expand Down

0 comments on commit f0e03bb

Please sign in to comment.