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

Support linting in Vue single-file components #406

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ defaults: &defaults
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"
steps:
# Restore project state
- attach_workspace:
Expand Down
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
3 changes: 2 additions & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,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 @@ -328,4 +328,30 @@ describe('The stylelint provider for Linter', () => {
rimraf.sync(tempDir);
});
});

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);
});
});
});