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

Commit

Permalink
feat: update to Linter v2 API
Browse files Browse the repository at this point in the history
Update the Linter API to v2 so this provider isn't stuck in the past.
  • Loading branch information
Arcanemagus committed Jan 3, 2018
1 parent 211bb65 commit 2d9798a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
12 changes: 7 additions & 5 deletions lib/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,14 @@ module.exports = {

const linter = new (await getPugLint(projectDir))();
linter.configure(rules);
const results = linter.checkString(fileText);
const results = linter.checkString(fileText, filePath);
return results.map(res => ({
type: res.name,
filePath,
range: helpers.generateRange(textEditor, res.line - 1, res.column - 1),
text: res.msg,
severity: 'error',
location: {
file: res.filename,
position: helpers.generateRange(textEditor, res.line - 1, res.column - 1),
},
excerpt: res.msg,
}));
},
};
Expand Down
16 changes: 8 additions & 8 deletions spec/linter-stylint-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ describe('The pug-lint provider for Linter', () => {
const messages = await lint(editor);

expect(messages.length).toEqual(1);
expect(messages[0].html).not.toBeDefined();
expect(messages[0].text).toBe(errMsg);
expect(messages[0].filePath).toBe(badPug);
expect(messages[0].range).toEqual([[0, 13], [0, 20]]);
expect(messages[0].description).not.toBeDefined();
expect(messages[0].excerpt).toBe(errMsg);
expect(messages[0].location.file).toBe(badPug);
expect(messages[0].location.position).toEqual([[0, 13], [0, 20]]);
});
});

Expand All @@ -56,10 +56,10 @@ describe('The pug-lint provider for Linter', () => {
const messages = await lint(editor);

expect(messages.length).toEqual(1);
expect(messages[0].html).not.toBeDefined();
expect(messages[0].text).toBe(errMsg);
expect(messages[0].filePath).toBe(noConfigSyntax);
expect(messages[0].range).toEqual([[1, 0], [1, 0]]);
expect(messages[0].description).not.toBeDefined();
expect(messages[0].excerpt).toBe(errMsg);
expect(messages[0].location.file).toBe(noConfigSyntax);
expect(messages[0].location.position).toEqual([[1, 0], [1, 0]]);
});
});
});

0 comments on commit 2d9798a

Please sign in to comment.