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

Commit fc236cf

Browse files
authored
Merge pull request #211 from AtomLinter/arcanemagus/linter-v2
Upgrade to Linter v2 API
2 parents 9d59886 + eece17d commit fc236cf

File tree

6 files changed

+89
-94
lines changed

6 files changed

+89
-94
lines changed

lib/main.coffee

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ module.exports =
9494
name: 'sass-lint'
9595
grammarScopes: ['source.css.scss', 'source.scss', 'source.css.sass', 'source.sass']
9696
scope: 'file'
97-
lintOnFly: true
97+
lintsOnChange: true
9898
lint: (editor) =>
9999
{find} = require 'atom-linter'
100100
helpers = require './helpers'
@@ -136,10 +136,12 @@ module.exports =
136136

137137
if config is null and @noConfigDisable is false
138138
return [
139-
type: 'Info'
140-
text: 'No .sass-lint.yml config file detected or specified. Please check your settings'
141-
filePath: filePath
142-
range: [[0, 0], [0, 0]]
139+
severity: 'info'
140+
excerpt: 'No .sass-lint.yml config file detected or specified. Please check your settings'
141+
location: {
142+
file: filePath
143+
position: [[0, 0], [0, 0]]
144+
}
143145
]
144146

145147
else if config is null and @noConfigDisable is true
@@ -165,34 +167,40 @@ module.exports =
165167
colEndIdx = if line then line.length else 1
166168

167169
return [
168-
type: 'Error'
169-
text: text
170-
filePath: filePath
171-
range: [[lineIdx, 0], [lineIdx, colEndIdx]]
170+
severity: 'error'
171+
excerpt: text
172+
location: {
173+
file: filePath
174+
position: [[lineIdx, 0], [lineIdx, colEndIdx]]
175+
}
172176
]
173177
else
174178
# Leaving this here to allow people to report the errors
175179
console.log('linter-sass-lint', error)
176180
return [
177-
type: 'Error'
178-
text: 'Unexpected parse error in file'
179-
filePath: filePath
180-
range: [[lineIdx, 0], [lineIdx, colEndIdx]]
181+
severity: 'error'
182+
excerpt: 'Unexpected parse error in file'
183+
location: {
184+
file: filePath
185+
position: [[lineIdx, 0], [lineIdx, colEndIdx]]
186+
}
181187
]
182188
return []
183189

184190
if result then return result.messages.map (msg) ->
185191
line = if msg.line then msg.line - 1 else 0
186192
col = if msg.column then msg.column - 1 else 0
187-
text = if msg.message then ' ' + msg.message else 'Unknown Error'
193+
text = if msg.message then msg.message + ' (' + msg.ruleId + ')' else 'Unknown Error'
188194
ruleHref = helpers.getRuleURI(msg.ruleId)
189-
html = '<a href="'+ ruleHref + '" class="badge badge-flexible sass-lint">' + msg.ruleId + '</a>' + text
190195

191196
result = {
192-
type: if msg.severity is 1 then 'Warning' else if msg.severity is 2 then 'Error' else 'Info',
193-
html,
194-
filePath: filePath,
195-
range: [[line, col], [line, col + 1]]
197+
severity: if msg.severity is 1 then 'warning' else if msg.severity is 2 then 'error' else 'info',
198+
excerpt: text,
199+
url: ruleHref
200+
location: {
201+
file: filePath,
202+
position: [[line, col], [line, col + 1]]
203+
}
196204
}
197205

198206
return result

