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

Commit d916068

Browse files
authored
Merge pull request #109 from AtomLinter/arcanemagus/check-path
Verify valid TextEditor and path
2 parents ec4a638 + ebf31dc commit d916068

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

lib/main.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,18 +44,29 @@ export default {
4444
scope: 'file',
4545
lintOnFly: true,
4646
lint: (textEditor) => {
47+
if (!atom.workspace.isTextEditor(textEditor)) {
48+
return null;
49+
}
50+
4751
const filePath = textEditor.getPath();
52+
if (!filePath) {
53+
// TextEditor has no path associated with it (yet)
54+
return null;
55+
}
56+
4857
const fileExt = path.extname(filePath);
4958
if (fileExt === '.zsh' || fileExt === '.zsh-theme') {
5059
// shellcheck does not support zsh
5160
return [];
5261
}
62+
5363
const text = textEditor.getText();
5464
const cwd = path.dirname(filePath);
5565
const showAll = this.enableNotice;
5666
// The first -f parameter overrides any others
5767
const parameters = [].concat(['-f', 'gcc'], this.userParameters, ['-']);
5868
const options = { stdin: text, cwd, ignoreExitCode: true };
69+
5970
return helpers.exec(this.executablePath, parameters, options).then((output) => {
6071
if (textEditor.getText() !== text) {
6172
// The text has changed since the lint was triggered, tell Linter not to update

0 commit comments

Comments
 (0)