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

Commit 28c5eaa

Browse files
authored
Merge pull request #85 from mauricerkelly/migrate-to-linter-2.0
Update to use Linter v2 provider and message formats
2 parents cf3ea35 + 9a0ad6c commit 28c5eaa

File tree

3 files changed

+28
-31
lines changed

3 files changed

+28
-31
lines changed

lib/init.js

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,11 @@ const parseError = async (toParse, sourceFilePath) => {
109109
const projectPath = await elixirProjectPath(sourceFilePath);
110110
let reResult = re.exec(toParse);
111111
while (reResult !== null) {
112-
let text;
112+
let excerpt;
113113
let filePath;
114114
let range;
115115
if (reResult[2] !== undefined) {
116-
text = `(${reResult[1]}) ${reResult[2]}`;
116+
excerpt = `(${reResult[1]}) ${reResult[2]}`;
117117
filePath = join(projectPath, reResult[3]);
118118
const fileEditor = findTextEditor(filePath);
119119
if (fileEditor) {
@@ -126,7 +126,7 @@ const parseError = async (toParse, sourceFilePath) => {
126126
range = new Range([reResult[4] - 1, 0], [reResult[4] - 1, 1]);
127127
}
128128
} else {
129-
text = `(${reResult[1]}) ${reResult[7]}`;
129+
excerpt = `(${reResult[1]}) ${reResult[7]}`;
130130
filePath = join(projectPath, reResult[5]);
131131
const fileEditor = findTextEditor(filePath);
132132
if (fileEditor) {
@@ -136,10 +136,9 @@ const parseError = async (toParse, sourceFilePath) => {
136136
}
137137
}
138138
messages.push({
139-
type: 'Error',
140-
text,
141-
filePath,
142-
range,
139+
severity: 'error',
140+
excerpt,
141+
location: { file: filePath, position: range },
143142
});
144143
reResult = re.exec(toParse);
145144
}
@@ -170,10 +169,9 @@ const parseWarning = async (toParse, sourceFilePath) => {
170169
range = new Range([reResult[3] - 1, 0], [reResult[3] - 1, 1]);
171170
}
172171
messages.push({
173-
type: 'Warning',
174-
text: reResult[1],
175-
filePath,
176-
range,
172+
severity: 'warning',
173+
excerpt: reResult[1],
174+
location: { file: filePath, position: range },
177175
});
178176
} catch (Error) {
179177
// eslint-disable-next-line no-console
@@ -209,10 +207,9 @@ const parseLegacyWarning = async (toParse, sourceFilePath) => {
209207
range = new Range([reResult[3] - 1, 0], [reResult[3] - 1, 1]);
210208
}
211209
messages.push({
212-
type: 'Warning',
213-
text: reResult[3],
214-
filePath,
215-
range,
210+
severity: 'warning',
211+
excerpt: reResult[3],
212+
location: { file: filePath, position: range },
216213
});
217214
} catch (Error) {
218215
// eslint-disable-next-line no-console
@@ -339,7 +336,7 @@ export default {
339336
return {
340337
grammarScopes: ['source.elixir'],
341338
scope: 'project',
342-
lintOnFly: false,
339+
lintsOnChange: false,
343340
name: 'Elixir',
344341
async lint(textEditor) {
345342
const filePath = textEditor.getPath();

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,17 @@
3636
"providedServices": {
3737
"linter": {
3838
"versions": {
39-
"1.0.0": "provideLinter"
39+
"2.0.0": "provideLinter"
4040
}
4141
}
4242
},
4343
"package-deps": [
44-
"linter",
44+
"linter:2.0.0",
4545
"language-elixir"
4646
],
4747
"dependencies": {
4848
"atom-linter": "^9.0.0",
49-
"atom-package-deps": "^4.0.1",
49+
"atom-package-deps": "^4.5.0",
5050
"tmp": "^0.0.31"
5151
},
5252
"devDependencies": {

spec/linter-elixirc-spec.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ describe('The elixirc provider for Linter', () => {
2525
waitsForPromise(() =>
2626
atom.workspace.open(errorMode1Path).then(editor => lint(editor)).then((messages) => {
2727
expect(messages.length).toBe(1);
28-
expect(messages[0].type).toBe('Error');
28+
expect(messages[0].severity).toBe('error');
2929
expect(messages[0].html).not.toBeDefined();
30-
expect(messages[0].text).toBe('(ArgumentError) Dangerous is not available');
31-
expect(messages[0].filePath).toBe(errorMode1Path);
32-
expect(messages[0].range).toEqual([[1, 0], [1, 32]]);
30+
expect(messages[0].excerpt).toBe('(ArgumentError) Dangerous is not available');
31+
expect(messages[0].location.file).toBe(errorMode1Path);
32+
expect(messages[0].location.position).toEqual([[1, 0], [1, 32]]);
3333
}),
3434
);
3535
});
@@ -38,11 +38,11 @@ describe('The elixirc provider for Linter', () => {
3838
waitsForPromise(() =>
3939
atom.workspace.open(errorMode2Path).then(editor => lint(editor)).then((messages) => {
4040
expect(messages.length).toBe(1);
41-
expect(messages[0].type).toBe('Error');
41+
expect(messages[0].severity).toBe('error');
4242
expect(messages[0].html).not.toBeDefined();
43-
expect(messages[0].text).toBe('(CompileError) module Usefulness is not loaded and could not be found');
44-
expect(messages[0].filePath).toBe(errorMode2Path);
45-
expect(messages[0].range).toEqual([[3, 2], [3, 20]]);
43+
expect(messages[0].excerpt).toBe('(CompileError) module Usefulness is not loaded and could not be found');
44+
expect(messages[0].location.file).toBe(errorMode2Path);
45+
expect(messages[0].location.position).toEqual([[3, 2], [3, 20]]);
4646
}),
4747
);
4848
});
@@ -51,11 +51,11 @@ describe('The elixirc provider for Linter', () => {
5151
waitsForPromise(() =>
5252
atom.workspace.open(warningPath).then(editor => lint(editor)).then((messages) => {
5353
expect(messages.length).toBe(1);
54-
expect(messages[0].type).toBe('Warning');
54+
expect(messages[0].severity).toBe('warning');
5555
expect(messages[0].html).not.toBeDefined();
56-
expect(messages[0].text).toBe('variable "deps" does not exist and is being expanded to "deps()", please use parentheses to remove the ambiguity or change the variable name');
57-
expect(messages[0].filePath).toBe(warningPath);
58-
expect(messages[0].range).toEqual([[9, 5], [9, 16]]);
56+
expect(messages[0].excerpt).toBe('variable "deps" does not exist and is being expanded to "deps()", please use parentheses to remove the ambiguity or change the variable name');
57+
expect(messages[0].location.file).toBe(warningPath);
58+
expect(messages[0].location.position).toEqual([[9, 5], [9, 16]]);
5959
}),
6060
);
6161
});

0 commit comments

Comments
 (0)