spec/linter-sass-lint-path-options-spec.js

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -32,28 +32,26 @@ describe('The sass-lint provider for Linter - path options', () => {
3232

3333
it('verifies the first message', () => {
3434
const slDocUrl = 'https://github.com/sasstools/sass-lint/tree/master/docs/rules/no-ids.md';
35-
const attributes = `href="${slDocUrl}" class="badge badge-flexible sass-lint"`;
36-
const warningMarkup = `<a ${attributes}>no-ids</a>`;
37-
const warnId = ' ID selectors not allowed';
38-
39-
expect(messages[0].type).toBe('Error');
40-
expect(messages[0].text).not.toBeDefined();
41-
expect(messages[0].html).toBe(`${warningMarkup}${warnId}`);
42-
expect(messages[0].filePath).toBe(failurePath);
43-
expect(messages[0].range).toEqual([[0, 0], [0, 1]]);
35+
const warnId = 'ID selectors not allowed (no-ids)';
36+
37+
expect(messages[0].severity).toBe('error');
38+
expect(messages[0].description).not.toBeDefined();
39+
expect(messages[0].url).toBe(slDocUrl);
40+
expect(messages[0].excerpt).toBe(warnId);
41+
expect(messages[0].location.file).toBe(failurePath);
42+
expect(messages[0].location.position).toEqual([[0, 0], [0, 1]]);
4443
});
4544

4645
it('verifies the second message', () => {
4746
const slDocUrl = 'https://github.com/sasstools/sass-lint/tree/master/docs/rules/no-color-literals.md';
48-
const attributes = `href="${slDocUrl}" class="badge badge-flexible sass-lint"`;
49-
const warningMarkup = `<a ${attributes}>no-color-literals</a>`;
50-
const warnId = ' Color literals such as \'red\' should only be used in variable declarations';
51-
52-
expect(messages[1].type).toBe('Warning');
53-
expect(messages[1].text).not.toBeDefined();
54-
expect(messages[1].html).toBe(`${warningMarkup}${warnId}`);
55-
expect(messages[1].filePath).toBe(failurePath);
56-
expect(messages[1].range).toEqual([[1, 9], [1, 10]]);
47+
const warnId = 'Color literals such as \'red\' should only be used in variable declarations (no-color-literals)';
48+
49+
expect(messages[1].severity).toBe('warning');
50+
expect(messages[1].description).not.toBeDefined();
51+
expect(messages[1].url).toBe(slDocUrl);
52+
expect(messages[1].excerpt).toBe(warnId);
53+
expect(messages[1].location.file).toBe(failurePath);
54+
expect(messages[1].location.position).toEqual([[1, 9], [1, 10]]);
5755
});
5856
});
5957
});

spec/linter-sass-lint-resolve-spec.js

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -33,28 +33,26 @@ describe('The sass-lint provider for Linter - resolve paths relative to config f
3333

3434
it('verifies the first message', () => {
3535
const slDocUrl = 'https://github.com/sasstools/sass-lint/tree/master/docs/rules/no-ids.md';
36-
const attributes = `href="${slDocUrl}" class="badge badge-flexible sass-lint"`;
37-
const warningMarkup = `<a ${attributes}>no-ids</a>`;
38-
const warnId = ' ID selectors not allowed';
36+
const warnId = 'ID selectors not allowed (no-ids)';
3937

40-
expect(messages[0].type).toBe('Error');
41-
expect(messages[0].text).not.toBeDefined();
42-
expect(messages[0].html).toBe(`${warningMarkup}${warnId}`);
43-
expect(messages[0].filePath).toBe(ignoredPath);
44-
expect(messages[0].range).toEqual([[0, 0], [0, 1]]);
38+
expect(messages[0].severity).toBe('error');
39+
expect(messages[0].description).not.toBeDefined();
40+
expect(messages[0].url).toBe(slDocUrl);
41+
expect(messages[0].excerpt).toBe(warnId);
42+
expect(messages[0].location.file).toBe(ignoredPath);
43+
expect(messages[0].location.position).toEqual([[0, 0], [0, 1]]);
4544
});
4645

4746
it('verifies the second message', () => {
4847
const slDocUrl = 'https://github.com/sasstools/sass-lint/tree/master/docs/rules/no-color-literals.md';
49-
const attributes = `href="${slDocUrl}" class="badge badge-flexible sass-lint"`;
50-
const warningMarkup = `<a ${attributes}>no-color-literals</a>`;
51-
const warnId = ' Color literals such as \'red\' should only be used in variable declarations';
48+
const warnId = 'Color literals such as \'red\' should only be used in variable declarations (no-color-literals)';
5249

53-
expect(messages[1].type).toBe('Warning');
54-
expect(messages[1].text).not.toBeDefined();
55-
expect(messages[1].html).toBe(`${warningMarkup}${warnId}`);
56-
expect(messages[1].filePath).toBe(ignoredPath);
57-
expect(messages[1].range).toEqual([[1, 9], [1, 10]]);
50+
expect(messages[1].severity).toBe('warning');
51+
expect(messages[1].description).not.toBeDefined();
52+
expect(messages[1].url).toBe(slDocUrl);
53+
expect(messages[1].excerpt).toBe(warnId);
54+
expect(messages[1].location.file).toBe(ignoredPath);
55+
expect(messages[1].location.position).toEqual([[1, 9], [1, 10]]);
5856
});
5957
});
6058

