@@ -4,22 +4,10 @@ import * as path from 'path';
4
4
// eslint-disable-next-line no-unused-vars, import/no-extraneous-dependencies
5
5
import { it , fit , wait , beforeEach , afterEach } from 'jasmine-fix' ;
6
6
7
- const badDir = path . join ( __dirname , 'fixtures' , 'bad' ) ;
8
- const configStandardPath = path . join ( badDir , 'stylelint-config-standard.css' ) ;
9
- const warn = path . join ( __dirname , 'fixtures' , 'warn' , 'warn.css' ) ;
10
- const good = path . join ( __dirname , 'fixtures' , 'good' , 'good.css' ) ;
11
- const ignorePath = path . join ( __dirname , 'fixtures' , 'ignore-files' , 'styles.css' ) ;
12
- const invalidPath = path . join ( __dirname , 'fixtures' , 'invalid' , 'invalid.css' ) ;
13
- const invalidRulePath = path . join ( __dirname , 'fixtures' , 'invalid-rule' , 'styles.css' ) ;
14
- const invalidExtendsPath = path . join ( __dirname , 'fixtures' , 'invalid-extends' , 'styles.css' ) ;
15
- const invalidConfigPath = path . join ( __dirname , 'fixtures' , 'invalid-config' , 'styles.css' ) ;
16
- const lessDir = path . join ( __dirname , 'fixtures' , 'less' ) ;
17
- const goodLess = path . join ( lessDir , 'good.less' ) ;
18
- const configStandardLessPath = path . join ( lessDir , 'stylelint-config-standard.less' ) ;
19
- const goodPostCSS = path . join ( __dirname , 'fixtures' , 'postcss' , 'styles.pcss' ) ;
20
- const issuesPostCSS = path . join ( __dirname , 'fixtures' , 'postcss' , 'issues.pcss' ) ;
21
- const goodSugarSS = path . join ( __dirname , 'fixtures' , 'sugarss' , 'good.sss' ) ;
22
- const badSugarSS = path . join ( __dirname , 'fixtures' , 'sugarss' , 'bad.sss' ) ;
7
+ const fixtures = path . join ( __dirname , 'fixtures' ) ;
8
+ const configStandardPath = path . join ( fixtures , 'bad' , 'stylelint-config-standard.css' ) ;
9
+ const warningPath = path . join ( fixtures , 'warn' , 'warn.css' ) ;
10
+ const invalidRulePath = path . join ( fixtures , 'invalid-rule' , 'styles.css' ) ;
23
11
24
12
const blockNoEmpty = 'Unexpected empty block (<a href="http://stylelint.io/user-guide/rules/block-no-empty">block-no-empty</a>)' ;
25
13
@@ -28,14 +16,13 @@ describe('The stylelint provider for Linter', () => {
28
16
29
17
beforeEach ( async ( ) => {
30
18
atom . workspace . destroyActivePaneItem ( ) ;
31
- atom . config . set ( 'linter-stylelint.useStandard' , true ) ;
32
19
33
20
await atom . packages . activatePackage ( 'language-css' ) ;
34
21
await atom . packages . activatePackage ( 'linter-stylelint' ) ;
35
22
} ) ;
36
23
37
24
it ( 'bundles and works with stylelint-config-standard' , async ( ) => {
38
- atom . config . set ( 'linter-stylelint.disableWhenNoConfig ' , false ) ;
25
+ atom . config . set ( 'linter-stylelint.useStandard ' , true ) ;
39
26
const editor = await atom . workspace . open ( configStandardPath ) ;
40
27
const messages = await lint ( editor ) ;
41
28
expect ( messages . length ) . toBeGreaterThan ( 0 ) ;
@@ -50,8 +37,7 @@ describe('The stylelint provider for Linter', () => {
50
37
} ) ;
51
38
52
39
it ( 'reports rules set as warnings as a Warning' , async ( ) => {
53
- atom . config . set ( 'linter-stylelint.useStandard' , false ) ;
54
- const editor = await atom . workspace . open ( warn ) ;
40
+ const editor = await atom . workspace . open ( warningPath ) ;
55
41
const messages = await lint ( editor ) ;
56
42
57
43
expect ( messages . length ) . toBeGreaterThan ( 0 ) ;
@@ -66,13 +52,14 @@ describe('The stylelint provider for Linter', () => {
66
52
} ) ;
67
53
68
54
it ( 'finds nothing wrong with a valid file' , async ( ) => {
69
- const editor = await atom . workspace . open ( good ) ;
55
+ const goodPath = path . join ( fixtures , 'good' , 'good.css' ) ;
56
+ const editor = await atom . workspace . open ( goodPath ) ;
70
57
const messages = await lint ( editor ) ;
71
58
expect ( messages . length ) . toBe ( 0 ) ;
72
59
} ) ;
73
60
74
61
it ( 'shows CSS syntax errors with an invalid file' , async ( ) => {
75
- atom . config . set ( 'linter-stylelint.disableWhenNoConfig ', false ) ;
62
+ const invalidPath = path . join ( fixtures , 'invalid ', 'invalid.css' ) ;
76
63
const editor = await atom . workspace . open ( invalidPath ) ;
77
64
const messages = await lint ( editor ) ;
78
65
expect ( messages . length ) . toBe ( 1 ) ;
@@ -87,7 +74,6 @@ describe('The stylelint provider for Linter', () => {
87
74
88
75
it ( 'shows an error on non-fatal stylelint runtime error' , async ( ) => {
89
76
const text = 'Unexpected option value "foo" for rule "block-no-empty"' ;
90
- atom . config . set ( 'linter-stylelint.useStandard' , false ) ;
91
77
const editor = await atom . workspace . open ( invalidRulePath ) ;
92
78
const messages = await lint ( editor ) ;
93
79
expect ( messages . length ) . toBe ( 1 ) ;
@@ -101,7 +87,8 @@ describe('The stylelint provider for Linter', () => {
101
87
} ) ;
102
88
103
89
it ( 'shows an error notification for a fatal stylelint runtime error' , async ( ) => {
104
- atom . config . set ( 'linter-stylelint.useStandard' , false ) ;
90
+ const invalidExtendsPath = path . join ( fixtures , 'invalid-extends' , 'styles.css' ) ;
91
+
105
92
spyOn ( atom . notifications , 'addError' ) . andCallFake ( ( ) => ( { } ) ) ;
106
93
const addError = atom . notifications . addError ;
107
94
@@ -117,7 +104,8 @@ describe('The stylelint provider for Linter', () => {
117
104
} ) ;
118
105
119
106
it ( 'shows an error notification with a broken syntax configuration' , async ( ) => {
120
- atom . config . set ( 'linter-stylelint.useStandard' , false ) ;
107
+ const invalidConfigPath = path . join ( fixtures , 'invalid-config' , 'styles.css' ) ;
108
+
121
109
spyOn ( atom . notifications , 'addError' ) . andCallFake ( ( ) => ( { } ) ) ;
122
110
const addError = atom . notifications . addError ;
123
111
@@ -133,7 +121,6 @@ describe('The stylelint provider for Linter', () => {
133
121
} ) ;
134
122
135
123
it ( 'disables when no configuration file is found' , async ( ) => {
136
- atom . config . set ( 'linter-stylelint.disableWhenNoConfig' , true ) ;
137
124
spyOn ( atom . notifications , 'addError' ) . andCallFake ( ( ) => ( { } ) ) ;
138
125
139
126
const editor = await atom . workspace . open ( configStandardPath ) ;
@@ -143,9 +130,7 @@ describe('The stylelint provider for Linter', () => {
143
130
} ) ;
144
131
145
132
describe ( 'ignores files when files are specified in ignoreFiles and' , ( ) => {
146
- beforeEach ( ( ) => {
147
- atom . config . set ( 'linter-stylelint.useStandard' , true ) ;
148
- } ) ;
133
+ const ignorePath = path . join ( fixtures , 'ignore-files' , 'styles.css' ) ;
149
134
150
135
it ( 'shows a message when asked to' , async ( ) => {
151
136
atom . config . set ( 'linter-stylelint.showIgnored' , true ) ;
@@ -170,35 +155,35 @@ describe('The stylelint provider for Linter', () => {
170
155
} ) ;
171
156
172
157
it ( "doesn't persist settings across runs" , async ( ) => {
173
- atom . config . set ( 'linter-stylelint.useStandard' , true ) ;
174
- atom . config . set ( 'linter-stylelint.disableWhenNoConfig' , false ) ;
175
158
// The config for this folder breaks the block-no-empty rule
176
159
const invalidEditor = await atom . workspace . open ( invalidRulePath ) ;
177
160
await lint ( invalidEditor ) ;
178
161
179
162
// While this file uses that rule
180
- const editor = await atom . workspace . open ( configStandardPath ) ;
163
+ const editor = await atom . workspace . open ( warningPath ) ;
181
164
const messages = await lint ( editor ) ;
182
165
expect ( messages . length ) . toBeGreaterThan ( 0 ) ;
183
166
184
167
// test only the first error
185
- expect ( messages [ 0 ] . type ) . toBe ( 'Error ' ) ;
186
- expect ( messages [ 0 ] . severity ) . toBe ( 'error ' ) ;
168
+ expect ( messages [ 0 ] . type ) . toBe ( 'Warning ' ) ;
169
+ expect ( messages [ 0 ] . severity ) . toBe ( 'warning ' ) ;
187
170
expect ( messages [ 0 ] . text ) . not . toBeDefined ( ) ;
188
171
expect ( messages [ 0 ] . html ) . toBe ( blockNoEmpty ) ;
189
- expect ( messages [ 0 ] . filePath ) . toBe ( configStandardPath ) ;
172
+ expect ( messages [ 0 ] . filePath ) . toBe ( warningPath ) ;
190
173
expect ( messages [ 0 ] . range ) . toEqual ( [ [ 0 , 5 ] , [ 0 , 7 ] ] ) ;
191
174
} ) ;
192
175
193
176
describe ( 'works with Less files and' , ( ) => {
177
+ const lessDir = path . join ( fixtures , 'less' ) ;
178
+ const goodLess = path . join ( lessDir , 'good.less' ) ;
179
+ const badLess = path . join ( lessDir , 'bad.less' ) ;
180
+
194
181
beforeEach ( async ( ) => {
195
- atom . config . set ( 'linter-stylelint.useStandard' , true ) ;
196
- atom . config . set ( 'linter-stylelint.disableWhenNoConfig' , false ) ;
197
182
await atom . packages . activatePackage ( 'language-less' ) ;
198
183
} ) ;
199
184
200
- it ( 'works with stylelint-config-standard ' , async ( ) => {
201
- const editor = await atom . workspace . open ( configStandardLessPath ) ;
185
+ it ( 'shows lint messages when found ' , async ( ) => {
186
+ const editor = await atom . workspace . open ( badLess ) ;
202
187
const messages = await lint ( editor ) ;
203
188
expect ( messages . length ) . toBeGreaterThan ( 0 ) ;
204
189
@@ -207,7 +192,7 @@ describe('The stylelint provider for Linter', () => {
207
192
expect ( messages [ 0 ] . severity ) . toBe ( 'error' ) ;
208
193
expect ( messages [ 0 ] . text ) . not . toBeDefined ( ) ;
209
194
expect ( messages [ 0 ] . html ) . toBe ( blockNoEmpty ) ;
210
- expect ( messages [ 0 ] . filePath ) . toBe ( configStandardLessPath ) ;
195
+ expect ( messages [ 0 ] . filePath ) . toBe ( badLess ) ;
211
196
expect ( messages [ 0 ] . range ) . toEqual ( [ [ 0 , 5 ] , [ 0 , 7 ] ] ) ;
212
197
} ) ;
213
198
@@ -219,13 +204,14 @@ describe('The stylelint provider for Linter', () => {
219
204
} ) ;
220
205
221
206
describe ( 'works with PostCSS files and' , ( ) => {
207
+ const goodPostCSS = path . join ( fixtures , 'postcss' , 'styles.pcss' ) ;
208
+ const issuesPostCSS = path . join ( fixtures , 'postcss' , 'issues.pcss' ) ;
209
+
222
210
beforeEach ( async ( ) => {
223
- atom . config . set ( 'linter-stylelint.useStandard' , true ) ;
224
- atom . config . set ( 'linter-stylelint.disableWhenNoConfig' , false ) ;
225
211
await atom . packages . activatePackage ( 'language-postcss' ) ;
226
212
} ) ;
227
213
228
- it ( 'works with stylelint-config-standard ' , async ( ) => {
214
+ it ( 'shows lint messages when found ' , async ( ) => {
229
215
const editor = await atom . workspace . open ( issuesPostCSS ) ;
230
216
const messages = await lint ( editor ) ;
231
217
expect ( messages . length ) . toBeGreaterThan ( 0 ) ;
@@ -247,13 +233,14 @@ describe('The stylelint provider for Linter', () => {
247
233
} ) ;
248
234
249
235
describe ( 'works with SugarSS files and' , ( ) => {
236
+ const goodSugarSS = path . join ( fixtures , 'sugarss' , 'good.sss' ) ;
237
+ const badSugarSS = path . join ( fixtures , 'sugarss' , 'bad.sss' ) ;
238
+
250
239
beforeEach ( async ( ) => {
251
- atom . config . set ( 'linter-stylelint.useStandard' , true ) ;
252
- atom . config . set ( 'linter-stylelint.disableWhenNoConfig' , false ) ;
253
240
await atom . packages . activatePackage ( 'language-postcss' ) ;
254
241
} ) ;
255
242
256
- it ( 'works with stylelint-config-standard ' , async ( ) => {
243
+ it ( 'shows lint messages when found ' , async ( ) => {
257
244
const nlzMessage = 'Expected a leading zero (<a href="http://stylelint.io/user-guide/rules/number-leading-zero">number-leading-zero</a>)' ;
258
245
const editor = await atom . workspace . open ( badSugarSS ) ;
259
246
const messages = await lint ( editor ) ;
0 commit comments