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

Commit

Permalink
feat: support linting in vue single-file components with scss
Browse files Browse the repository at this point in the history
  • Loading branch information
jonboiser committed Jul 20, 2018
1 parent fba3d82 commit 4b64b4e
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ env:
global:
# Pre-install the required language file as package activation doesn't wait
# for the installation to complete.
- APM_TEST_PACKAGES="language-postcss"
- APM_TEST_PACKAGES="language-postcss language-vue"

jobs:
include:
Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
### Project specific config ###
environment:
APM_TEST_PACKAGES: language-postcss
APM_TEST_PACKAGES: language-postcss language-vue

matrix:
- ATOM_CHANNEL: stable
Expand Down
2 changes: 1 addition & 1 deletion circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ machine:
environment:
# Pre-install the required language file as package activation doesn't wait
# for the installation to complete.
APM_TEST_PACKAGES: "language-postcss"
APM_TEST_PACKAGES: "language-postcss language-vue"
3 changes: 2 additions & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ export default {
'source.less',
'source.css.less',
'source.css.postcss',
'source.css.postcss.sugarss'
'source.css.postcss.sugarss',
'source.css.scss.embedded.html'
];
},

Expand Down
5 changes: 5 additions & 0 deletions spec/fixtures/vue/.stylelintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"rules": {
"block-no-empty": true
}
}
9 changes: 9 additions & 0 deletions spec/fixtures/vue/badSCSS.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<template></template>


<script></script>


<style lang="scss" scoped>
a {}
</style>
11 changes: 11 additions & 0 deletions spec/fixtures/vue/goodSCSS.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<template></template>


<script></script>


<style lang="scss" scoped>
a {
color: red;
}
</style>
26 changes: 26 additions & 0 deletions spec/linter-stylelint-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -249,4 +249,30 @@ describe('The stylelint provider for Linter', () => {
expect(messages.length).toBe(0);
});
});

describe('works with Vue Single File Components', () => {
const goodVueSCSS = path.join(fixtures, 'vue', 'goodSCSS.vue');
const badVueSCSS = path.join(fixtures, 'vue', 'badSCSS.vue');

beforeEach(async () => {
await atom.packages.activatePackage('language-vue');
});

it('shows lint messages when found', async () => {
const editor = await atom.workspace.open(badVueSCSS);
const messages = await lint(editor);

expect(messages[0].severity).toBe('error');
expect(messages[0].excerpt).toBe(blockNoEmpty);
expect(messages[0].url).toBe(blockNoEmptyUrl);
expect(messages[0].location.file).toBe(badVueSCSS);
expect(messages[0].location.position).toEqual([[7, 2], [7, 4]]);
});

it('finds nothing wrong with a valid file', async () => {
const editor = await atom.workspace.open(goodVueSCSS);
const messages = await lint(editor);
expect(messages.length).toBe(0);
});
});
});

0 comments on commit 4b64b4e

Please sign in to comment.