spec/linter-sass-lint-sass-spec.js

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -33,28 +33,26 @@ describe('The sass-lint provider for Linter - sass', () => {
3333

3434
it('verifies the first message', () => {
3535
const slDocUrl = 'https://github.com/sasstools/sass-lint/tree/master/docs/rules/no-ids.md';
36-
const attributes = `href="${slDocUrl}" class="badge badge-flexible sass-lint"`;
37-
const warningMarkup = `<a ${attributes}>no-ids</a>`;
38-
const warnId = ' ID selectors not allowed';
39-
40-
expect(messages[0].type).toEqual('Error');
41-
expect(messages[0].text).not.toBeDefined();
42-
expect(messages[0].html).toBe(`${warningMarkup}${warnId}`);
43-
expect(messages[0].filePath).toBe(failurePath);
44-
expect(messages[0].range).toEqual([[0, 0], [0, 1]]);
36+
const warnId = 'ID selectors not allowed (no-ids)';
37+
38+
expect(messages[0].severity).toBe('error');
39+
expect(messages[0].description).not.toBeDefined();
40+
expect(messages[0].url).toBe(slDocUrl);
41+
expect(messages[0].excerpt).toBe(warnId);
42+
expect(messages[0].location.file).toBe(failurePath);
43+
expect(messages[0].location.position).toEqual([[0, 0], [0, 1]]);
4544
});
4645

4746
it('verifies the second message', () => {
4847
const slDocUrl = 'https://github.com/sasstools/sass-lint/tree/master/docs/rules/no-color-literals.md';
49-
const attributes = `href="${slDocUrl}" class="badge badge-flexible sass-lint"`;
50-
const warningMarkup = `<a ${attributes}>no-color-literals</a>`;
51-
const warnId = ' Color literals such as \'red\' should only be used in variable declarations';
52-
53-
expect(messages[1].type).toEqual('Warning');
54-
expect(messages[1].text).not.toBeDefined();
55-
expect(messages[1].html).toBe(`${warningMarkup}${warnId}`);
56-
expect(messages[1].filePath).toBe(failurePath);
57-
expect(messages[1].range).toEqual([[1, 9], [1, 10]]);
48+
const warnId = 'Color literals such as \'red\' should only be used in variable declarations (no-color-literals)';
49+
50+
expect(messages[1].severity).toBe('warning');
51+
expect(messages[1].description).not.toBeDefined();
52+
expect(messages[1].url).toBe(slDocUrl);
53+
expect(messages[1].excerpt).toBe(warnId);
54+
expect(messages[1].location.file).toBe(failurePath);
55+
expect(messages[1].location.position).toEqual([[1, 9], [1, 10]]);
5856
});
5957
});
6058

spec/linter-sass-lint-scss-spec.js

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -33,28 +33,26 @@ describe('The sass-lint provider for Linter - scss', () => {
3333

3434
it('verifies the first message', () => {
3535
const slDocUrl = 'https://github.com/sasstools/sass-lint/tree/master/docs/rules/no-ids.md';
36-
const attributes = `href="${slDocUrl}" class="badge badge-flexible sass-lint"`;
37-
const warningMarkup = `<a ${attributes}>no-ids</a>`;
38-
const warnId = ' ID selectors not allowed';
39-
40-
expect(messages[0].type).toBe('Error');
41-
expect(messages[0].text).not.toBeDefined();
42-
expect(messages[0].html).toBe(`${warningMarkup}${warnId}`);
43-
expect(messages[0].filePath).toBe(failurePath);
44-
expect(messages[0].range).toEqual([[0, 0], [0, 1]]);
36+
const warnId = 'ID selectors not allowed (no-ids)';
37+
38+
expect(messages[0].severity).toBe('error');
39+
expect(messages[0].description).not.toBeDefined();
40+
expect(messages[0].url).toBe(slDocUrl);
41+
expect(messages[0].excerpt).toBe(warnId);
42+
expect(messages[0].location.file).toBe(failurePath);
43+
expect(messages[0].location.position).toEqual([[0, 0], [0, 1]]);
4544
});
4645

4746
it('verifies the second message', () => {
4847
const slDocUrl = 'https://github.com/sasstools/sass-lint/tree/master/docs/rules/no-color-literals.md';
49-
const attributes = `href="${slDocUrl}" class="badge badge-flexible sass-lint"`;
50-
const warningMarkup = `<a ${attributes}>no-color-literals</a>`;
51-
const warnId = ' Color literals such as \'red\' should only be used in variable declarations';
52-
53-
expect(messages[1].type).toBe('Warning');
54-
expect(messages[1].text).not.toBeDefined();
55-
expect(messages[1].html).toBe(`${warningMarkup}${warnId}`);
56-
expect(messages[1].filePath).toBe(failurePath);
57-
expect(messages[1].range).toEqual([[1, 9], [1, 10]]);
48+
const warnId = 'Color literals such as \'red\' should only be used in variable declarations (no-color-literals)';
49+
50+
expect(messages[1].severity).toBe('warning');
51+
expect(messages[1].description).not.toBeDefined();
52+
expect(messages[1].url).toBe(slDocUrl);
53+
expect(messages[1].excerpt).toBe(warnId);
54+
expect(messages[1].location.file).toBe(failurePath);
55+
expect(messages[1].location.position).toEqual([[1, 9], [1, 10]]);
5856
});
5957
});
6058

styles/atom-text-editor.less

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)