11'use strict' ;
22
3- var assign = require ( 'object-assign' ) ;
4- var td = require ( 'testdouble' ) ;
3+ const assign = require ( 'object-assign' ) ;
4+ const td = require ( 'testdouble' ) ;
55
6- var StyleLintPlugin = require ( '../' ) ;
6+ const StyleLintPlugin = require ( '../' ) ;
77
8- var pack = require ( './helpers/pack' ) ;
9- var webpack = require ( './helpers/webpack' ) ;
10- var baseConfig = require ( './helpers/base-config' ) ;
11- var configFilePath = getPath ( './.stylelintrc' ) ;
12- var errorMessage = require ( '../lib/constants' ) . errorMessage ;
8+ const pack = require ( './helpers/pack' ) ;
9+ const webpack = require ( './helpers/webpack' ) ;
10+ const baseConfig = require ( './helpers/base-config' ) ;
11+ const configFilePath = getPath ( './.stylelintrc' ) ;
12+ const errorMessage = require ( '../lib/constants' ) . errorMessage ;
1313
1414describe ( 'stylelint-webpack-plugin' , function ( ) {
1515 it ( 'works with a simple file' , function ( ) {
@@ -46,7 +46,7 @@ describe('stylelint-webpack-plugin', function () {
4646 } ) ;
4747
4848 it ( 'fails on errors when asked to' , function ( ) {
49- var config = {
49+ const config = {
5050 context : './test/fixtures/single-error' ,
5151 plugins : [
5252 new StyleLintPlugin ( {
@@ -65,7 +65,7 @@ describe('stylelint-webpack-plugin', function () {
6565 } ) ;
6666
6767 it ( 'fails when .stylelintrc is not a proper format' , function ( ) {
68- var config = {
68+ const config = {
6969 context : './test/fixtures/single-error' ,
7070 plugins : [
7171 new StyleLintPlugin ( {
@@ -92,7 +92,7 @@ describe('stylelint-webpack-plugin', function () {
9292 } ) ;
9393
9494 it ( 'sends messages to the console' , function ( ) {
95- var config = {
95+ const config = {
9696 context : './test/fixtures/syntax-error' ,
9797 plugins : [
9898 new StyleLintPlugin ( {
@@ -111,15 +111,14 @@ describe('stylelint-webpack-plugin', function () {
111111 } ) ;
112112
113113 context ( 'without StyleLintPlugin configuration' , function ( ) {
114- var config = {
115- context : './test/fixtures/lint-free' ,
114+ const config = {
116115 plugins : [
117116 new StyleLintPlugin ( )
118117 ]
119118 } ;
120119
121120 it ( 'works by using stylelint#cosmiconfig under the hood' , function ( ) {
122- return pack ( assign ( { } , baseConfig , config ) )
121+ return pack ( assign ( { } , baseConfig , config , { context : './test/fixtures/lint-free' } ) )
123122 . then ( function ( stats ) {
124123 expect ( stats . compilation . errors ) . to . have . length ( 0 ) ;
125124 expect ( stats . compilation . warnings ) . to . have . length ( 0 ) ;
@@ -136,7 +135,7 @@ describe('stylelint-webpack-plugin', function () {
136135
137136 context ( 'interop with NoErrorsPlugin' , function ( ) {
138137 it ( 'works when failOnError is false' , function ( ) {
139- var config = {
138+ const config = {
140139 context : './test/fixtures/single-error' ,
141140 plugins : [
142141 new StyleLintPlugin ( {
@@ -154,8 +153,7 @@ describe('stylelint-webpack-plugin', function () {
154153 } ) ;
155154
156155 context ( 'when failOnError is true' , function ( ) {
157- var config = {
158- context : './test/fixtures/single-error' ,
156+ const config = {
159157 plugins : [
160158 new StyleLintPlugin ( {
161159 configFile : configFilePath ,
@@ -167,7 +165,7 @@ describe('stylelint-webpack-plugin', function () {
167165 } ;
168166
169167 it ( 'throws when there is an error' , function ( ) {
170- return pack ( assign ( { } , baseConfig , config ) )
168+ return pack ( assign ( { } , baseConfig , config , { context : './test/fixtures/single-error' } ) )
171169 . then ( expect . fail )
172170 . catch ( function ( err ) {
173171 expect ( err ) . to . be . instanceof ( Error ) ;
@@ -184,19 +182,26 @@ describe('stylelint-webpack-plugin', function () {
184182 } ) ;
185183
186184 context ( 'when `emitErrors` is disabled' , function ( ) {
187- it ( 'emits errors as warnings when asked to' , function ( ) {
188- var config = {
189- context : './test/fixtures/single-error' ,
190- plugins : [
191- new StyleLintPlugin ( {
192- configFile : configFilePath ,
193- quiet : true ,
194- emitErrors : false
195- } )
196- ]
197- } ;
185+ const config = {
186+ plugins : [
187+ new StyleLintPlugin ( {
188+ configFile : configFilePath ,
189+ quiet : true ,
190+ emitErrors : false
191+ } )
192+ ]
193+ } ;
198194
199- return pack ( assign ( { } , baseConfig , config ) )
195+ it ( 'does not print warnings or errors when there are none' , function ( ) {
196+ return pack ( assign ( { } , baseConfig , config , { context : './test/fixtures/lint-free' } ) )
197+ . then ( function ( stats ) {
198+ expect ( stats . compilation . errors ) . to . have . length ( 0 ) ;
199+ expect ( stats . compilation . warnings ) . to . have . length ( 0 ) ;
200+ } ) ;
201+ } ) ;
202+
203+ it ( 'emits errors as warnings when asked to' , function ( ) {
204+ return pack ( assign ( { } , baseConfig , config , { context : './test/fixtures/single-error' } ) )
200205 . then ( function ( stats ) {
201206 expect ( stats . compilation . errors ) . to . have . length ( 0 ) ;
202207 expect ( stats . compilation . warnings ) . to . have . length ( 1 ) ;
@@ -205,18 +210,7 @@ describe('stylelint-webpack-plugin', function () {
205210 } ) ;
206211
207212 it ( 'still indicates that warnings are warnings, even when emitting errors as warnings too' , function ( ) {
208- var config = {
209- context : './test/fixtures/rule-warning' ,
210- plugins : [
211- new StyleLintPlugin ( {
212- configFile : configFilePath ,
213- quiet : true ,
214- emitErrors : false
215- } )
216- ]
217- } ;
218-
219- return pack ( assign ( { } , baseConfig , config ) )
213+ return pack ( assign ( { } , baseConfig , config , { context : './test/fixtures/rule-warning' } ) )
220214 . then ( function ( stats ) {
221215 expect ( stats . compilation . errors ) . to . have . length ( 0 ) ;
222216 expect ( stats . compilation . warnings ) . to . have . length ( 1 ) ;
@@ -227,7 +221,7 @@ describe('stylelint-webpack-plugin', function () {
227221
228222 context ( 'lintDirtyModulesOnly flag is enabled' , function ( ) {
229223 it ( 'skips linting on initial run' , function ( ) {
230- var config = {
224+ const config = {
231225 context : './test/fixtures/single-error' ,
232226 plugins : [
233227 new StyleLintPlugin ( {
@@ -246,7 +240,7 @@ describe('stylelint-webpack-plugin', function () {
246240 } ) ;
247241
248242 it ( 'still skips on initial run with `emitErrors` disabled' , function ( ) {
249- var config = {
243+ const config = {
250244 context : './test/fixtures/single-error' ,
251245 plugins : [
252246 new StyleLintPlugin ( {
0 commit comments