Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add linter v2 integration #579

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
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
32 changes: 27 additions & 5 deletions lib/linter-integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,23 @@

class Linter {
constructor(registry) {
this.linter = registry.register({ name: 'Build' });
const options = { name: 'Build' };

if (registry.register) {
this.linter = registry.register(options);
} else {
this.linter = registry(options);
}
}
destroy() {
this.linter.dispose();
}
clear() {
this.linter.deleteMessages();
if (this.linter.clearMessages) {
this.linter.clearMessages();
} else {
this.linter.deleteMessages();
}
}
processMessages(messages, cwd) {
function extractRange(json) {
Expand All @@ -29,7 +39,8 @@ class Linter {
default: return null;
}
}
this.linter.setMessages(messages.map(match => ({

messages = 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,
Expand All @@ -43,8 +54,19 @@ class Linter {
filePath: trace.file && normalizePath(trace.file),
severity: typeToSeverity(trace.type) || 'info',
range: extractRange(trace)
}))
})));
})),
location: {
file: normalizePath(match.file),
position: extractRange(match)
},
excerpt: !match.message && !match.html_message ? 'Error from build' : match.message
}));

if (this.linter.setAllMessages) {
this.linter.setAllMessages(messages);
} else {
this.linter.setMessages(messages);
}
}
}

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