Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.DS_Store
npm-debug.log
/node_modules
53 changes: 34 additions & 19 deletions lib/linter-integration.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,32 @@
'use babel';

import { CompositeDisposable } from 'atom';

class Linter {
constructor(registry) {
this.linter = registry.register({ name: 'Build' });
const _this = this;
this.linter = registry({ name: 'Build' });
this.subscriptions = new CompositeDisposable();

// Setting and clearing messages per filePath
this.subscriptions.add(atom.workspace.observeTextEditors(function (textEditor) {
_this.editorPath = textEditor.getPath();
if (!_this.editorPath) {
return;
}
const subscription = textEditor.onDidDestroy(function () {
_this.subscriptions.remove(subscription);
_this.linter.setMessages(_this.editorPath, []);
});
_this.subscriptions.add(subscription);
}));
}
destroy() {
this.linter.dispose();
// this.linter.dispose();
this.subscriptions.dispose();
}
clear() {
this.linter.deleteMessages();
this.linter.clearMessages();
}
processMessages(messages, cwd) {
function extractRange(json) {
Expand All @@ -29,22 +47,19 @@ class Linter {
default: return null;
}
}
this.linter.setMessages(messages.map(match => ({
type: match.type || 'Error',
text: !match.message && !match.html_message ? 'Error from build' : match.message,
html: match.message ? undefined : match.html_message,
filePath: normalizePath(match.file),
severity: typeToSeverity(match.type),
range: extractRange(match),
trace: match.trace && match.trace.map(trace => ({
type: trace.type || 'Trace',
text: !trace.message && !trace.html_message ? 'Trace in build' : trace.message,
html: trace.message ? undefined : trace.html_message,
filePath: trace.file && normalizePath(trace.file),
severity: typeToSeverity(trace.type) || 'info',
range: extractRange(trace)
}))
})));
this.linter.setMessages(this.editorPath, (messages.map(match => ({
severity: typeToSeverity(match.type) || 'info',
location: {
file: normalizePath(match.file),
position: extractRange(match)
},
excerpt: !match.message && !match.html_message
? 'Error from build'
: match.message,
description: match.message
? undefined
: match.html_message
}))));
}
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
},
"linter-indie": {
"versions": {
"1.0.0": "consumeLinterRegistry"
"2.0.0": "consumeLinterRegistry"
}
}
},
Expand Down