From 9ae76f8d9ab2d69c5116e81e83a395a004c62366 Mon Sep 17 00:00:00 2001 From: Jonathan Boiser Date: Thu, 12 Jul 2018 15:00:27 -0700 Subject: [PATCH] feat: support linting in vue single-file components with scss --- .travis.yml | 2 +- lib/index.js | 3 ++- spec/fixtures/vue/.stylelintrc | 5 +++++ spec/fixtures/vue/badSCSS.vue | 9 +++++++++ spec/fixtures/vue/goodSCSS.vue | 11 +++++++++++ spec/linter-stylelint-spec.js | 26 ++++++++++++++++++++++++++ 6 files changed, 54 insertions(+), 2 deletions(-) create mode 100644 spec/fixtures/vue/.stylelintrc create mode 100644 spec/fixtures/vue/badSCSS.vue create mode 100644 spec/fixtures/vue/goodSCSS.vue diff --git a/.travis.yml b/.travis.yml index d66d3b14..4fcec7d4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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: diff --git a/lib/index.js b/lib/index.js index 4ff75724..6d890daf 100644 --- a/lib/index.js +++ b/lib/index.js @@ -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' ]; }, diff --git a/spec/fixtures/vue/.stylelintrc b/spec/fixtures/vue/.stylelintrc new file mode 100644 index 00000000..0eb6e7c4 --- /dev/null +++ b/spec/fixtures/vue/.stylelintrc @@ -0,0 +1,5 @@ +{ + "rules": { + "block-no-empty": true + } +} diff --git a/spec/fixtures/vue/badSCSS.vue b/spec/fixtures/vue/badSCSS.vue new file mode 100644 index 00000000..f2cd1b2e --- /dev/null +++ b/spec/fixtures/vue/badSCSS.vue @@ -0,0 +1,9 @@ + + + + + + + diff --git a/spec/fixtures/vue/goodSCSS.vue b/spec/fixtures/vue/goodSCSS.vue new file mode 100644 index 00000000..fdd7b009 --- /dev/null +++ b/spec/fixtures/vue/goodSCSS.vue @@ -0,0 +1,11 @@ + + + + + + + diff --git a/spec/linter-stylelint-spec.js b/spec/linter-stylelint-spec.js index da0145e3..ad3d6890 100644 --- a/spec/linter-stylelint-spec.js +++ b/spec/linter-stylelint-spec.js @@ -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); + }); + }); });