This repository has been archived by the owner on Aug 7, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #101 from AtomLinter/resolve-relative-paths
Resolve relative paths
- Loading branch information
Showing
5 changed files
with
111 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
options: | ||
formatter: json | ||
merge-default-rules: false | ||
files: | ||
include: '../files/ignored.scss' | ||
rules: | ||
no-color-literals: 1 | ||
no-ids: 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
'use babel'; | ||
const lint = require('../lib/main.coffee').provideLinter().lint; | ||
|
||
describe('The sass-lint provider for Linter - resolve paths relative to config file', () => { | ||
const configFile = `${__dirname}/fixtures/config/.relative-config.yml`; | ||
|
||
beforeEach(() => { | ||
atom.workspace.destroyActivePaneItem(); | ||
waitsForPromise(() => { | ||
atom.packages.activatePackage('linter-sass-lint'); | ||
return atom.packages.activatePackage('language-sass'); | ||
}); | ||
}); | ||
describe('checks ignored.scss and', () => { | ||
let editor = null; | ||
beforeEach(() => { | ||
waitsForPromise(() => { | ||
atom.config.set('linter-sass-lint.configFile', configFile); | ||
atom.config.set('linter-sass-lint.resolvePathsRelativeToConfig', true); | ||
return atom.workspace.open(`${__dirname}/fixtures/files/ignored.scss`).then(openEditor => { | ||
editor = openEditor; | ||
}); | ||
}); | ||
}); | ||
|
||
it('finds at least one message', () => { | ||
const messages = lint(editor); | ||
expect(messages.length).toBeGreaterThan(0); | ||
}); | ||
|
||
it('verifies the first message', () => { | ||
const messages = lint(editor); | ||
const slDocUrl = 'https://github.com/sasstools/sass-lint/tree/master/docs/rules/no-ids.md'; | ||
const attributes = `href="${slDocUrl}" class="badge badge-flexible sass-lint"`; | ||
const warningMarkup = `<a ${attributes}>no-ids</a>`; | ||
const warnId = ' ID selectors not allowed'; | ||
expect(messages[0].type).toBeDefined(); | ||
expect(messages[0].type).toEqual('Error'); | ||
expect(messages[0].html).toBeDefined(); | ||
expect(messages[0].html).toEqual(`${warningMarkup}${warnId}`); | ||
expect(messages[0].filePath).toBeDefined(); | ||
expect(messages[0].filePath).toMatch(/.+ignored\.scss$/); | ||
expect(messages[0].range).toBeDefined(); | ||
expect(messages[0].range.length).toEqual(2); | ||
expect(messages[0].range).toEqual([[0, 0], [0, 1]]); | ||
}); | ||
|
||
it('verifies the second message', () => { | ||
const messages = lint(editor); | ||
const slDocUrl = 'https://github.com/sasstools/sass-lint/tree/master/docs/rules/no-color-literals.md'; | ||
const attributes = `href="${slDocUrl}" class="badge badge-flexible sass-lint"`; | ||
const warningMarkup = `<a ${attributes}>no-color-literals</a>`; | ||
const warnId = ' Color literals such as \'red\' should only be used in variable declarations'; | ||
expect(messages[1].type).toBeDefined(); | ||
expect(messages[1].type).toEqual('Warning'); | ||
expect(messages[1].html).toBeDefined(); | ||
expect(messages[1].html).toEqual(`${warningMarkup}${warnId}`); | ||
expect(messages[1].filePath).toBeDefined(); | ||
expect(messages[1].filePath).toMatch(/.+ignored\.scss$/); | ||
expect(messages[1].range).toBeDefined(); | ||
expect(messages[1].range.length).toEqual(2); | ||
expect(messages[1].range).toEqual([[1, 9], [1, 10]]); | ||
}); | ||
}); | ||
|
||
describe('checks failure.scss and', () => { | ||
let editor = null; | ||
beforeEach(() => { | ||
waitsForPromise(() => { | ||
atom.config.set('linter-sass-lint.configFile', configFile); | ||
return atom.workspace.open(`${__dirname}/fixtures/files/failure.scss`).then(openEditor => { | ||
editor = openEditor; | ||
}); | ||
}); | ||
}); | ||
|
||
it('finds nothing wrong with the valid file', () => { | ||
const messages = lint(editor); | ||
expect(messages.length).toEqual(0); | ||
}); | ||
}); | ||
}); |