From 88f8f82745ee410c16e65399742fca31f253e949 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Zamanillo?= Date: Mon, 28 Jan 2019 11:36:59 +0100 Subject: [PATCH 1/4] V2 linter API support --- lib/index.js | 10 ++++++---- package.json | 4 ++-- spec/linter-jsonlint-spec.js | 8 ++++---- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/lib/index.js b/lib/index.js index 0f0a360..34c450c 100644 --- a/lib/index.js +++ b/lib/index.js @@ -28,10 +28,12 @@ export function provideLinter() { const column = 0; return Promise.resolve([{ - type: 'Error', - text: message, - filePath: path, - range: new Range([line, column], [line, column + 1]) + severity: 'error', + excerpt: message, + location: { + file: path, + position: new Range([line, column], [line, column + 1]) + } }]); } diff --git a/package.json b/package.json index 284b76c..1e8c84d 100644 --- a/package.json +++ b/package.json @@ -59,12 +59,12 @@ } }, "package-deps": [ - "linter" + "linter:2.0.0" ], "providedServices": { "linter": { "versions": { - "1.0.0": "provideLinter" + "2.0.0": "provideLinter" } } } diff --git a/spec/linter-jsonlint-spec.js b/spec/linter-jsonlint-spec.js index d1a3af1..f20db3c 100644 --- a/spec/linter-jsonlint-spec.js +++ b/spec/linter-jsonlint-spec.js @@ -34,13 +34,13 @@ describe('The jsonlint provider for Linter', () => { it('verifies the first message', () => { waitsForPromise(() => lint(editor).then((messages) => { - expect(messages[0].type).toEqual('Error'); - expect(messages[0].text).toEqual(`Parse error on line 2: + expect(messages[0].severity).toEqual('error'); + expect(messages[0].excerpt).toEqual(`Parse error on line 2: { "key": 1 + 2} ------------^ Expecting 'EOF', '}', ',', ']', got 'undefined'`); - expect(messages[0].filePath).toMatch(/.+bad\.json$/); - expect(messages[0].range).toEqual({ + expect(messages[0].location.file).toMatch(/.+bad\.json$/); + expect(messages[0].location.position).toEqual({ start: { row: 2, column: 0 }, end: { row: 2, column: 1 } }); From 60ff261a5ec9bb7043c7cd0da625bc7a5d4f5029 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Zamanillo?= Date: Mon, 28 Jan 2019 11:40:49 +0100 Subject: [PATCH 2/4] Fixed Missing trailing comma comma-dangle --- lib/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/index.js b/lib/index.js index 34c450c..6e36867 100644 --- a/lib/index.js +++ b/lib/index.js @@ -32,8 +32,8 @@ export function provideLinter() { excerpt: message, location: { file: path, - position: new Range([line, column], [line, column + 1]) - } + position: new Range([line, column], [line, column + 1]), + }, }]); } From 5d2825ad2729b22453933118792a7f83a5421f17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Zamanillo?= Date: Mon, 28 Jan 2019 11:40:49 +0100 Subject: [PATCH 3/4] Revert "Fixed Missing trailing comma comma-dangle" This reverts commit 60ff261a5ec9bb7043c7cd0da625bc7a5d4f5029. --- lib/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/index.js b/lib/index.js index 6e36867..34c450c 100644 --- a/lib/index.js +++ b/lib/index.js @@ -32,8 +32,8 @@ export function provideLinter() { excerpt: message, location: { file: path, - position: new Range([line, column], [line, column + 1]), - }, + position: new Range([line, column], [line, column + 1]) + } }]); } From b440bbf5f7b0208b64b077006e924883c5f62fa8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Zamanillo?= Date: Mon, 28 Jan 2019 11:46:28 +0100 Subject: [PATCH 4/4] Forgotten lintOnFly => lintsOnChange --- lib/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/index.js b/lib/index.js index 34c450c..6b36dad 100644 --- a/lib/index.js +++ b/lib/index.js @@ -15,7 +15,7 @@ export function provideLinter() { name: 'JSON Lint', grammarScopes: ['source.json'], scope: 'file', - lintOnFly: true, + lintsOnChange: true, lint: (editor) => { const path = editor.getPath(); const text = editor.getText();