From 1caae5174f5b2a6c117372f81d3dfd66a082e873 Mon Sep 17 00:00:00 2001 From: Jason Kurian Date: Thu, 14 Jul 2016 19:09:07 -0400 Subject: [PATCH 01/11] Update stylelint dependency Fixes #14. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 07828d8..35e3140 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,7 @@ "mocha": "^2.3.4" }, "peerDependencies": { - "stylelint": "^6.0.1" + "stylelint": "^7.0.1" }, "scripts": { "test": "mocha --harmony --full-trace --check-leaks", From d1d40b76156dfa755d5b1549acc58cd02ae60ce6 Mon Sep 17 00:00:00 2001 From: Jason Kurian Date: Thu, 14 Jul 2016 19:26:15 -0400 Subject: [PATCH 02/11] Update local stylelint dependency as well --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 35e3140..543d071 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "extract-text-webpack-plugin": "^1.0.1", "loader-utils": "~0.2.10", "object-assign": "~4.0.1", - "stylelint": "^6.0.1", + "stylelint": "^7.0.1", "webpack": "^1.12.10" }, "devDependencies": { From 2505cb5d6de933614bff06c3addb80638ce807d2 Mon Sep 17 00:00:00 2001 From: Jason Kurian Date: Thu, 14 Jul 2016 19:33:29 -0400 Subject: [PATCH 03/11] fix renamed rules --- test/.stylelintrc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/.stylelintrc b/test/.stylelintrc index ffed810..16f04e8 100644 --- a/test/.stylelintrc +++ b/test/.stylelintrc @@ -41,22 +41,22 @@ "function-url-quotes": "double", "function-whitespace-after": "always", "indentation": 2, + "length-zero-no-unit": true, "max-empty-lines": 1, "media-feature-colon-space-after": "always", "media-feature-colon-space-before": "never", "media-feature-no-missing-punctuation": true, + "media-feature-parentheses-space-inside": "never", "media-feature-range-operator-space-after": "always", "media-feature-range-operator-space-before": "always", "media-query-list-comma-newline-after": "always-multi-line", "media-query-list-comma-space-after": "always-single-line", "media-query-list-comma-space-before": "never", - "media-query-parentheses-space-inside": "never", "no-eol-whitespace": true, "no-invalid-double-slash-comments": true, - "no-missing-eof-newline": true, + "no-missing-end-of-source-newline": true, "number-leading-zero": "always", "number-no-trailing-zeros": true, - "number-zero-length-no-unit": true, "rule-non-nested-empty-line-before": [ "always-multi-line", { "ignore": ["after-comment"], } ], @@ -71,4 +71,4 @@ "value-list-comma-space-after": "always-single-line", "value-list-comma-space-before": "never", }, -} \ No newline at end of file +} From c458dbb4a6d3355755028fa4e30a843cf35639e2 Mon Sep 17 00:00:00 2001 From: Jason Kurian Date: Thu, 28 Jul 2016 03:46:36 -0400 Subject: [PATCH 04/11] add editorconfig --- .editorconfig | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..d066b85 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,16 @@ +root = true + +[*] + +# Change these settings to your own preference +indent_style = space +indent_size = 2 + +# We recommend you to keep these unchanged +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +[*.md] +insert_final_newline = false From d1b1b73cd6d63d5ee00ff75b00f1b1e7136ae8c2 Mon Sep 17 00:00:00 2001 From: Jason Kurian Date: Thu, 28 Jul 2016 03:46:47 -0400 Subject: [PATCH 05/11] remove peerDependency --- package.json | 3 --- 1 file changed, 3 deletions(-) diff --git a/package.json b/package.json index 543d071..75f7148 100644 --- a/package.json +++ b/package.json @@ -36,9 +36,6 @@ "memory-fs": "^0.3.0", "mocha": "^2.3.4" }, - "peerDependencies": { - "stylelint": "^7.0.1" - }, "scripts": { "test": "mocha --harmony --full-trace --check-leaks", "preversion": "npm run test", From 1fa8f45adbd619c71de2f9b5d41533770f86c373 Mon Sep 17 00:00:00 2001 From: Jason Kurian Date: Thu, 28 Jul 2016 04:24:36 -0400 Subject: [PATCH 06/11] Simplify linter --- lib/linter.js | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/lib/linter.js b/lib/linter.js index f6c0d51..f07f057 100644 --- a/lib/linter.js +++ b/lib/linter.js @@ -2,13 +2,7 @@ var stylelint = require('stylelint'); function lint(options) { - return new Promise(function(resolve, reject) { - stylelint.lint(options).then(function(data) { - resolve(data); - }).catch(function(e) { - reject(e); - }); - }); + return stylelint.lint(options); } -module.exports = lint; \ No newline at end of file +module.exports = lint; From 4576322399203da65da00b668ba5a65f775f99c5 Mon Sep 17 00:00:00 2001 From: Jason Kurian Date: Thu, 28 Jul 2016 04:25:17 -0400 Subject: [PATCH 07/11] Use chai array length assertion --- test/index.js | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/test/index.js b/test/index.js index ee16b81..20c2cf5 100644 --- a/test/index.js +++ b/test/index.js @@ -51,8 +51,9 @@ describe('sasslint-loader', function () { pack(assign({}, baseConfig, config), function (err, stats) { expect(err).to.not.exist; - expect(stats.compilation.errors.length).to.equal(0); - expect(stats.compilation.warnings.length).to.equal(0); + console.log(stats.compilation.errors); + expect(stats.compilation.errors).to.have.length(0); + expect(stats.compilation.warnings).to.have.length(0); done(err); }); }); @@ -69,7 +70,7 @@ describe('sasslint-loader', function () { pack(assign({}, baseConfig, config), function (err, stats) { expect(err).to.not.exist; - expect(stats.compilation.errors.length).to.equal(1); + expect(stats.compilation.errors).to.have.length(1); done(err); }); }); @@ -78,11 +79,13 @@ describe('sasslint-loader', function () { var config = { context: './test/testfiles/test3', entry: './index', - plugins: [ new styleLintPlugin({ - configFile: configFilePath, - quiet: true, - failOnError: true - })] + plugins: [ + new styleLintPlugin({ + configFile: configFilePath, + quiet: true, + failOnError: true + }) + ] }; return expect(new Promise(function(resolve, reject) { @@ -141,4 +144,4 @@ describe('sasslint-loader', function () { // done(err); // }); // }); -}); \ No newline at end of file +}); From c34e44169a54182f4a4bbcff85544b6f40e53eda Mon Sep 17 00:00:00 2001 From: Jason Kurian Date: Thu, 28 Jul 2016 19:34:56 -0400 Subject: [PATCH 08/11] Fix last few errors in stylelintrc --- test/.stylelintrc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/.stylelintrc b/test/.stylelintrc index 16f04e8..b6521d3 100644 --- a/test/.stylelintrc +++ b/test/.stylelintrc @@ -30,7 +30,7 @@ "declaration-colon-newline-after": "always-multi-line", "declaration-colon-space-after": "always-single-line", "declaration-colon-space-before": "never", - "font-family-name-quotes": "double-where-recommended", + "font-family-name-quotes": "always-unless-keyword", "function-calc-no-unspaced-operator": true, "function-comma-newline-after": "always-multi-line", "function-comma-space-after": "always-single-line", @@ -38,7 +38,6 @@ "function-linear-gradient-no-nonstandard-direction": true, "function-parentheses-newline-inside": "always-multi-line", "function-parentheses-space-inside": "never-single-line", - "function-url-quotes": "double", "function-whitespace-after": "always", "indentation": 2, "length-zero-no-unit": true, From bdde104c5402f3b89be5920f0a881ef27a39b641 Mon Sep 17 00:00:00 2001 From: Jason Kurian Date: Thu, 28 Jul 2016 19:37:54 -0400 Subject: [PATCH 09/11] Restructure with linting and coverage --- .gitignore | 4 +- .travis.yml | 6 +- README.md | 6 +- index.js | 76 ++++++------------- lib/run-compilation.js | 46 +++++++++++ package.json | 26 ++++++- test/fixtures/test1/index.js | 3 + test/{testfiles => fixtures}/test1/test.scss | 0 test/fixtures/test2/index.js | 3 + test/{testfiles => fixtures}/test2/test.scss | 0 test/fixtures/test3/index.js | 3 + test/{testfiles => fixtures}/test3/test.scss | 0 test/fixtures/test4/index.js | 3 + test/{testfiles => fixtures}/test4/test.scss | 0 test/fixtures/test5/index.js | 3 + test/{testfiles => fixtures}/test5/test.scss | 0 test/fixtures/test6/index.js | 3 + test/{testfiles => fixtures}/test6/test.scss | 0 .../test7/_second.scss | 0 test/fixtures/test7/index.js | 3 + test/{testfiles => fixtures}/test7/test.scss | 0 test/helpers/setup.js | 10 +++ test/index.js | 59 +++++++------- test/mocha.opts | 4 + test/testfiles/test1/index.js | 3 - test/testfiles/test2/index.js | 3 - test/testfiles/test3/index.js | 3 - test/testfiles/test4/index.js | 3 - test/testfiles/test5/index.js | 3 - test/testfiles/test6/index.js | 3 - test/testfiles/test7/index.js | 3 - 31 files changed, 165 insertions(+), 114 deletions(-) create mode 100644 lib/run-compilation.js create mode 100644 test/fixtures/test1/index.js rename test/{testfiles => fixtures}/test1/test.scss (100%) create mode 100644 test/fixtures/test2/index.js rename test/{testfiles => fixtures}/test2/test.scss (100%) create mode 100644 test/fixtures/test3/index.js rename test/{testfiles => fixtures}/test3/test.scss (100%) create mode 100644 test/fixtures/test4/index.js rename test/{testfiles => fixtures}/test4/test.scss (100%) create mode 100644 test/fixtures/test5/index.js rename test/{testfiles => fixtures}/test5/test.scss (100%) create mode 100644 test/fixtures/test6/index.js rename test/{testfiles => fixtures}/test6/test.scss (100%) rename test/{testfiles => fixtures}/test7/_second.scss (100%) create mode 100644 test/fixtures/test7/index.js rename test/{testfiles => fixtures}/test7/test.scss (100%) create mode 100644 test/helpers/setup.js create mode 100644 test/mocha.opts delete mode 100644 test/testfiles/test1/index.js delete mode 100644 test/testfiles/test2/index.js delete mode 100644 test/testfiles/test3/index.js delete mode 100644 test/testfiles/test4/index.js delete mode 100644 test/testfiles/test5/index.js delete mode 100644 test/testfiles/test6/index.js delete mode 100644 test/testfiles/test7/index.js diff --git a/.gitignore b/.gitignore index 5171c54..cf5db45 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ node_modules -npm-debug.log \ No newline at end of file +npm-debug.log +.nyc_output +coverage diff --git a/.travis.yml b/.travis.yml index 998f9b6..4e23218 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,3 +1,7 @@ +sudo: false language: node_js node_js: - - '4' \ No newline at end of file + - 4 + - "stable" + +after_success: "cat ./coverage/lcov.info | ./node_modules/.bin/coveralls" diff --git a/README.md b/README.md index 3b9d9d5..4eb8dab 100644 --- a/README.md +++ b/README.md @@ -18,13 +18,13 @@ $ npm install stylelint-webpack-plugin In your webpack configuration ```js -var styleLintPlugin = require('stylelint-webpack-plugin'); +var StyleLintPlugin = require('stylelint-webpack-plugin'); module.exports = { // ... plugins: [ - new styleLintPlugin(), + new StyleLintPlugin(), ], // ... } @@ -47,7 +47,7 @@ See [stylelint options](http://stylelint.io/user-guide/node-api/#options), for t // Default settings module.exports = { plugins: [ - new styleLintPlugin({ + new StyleLintPlugin({ configFile: '.stylelintrc', context: 'inherits from webpack', files: '**/*.s?(a|c)ss', diff --git a/index.js b/index.js index 2491d08..06b6c19 100644 --- a/index.js +++ b/index.js @@ -1,74 +1,44 @@ +'use strict'; + // Dependencies -var loaderUtils = require('loader-utils'); -var assign = require('object-assign'); var path = require('path'); +var assign = require('object-assign'); var formatter = require('stylelint/dist/formatters/stringFormatter').default; -var chalk = require('chalk'); +var arrify = require('arrify'); // Modules -var linter = require('./lib/linter'); +var runCompilation = require('./lib/run-compilation'); function apply(options, compiler) { var context = options.context || compiler.context; - var errors = []; options = Object.assign({}, options, { // TODO: make it work with arrays - files: options.files.map(function(file) { + files: options.files.map(function (file) { return path.join(context, '/', file); }) }); - function runCompilation(compilation, done) { - linter(options).then(function(lint) { - if (lint.errored) { - errors = lint.results.filter(function(f) { - return f.errored; - }).map(function(f) { - return f.source; // send error instead - }); - - (options.quiet !== true) && console.log(chalk.yellow(options.formatter(lint.results))); - } - - if (options.failOnError && errors.length) { - done(new Error('Failed because of a stylelint error.\n')); - } else { - done(); - } - }).catch(function(e) { - if (options.failOnError && errors.length) { - done(new Error('Failed because of a stylelint error.\n')); - } else { - done(); - } - console.log(chalk.red(e)); - }); - - compilation.plugin && compilation.plugin('compilation', function(compilation) { - errors.forEach(function(err) { - compilation.errors.push(err); - }); - }); - } - - compiler.plugin('run', runCompilation); - compiler.plugin('watch-run', runCompilation); + compiler.plugin('run', runCompilation.bind(this, options)); + compiler.plugin('watch-run', runCompilation.bind(this, options)); } // makes it easier to pass and check options to the plugin thank you webpack doc // [https://webpack.github.io/docs/plugins.html#the-compiler-instance] -module.exports = function(options) { - options = options || {}; - // Default Glob is any directory level of scss and/or sass file, - // under webpack's context and specificity changed via globbing patterns - options.files = options.files || '**/*.s?(c|a)ss'; - !Array.isArray(options.files) && (options.files = [options.files]); - options.configFile = options.configFile || '.stylelintrc'; - options.formatter = options.formatter || formatter; - options.quiet = options.quiet || false; - +module.exports = function (options) { return { - apply: apply.bind(this, options) + apply: apply.bind(this, buildOptions(options)) }; -}; \ No newline at end of file +}; + +function buildOptions(options) { + return assign({ + configFile: '.stylelintrc', + formatter: formatter, + quiet: false + }, options, { + // Default Glob is any directory level of scss and/or sass file, + // under webpack's context and specificity changed via globbing patterns + files: arrify(options.files || '**/*.s?(c|a)ss') + }); +} diff --git a/lib/run-compilation.js b/lib/run-compilation.js new file mode 100644 index 0000000..12e6cba --- /dev/null +++ b/lib/run-compilation.js @@ -0,0 +1,46 @@ +'use strict'; + +var chalk = require('chalk'); +var linter = require('./linter'); + +module.exports = function runCompilation(options, compilation, done) { + var errors = []; + + linter(options) + .then(function (lint) { + if (lint.errored) { + errors = lint.results + .filter(function (f) { + return f.errored; + }) + .map(function (f) { + return f.source; // send error instead + }); + + if (!options.quiet) { + console.log(chalk.yellow(options.formatter(lint.results))); + } + } + + if (options.failOnError && errors.length) { + done(new Error('Failed because of a stylelint error.\n')); + } else { + done(); + } + }) + .catch(function (err) { + if (options.failOnError && errors.length) { + done(new Error('Failed because of a stylelint error.\n')); + } else { + done(); + } + console.log(chalk.red(err)); + }); + + // eslint-disable-next-line no-unused-expressions + compilation.plugin && compilation.plugin('compilation', function (compilation) { + errors.forEach(function (err) { + compilation.errors.push(err); + }); + }); +}; diff --git a/package.json b/package.json index 75f7148..3d1e4ab 100644 --- a/package.json +++ b/package.json @@ -23,6 +23,7 @@ }, "homepage": "https://github.com/vieron/stylelint-webpack-plugin#readme", "dependencies": { + "arrify": "^1.0.1", "chalk": "^1.1.1", "extract-text-webpack-plugin": "^1.0.1", "loader-utils": "~0.2.10", @@ -33,12 +34,33 @@ "devDependencies": { "chai": "^3.4.1", "chai-as-promised": "^5.2.0", + "coveralls": "^2.11.12", "memory-fs": "^0.3.0", - "mocha": "^2.3.4" + "mocha": "^2.3.4", + "nyc": "^7.1.0", + "xo": "^0.16.0" }, "scripts": { - "test": "mocha --harmony --full-trace --check-leaks", + "pretest": "xo", + "test": "nyc mocha", "preversion": "npm run test", "version": "git add -A ." + }, + "nyc": { + "reporter": [ + "lcov", + "text-summary" + ] + }, + "xo": { + "space": true, + "envs": [ + "node", + "mocha" + ], + "globals": [ + "getPath", + "expect" + ] } } diff --git a/test/fixtures/test1/index.js b/test/fixtures/test1/index.js new file mode 100644 index 0000000..daac3c2 --- /dev/null +++ b/test/fixtures/test1/index.js @@ -0,0 +1,3 @@ +require(getPath('./../../../node_modules/file-loader/index') + '!./test.scss'); + +console.log('test1'); diff --git a/test/testfiles/test1/test.scss b/test/fixtures/test1/test.scss similarity index 100% rename from test/testfiles/test1/test.scss rename to test/fixtures/test1/test.scss diff --git a/test/fixtures/test2/index.js b/test/fixtures/test2/index.js new file mode 100644 index 0000000..c1d394b --- /dev/null +++ b/test/fixtures/test2/index.js @@ -0,0 +1,3 @@ +require(getPath('./../../../node_modules/file-loader/index') + '!./test.scss'); + +console.log('test2'); diff --git a/test/testfiles/test2/test.scss b/test/fixtures/test2/test.scss similarity index 100% rename from test/testfiles/test2/test.scss rename to test/fixtures/test2/test.scss diff --git a/test/fixtures/test3/index.js b/test/fixtures/test3/index.js new file mode 100644 index 0000000..ab763be --- /dev/null +++ b/test/fixtures/test3/index.js @@ -0,0 +1,3 @@ +require(getPath('./../../../node_modules/file-loader/index') + '!./test.scss'); + +console.log('test3'); diff --git a/test/testfiles/test3/test.scss b/test/fixtures/test3/test.scss similarity index 100% rename from test/testfiles/test3/test.scss rename to test/fixtures/test3/test.scss diff --git a/test/fixtures/test4/index.js b/test/fixtures/test4/index.js new file mode 100644 index 0000000..82c89c3 --- /dev/null +++ b/test/fixtures/test4/index.js @@ -0,0 +1,3 @@ +require(getPath('./../../../node_modules/file-loader/index') + '!./test.scss'); + +console.log('test4'); diff --git a/test/testfiles/test4/test.scss b/test/fixtures/test4/test.scss similarity index 100% rename from test/testfiles/test4/test.scss rename to test/fixtures/test4/test.scss diff --git a/test/fixtures/test5/index.js b/test/fixtures/test5/index.js new file mode 100644 index 0000000..8a383a6 --- /dev/null +++ b/test/fixtures/test5/index.js @@ -0,0 +1,3 @@ +require(getPath('./../../../node_modules/file-loader/index') + '!./test.scss'); + +console.log('test5'); diff --git a/test/testfiles/test5/test.scss b/test/fixtures/test5/test.scss similarity index 100% rename from test/testfiles/test5/test.scss rename to test/fixtures/test5/test.scss diff --git a/test/fixtures/test6/index.js b/test/fixtures/test6/index.js new file mode 100644 index 0000000..aa35728 --- /dev/null +++ b/test/fixtures/test6/index.js @@ -0,0 +1,3 @@ +require(getPath('./../../../node_modules/file-loader/index') + '!./test.scss'); + +console.log('test6'); diff --git a/test/testfiles/test6/test.scss b/test/fixtures/test6/test.scss similarity index 100% rename from test/testfiles/test6/test.scss rename to test/fixtures/test6/test.scss diff --git a/test/testfiles/test7/_second.scss b/test/fixtures/test7/_second.scss similarity index 100% rename from test/testfiles/test7/_second.scss rename to test/fixtures/test7/_second.scss diff --git a/test/fixtures/test7/index.js b/test/fixtures/test7/index.js new file mode 100644 index 0000000..aa35728 --- /dev/null +++ b/test/fixtures/test7/index.js @@ -0,0 +1,3 @@ +require(getPath('./../../../node_modules/file-loader/index') + '!./test.scss'); + +console.log('test6'); diff --git a/test/testfiles/test7/test.scss b/test/fixtures/test7/test.scss similarity index 100% rename from test/testfiles/test7/test.scss rename to test/fixtures/test7/test.scss diff --git a/test/helpers/setup.js b/test/helpers/setup.js new file mode 100644 index 0000000..ec6e08b --- /dev/null +++ b/test/helpers/setup.js @@ -0,0 +1,10 @@ +'use strict'; + +var chai = require('chai'); + +global.expect = chai.expect; + +chai.use(require('chai-as-promised')); + +// get path from the './test' directory +global.getPath = require('path').join.bind(this, __dirname, '..'); diff --git a/test/index.js b/test/index.js index 20c2cf5..b3f0f55 100644 --- a/test/index.js +++ b/test/index.js @@ -1,28 +1,24 @@ -/* global __dirname, describe, it */ -var chai = require('chai'); -var expect = chai.expect; -var chaiAsPromised = require('chai-as-promised'); +/* eslint no-unused-expressions: 0 */ + +'use strict'; + var assign = require('object-assign'); var webpack = require('webpack'); var MemoryFileSystem = require('memory-fs'); -var ExtractTextPlugin = require('extract-text-webpack-plugin'); -var path = require('path'); - -chai.use(chaiAsPromised); // _dirname is the test directory -var styleLintPlugin = require(path.join(__dirname, '../index')); +var StyleLintPlugin = require(getPath('../index')); var outputFileSystem = new MemoryFileSystem(); -var configFilePath = path.join(__dirname, './.stylelintrc'); +var configFilePath = getPath('./.stylelintrc'); var baseConfig = { debug: false, output: { - path: path.join(__dirname, 'output') + path: getPath('output') }, plugins: [ - new styleLintPlugin({ + new StyleLintPlugin({ quiet: true, configFile: configFilePath }) @@ -38,20 +34,15 @@ function pack(testConfig, callback) { compiler.run(callback); } - -/** - * Test Suite - */ describe('sasslint-loader', function () { it('works with a simple file', function (done) { var config = { - context: './test/testfiles/test1', + context: './test/fixtures/test1', entry: './index' }; pack(assign({}, baseConfig, config), function (err, stats) { expect(err).to.not.exist; - console.log(stats.compilation.errors); expect(stats.compilation.errors).to.have.length(0); expect(stats.compilation.warnings).to.have.length(0); done(err); @@ -60,9 +51,9 @@ describe('sasslint-loader', function () { it('sends errors properly', function (done) { var config = { - context: './test/testfiles/test3', + context: './test/fixtures/test3', entry: './index', - plugins: [ new styleLintPlugin({ + plugins: [new StyleLintPlugin({ quiet: true, configFile: configFilePath })] @@ -77,10 +68,10 @@ describe('sasslint-loader', function () { it('fails on errors', function () { var config = { - context: './test/testfiles/test3', + context: './test/fixtures/test3', entry: './index', plugins: [ - new styleLintPlugin({ + new StyleLintPlugin({ configFile: configFilePath, quiet: true, failOnError: true @@ -88,10 +79,10 @@ describe('sasslint-loader', function () { ] }; - return expect(new Promise(function(resolve, reject) { + return expect(new Promise(function (resolve, reject) { var compiler = webpack(assign({}, baseConfig, config)); compiler.outputFileSystem = outputFileSystem; - compiler.run(function(err) { + compiler.run(function (err) { reject(err); }); })).to.eventually.be.rejectedWith('Error: Failed because of a stylelint error.\n'); @@ -99,12 +90,14 @@ describe('sasslint-loader', function () { it('can specify a JSON config file via config', function (done) { var config = { - context: './test/testfiles/test5', + context: './test/fixtures/test5', entry: './index', - plugins: [ new styleLintPlugin({ - configFile: configFilePath, - quiet: true - })] + plugins: [ + new StyleLintPlugin({ + configFile: configFilePath, + quiet: true + }) + ] }; pack(assign({}, baseConfig, config), function (err, stats) { @@ -114,9 +107,9 @@ describe('sasslint-loader', function () { }); }); - it('should work with multiple files', function(done) { + it('should work with multiple files', function (done) { var config = { - context: './test/testfiles/test7', + context: './test/fixtures/test7', entry: './index' }; @@ -129,9 +122,9 @@ describe('sasslint-loader', function () { // it('should work with multiple context', function(done) { // var config = { - // context: './test/testfiles/test5', + // context: './test/fixtures/test5', // entry: './index', - // plugins: [ new styleLintPlugin({ + // plugins: [ new StyleLintPlugin({ // configFile: configFilePath, // context: ['./test/testFiles/test5', './test/testFiles/test7'] // })] diff --git a/test/mocha.opts b/test/mocha.opts new file mode 100644 index 0000000..f165676 --- /dev/null +++ b/test/mocha.opts @@ -0,0 +1,4 @@ +--require ./test/helpers/setup.js +--harmony +--full-trace +--check-leaks diff --git a/test/testfiles/test1/index.js b/test/testfiles/test1/index.js deleted file mode 100644 index 6ea93a5..0000000 --- a/test/testfiles/test1/index.js +++ /dev/null @@ -1,3 +0,0 @@ -require(path.join(__dirname, './../../../node_modules/file-loader/index') + '!./test.scss'); - -console.log('test1'); \ No newline at end of file diff --git a/test/testfiles/test2/index.js b/test/testfiles/test2/index.js deleted file mode 100644 index 905d6fc..0000000 --- a/test/testfiles/test2/index.js +++ /dev/null @@ -1,3 +0,0 @@ -require(path.join(__dirname, './../../../node_modules/file-loader/index') + '!./test.scss'); - -console.log('test2'); \ No newline at end of file diff --git a/test/testfiles/test3/index.js b/test/testfiles/test3/index.js deleted file mode 100644 index 945d34c..0000000 --- a/test/testfiles/test3/index.js +++ /dev/null @@ -1,3 +0,0 @@ -require(path.join(__dirname, './../../../node_modules/file-loader/index') + '!./test.scss'); - -console.log('test3'); \ No newline at end of file diff --git a/test/testfiles/test4/index.js b/test/testfiles/test4/index.js deleted file mode 100644 index f62d7fc..0000000 --- a/test/testfiles/test4/index.js +++ /dev/null @@ -1,3 +0,0 @@ -require(path.join(__dirname, './../../../node_modules/file-loader/index') + '!./test.scss'); - -console.log('test4'); \ No newline at end of file diff --git a/test/testfiles/test5/index.js b/test/testfiles/test5/index.js deleted file mode 100644 index d7feb83..0000000 --- a/test/testfiles/test5/index.js +++ /dev/null @@ -1,3 +0,0 @@ -require(path.join(__dirname, './../../../node_modules/file-loader/index') + '!./test.scss'); - -console.log('test5'); \ No newline at end of file diff --git a/test/testfiles/test6/index.js b/test/testfiles/test6/index.js deleted file mode 100644 index 71e2cdf..0000000 --- a/test/testfiles/test6/index.js +++ /dev/null @@ -1,3 +0,0 @@ -require(path.join(__dirname, './../../../node_modules/file-loader/index') + '!./test.scss'); - -console.log('test6'); \ No newline at end of file diff --git a/test/testfiles/test7/index.js b/test/testfiles/test7/index.js deleted file mode 100644 index 71e2cdf..0000000 --- a/test/testfiles/test7/index.js +++ /dev/null @@ -1,3 +0,0 @@ -require(path.join(__dirname, './../../../node_modules/file-loader/index') + '!./test.scss'); - -console.log('test6'); \ No newline at end of file From 94df25b4e00a3e597181d4a26e32398fc1e9ca74 Mon Sep 17 00:00:00 2001 From: Jason Kurian Date: Thu, 28 Jul 2016 23:52:29 -0400 Subject: [PATCH 10/11] Add some documentation for runCompilation and add missing use strict --- lib/linter.js | 2 ++ lib/run-compilation.js | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/lib/linter.js b/lib/linter.js index f07f057..11eb619 100644 --- a/lib/linter.js +++ b/lib/linter.js @@ -1,3 +1,5 @@ +'use strict'; + // Dependencies var stylelint = require('stylelint'); diff --git a/lib/run-compilation.js b/lib/run-compilation.js index 12e6cba..908f9be 100644 --- a/lib/run-compilation.js +++ b/lib/run-compilation.js @@ -3,6 +3,13 @@ var chalk = require('chalk'); var linter = require('./linter'); +/** + * Function bound to the plugin `apply` method to run the linter and report any + * errors (and their source file locations) + * @param options - from the apply method, the options passed in + * @param compilation - the compiler object + * @param done - callback + */ module.exports = function runCompilation(options, compilation, done) { var errors = []; From ddc23b0fa978072b7d16fcbff29b48fdd7368ce7 Mon Sep 17 00:00:00 2001 From: Jason Kurian Date: Tue, 2 Aug 2016 17:55:35 -0400 Subject: [PATCH 11/11] Keep stylelint v7 in peerDependencies. --- package.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/package.json b/package.json index 3d1e4ab..81b71ed 100644 --- a/package.json +++ b/package.json @@ -22,6 +22,9 @@ "url": "https://github.com/vieron/stylelint-webpack-plugin/issues" }, "homepage": "https://github.com/vieron/stylelint-webpack-plugin#readme", + "peerDependencies": { + "stylelint": "^7.0.1" + }, "dependencies": { "arrify": "^1.0.1", "chalk": "^1.1.1",