From 575f21b1c93f1697ca73d7f1772933c6b147058a Mon Sep 17 00:00:00 2001 From: Clemens Solar Date: Sat, 4 May 2019 00:21:49 +0200 Subject: [PATCH 1/2] Add linter v2 integration --- lib/linter-integration.js | 32 +++++++++++++++++++++++++++----- package.json | 3 ++- 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/lib/linter-integration.js b/lib/linter-integration.js index 924dd14b..39040d8a 100644 --- a/lib/linter-integration.js +++ b/lib/linter-integration.js @@ -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) { @@ -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, @@ -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); + } } } diff --git a/package.json b/package.json index 8a6b52be..f21a8399 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,8 @@ }, "linter-indie": { "versions": { - "1.0.0": "consumeLinterRegistry" + "^1.0.0": "consumeLinterRegistry", + "^2.0.0": "consumeLinterRegistry" } } }, From ffbc4946ebda4b6ac41290e3e17fbef4e1afcd57 Mon Sep 17 00:00:00 2001 From: Clemens Solar Date: Sat, 4 May 2019 16:33:49 +0200 Subject: [PATCH 2/2] Remove dangling comma --- lib/linter-integration.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/linter-integration.js b/lib/linter-integration.js index 39040d8a..e04a5f5b 100644 --- a/lib/linter-integration.js +++ b/lib/linter-integration.js @@ -59,7 +59,7 @@ class Linter { file: normalizePath(match.file), position: extractRange(match) }, - excerpt: !match.message && !match.html_message ? 'Error from build' : match.message, + excerpt: !match.message && !match.html_message ? 'Error from build' : match.message })); if (this.linter.setAllMessages) {