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

Commit 7e5ad9a

Browse files
committed
feat: support linting in vue single-file components with scss
1 parent ffc6c49 commit 7e5ad9a

File tree

9 files changed

+70
-4
lines changed

9 files changed

+70
-4
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ defaults: &defaults
77
environment:
88
# Pre-install the required language file as package activation doesn't wait
99
# for the installation to complete.
10-
APM_TEST_PACKAGES: "language-postcss"
10+
APM_TEST_PACKAGES: "language-postcss language-vue"
1111
steps:
1212
# Restore project state
1313
- attach_workspace:

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ env:
88
global:
99
# Pre-install the required language file as package activation doesn't wait
1010
# for the installation to complete.
11-
- APM_TEST_PACKAGES="language-postcss"
11+
- APM_TEST_PACKAGES="language-postcss language-vue"
1212

1313
jobs:
1414
include:

appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
### Project specific config ###
22
environment:
3-
APM_TEST_PACKAGES: language-postcss
3+
APM_TEST_PACKAGES: language-postcss language-vue
44

55
matrix:
66
- ATOM_CHANNEL: stable

circle.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
dependencies:
2+
override:
3+
- curl -s -O https://raw.githubusercontent.com/atom/ci/master/build-package.sh
4+
- chmod u+x build-package.sh
5+
6+
test:
7+
override:
8+
- ./build-package.sh
9+
10+
machine:
11+
environment:
12+
# Pre-install the required language file as package activation doesn't wait
13+
# for the installation to complete.
14+
APM_TEST_PACKAGES: "language-postcss language-vue"

lib/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ export default {
6767
'source.less',
6868
'source.css.less',
6969
'source.css.postcss',
70-
'source.css.postcss.sugarss'
70+
'source.css.postcss.sugarss',
71+
'source.css.scss.embedded.html'
7172
];
7273
},
7374

spec/fixtures/vue/.stylelintrc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"rules": {
3+
"block-no-empty": true
4+
}
5+
}

spec/fixtures/vue/badSCSS.vue

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<template></template>
2+
3+
4+
<script></script>
5+
6+
7+
<style lang="scss" scoped>
8+
a {}
9+
</style>

spec/fixtures/vue/goodSCSS.vue

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<template></template>
2+
3+
4+
<script></script>
5+
6+
7+
<style lang="scss" scoped>
8+
a {
9+
color: red;
10+
}
11+
</style>

spec/linter-stylelint-spec.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,4 +249,30 @@ describe('The stylelint provider for Linter', () => {
249249
expect(messages.length).toBe(0);
250250
});
251251
});
252+
253+
describe('works with Vue Single File Components', () => {
254+
const goodVueSCSS = path.join(fixtures, 'vue', 'goodSCSS.vue');
255+
const badVueSCSS = path.join(fixtures, 'vue', 'badSCSS.vue');
256+
257+
beforeEach(async () => {
258+
await atom.packages.activatePackage('language-vue');
259+
});
260+
261+
it('shows lint messages when found', async () => {
262+
const editor = await atom.workspace.open(badVueSCSS);
263+
const messages = await lint(editor);
264+
265+
expect(messages[0].severity).toBe('error');
266+
expect(messages[0].excerpt).toBe(blockNoEmpty);
267+
expect(messages[0].url).toBe(blockNoEmptyUrl);
268+
expect(messages[0].location.file).toBe(badVueSCSS);
269+
expect(messages[0].location.position).toEqual([[7, 2], [7, 4]]);
270+
});
271+
272+
it('finds nothing wrong with a valid file', async () => {
273+
const editor = await atom.workspace.open(goodVueSCSS);
274+
const messages = await lint(editor);
275+
expect(messages.length).toBe(0);
276+
});
277+
});
252278
});

0 commit comments

Comments
 (0)