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

Commit

Permalink
Merge pull request #94 from vzamanillo/v2-linter-api-support
Browse files Browse the repository at this point in the history
V2 linter API support
  • Loading branch information
Arcanemagus authored Jan 28, 2019
2 parents bc85ee1 + b440bbf commit d396e5a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
12 changes: 7 additions & 5 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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])
}
}]);
}

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,12 @@
}
},
"package-deps": [
"linter"
"linter:2.0.0"
],
"providedServices": {
"linter": {
"versions": {
"1.0.0": "provideLinter"
"2.0.0": "provideLinter"
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions spec/linter-jsonlint-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
});
Expand Down

0 comments on commit d396e5a

Please sign in to comment.