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

Commit b0bd7ce

Browse files
committed
Stop relying on useStandard in all the specs
Add configuration files where appropriate, allowing the option to be left at the default of disabled for all relevant specs.
1 parent e83677b commit b0bd7ce

File tree

8 files changed

+64
-48
lines changed

8 files changed

+64
-48
lines changed

spec/fixtures/good/.stylelintrc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"rules": {
3+
"block-no-empty": true
4+
}
5+
}
Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
{
2-
"ignoreFiles": ["styles.css"],
3-
"rules": { "block-no-empty": true }
2+
"ignoreFiles": [
3+
"styles.css"
4+
],
5+
"rules": {
6+
"block-no-empty": true
7+
}
48
}

spec/fixtures/invalid/.stylelintrc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"rules": {
3+
"block-no-empty": true
4+
}
5+
}

spec/fixtures/less/.stylelintrc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"rules": {
3+
"block-no-empty": true
4+
}
5+
}

spec/fixtures/postcss/.stylelintrc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"rules": {
3+
"block-no-empty": true
4+
}
5+
}

spec/fixtures/sugarss/.stylelintrc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"rules": {
3+
"number-leading-zero": "always"
4+
}
5+
}

spec/linter-stylelint-spec.js

Lines changed: 33 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,10 @@ import * as path from 'path';
44
// eslint-disable-next-line no-unused-vars, import/no-extraneous-dependencies
55
import { it, fit, wait, beforeEach, afterEach } from 'jasmine-fix';
66

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');
2311

2412
const blockNoEmpty = 'Unexpected empty block (<a href="http://stylelint.io/user-guide/rules/block-no-empty">block-no-empty</a>)';
2513

@@ -28,14 +16,13 @@ describe('The stylelint provider for Linter', () => {
2816

2917
beforeEach(async () => {
3018
atom.workspace.destroyActivePaneItem();
31-
atom.config.set('linter-stylelint.useStandard', true);
3219

3320
await atom.packages.activatePackage('language-css');
3421
await atom.packages.activatePackage('linter-stylelint');
3522
});
3623

3724
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);
3926
const editor = await atom.workspace.open(configStandardPath);
4027
const messages = await lint(editor);
4128
expect(messages.length).toBeGreaterThan(0);
@@ -50,8 +37,7 @@ describe('The stylelint provider for Linter', () => {
5037
});
5138

5239
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);
5541
const messages = await lint(editor);
5642

5743
expect(messages.length).toBeGreaterThan(0);
@@ -66,13 +52,14 @@ describe('The stylelint provider for Linter', () => {
6652
});
6753

6854
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);
7057
const messages = await lint(editor);
7158
expect(messages.length).toBe(0);
7259
});
7360

7461
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');
7663
const editor = await atom.workspace.open(invalidPath);
7764
const messages = await lint(editor);
7865
expect(messages.length).toBe(1);
@@ -87,7 +74,6 @@ describe('The stylelint provider for Linter', () => {
8774

8875
it('shows an error on non-fatal stylelint runtime error', async () => {
8976
const text = 'Unexpected option value "foo" for rule "block-no-empty"';
90-
atom.config.set('linter-stylelint.useStandard', false);
9177
const editor = await atom.workspace.open(invalidRulePath);
9278
const messages = await lint(editor);
9379
expect(messages.length).toBe(1);
@@ -101,7 +87,8 @@ describe('The stylelint provider for Linter', () => {
10187
});
10288

10389
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+
10592
spyOn(atom.notifications, 'addError').andCallFake(() => ({}));
10693
const addError = atom.notifications.addError;
10794

@@ -117,7 +104,8 @@ describe('The stylelint provider for Linter', () => {
117104
});
118105

119106
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+
121109
spyOn(atom.notifications, 'addError').andCallFake(() => ({}));
122110
const addError = atom.notifications.addError;
123111

@@ -133,7 +121,6 @@ describe('The stylelint provider for Linter', () => {
133121
});
134122

135123
it('disables when no configuration file is found', async () => {
136-
atom.config.set('linter-stylelint.disableWhenNoConfig', true);
137124
spyOn(atom.notifications, 'addError').andCallFake(() => ({}));
138125

139126
const editor = await atom.workspace.open(configStandardPath);
@@ -143,9 +130,7 @@ describe('The stylelint provider for Linter', () => {
143130
});
144131

145132
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');
149134

150135
it('shows a message when asked to', async () => {
151136
atom.config.set('linter-stylelint.showIgnored', true);
@@ -170,35 +155,35 @@ describe('The stylelint provider for Linter', () => {
170155
});
171156

172157
it("doesn't persist settings across runs", async () => {
173-
atom.config.set('linter-stylelint.useStandard', true);
174-
atom.config.set('linter-stylelint.disableWhenNoConfig', false);
175158
// The config for this folder breaks the block-no-empty rule
176159
const invalidEditor = await atom.workspace.open(invalidRulePath);
177160
await lint(invalidEditor);
178161

179162
// While this file uses that rule
180-
const editor = await atom.workspace.open(configStandardPath);
163+
const editor = await atom.workspace.open(warningPath);
181164
const messages = await lint(editor);
182165
expect(messages.length).toBeGreaterThan(0);
183166

184167
// 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');
187170
expect(messages[0].text).not.toBeDefined();
188171
expect(messages[0].html).toBe(blockNoEmpty);
189-
expect(messages[0].filePath).toBe(configStandardPath);
172+
expect(messages[0].filePath).toBe(warningPath);
190173
expect(messages[0].range).toEqual([[0, 5], [0, 7]]);
191174
});
192175

193176
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+
194181
beforeEach(async () => {
195-
atom.config.set('linter-stylelint.useStandard', true);
196-
atom.config.set('linter-stylelint.disableWhenNoConfig', false);
197182
await atom.packages.activatePackage('language-less');
198183
});
199184

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);
202187
const messages = await lint(editor);
203188
expect(messages.length).toBeGreaterThan(0);
204189

@@ -207,7 +192,7 @@ describe('The stylelint provider for Linter', () => {
207192
expect(messages[0].severity).toBe('error');
208193
expect(messages[0].text).not.toBeDefined();
209194
expect(messages[0].html).toBe(blockNoEmpty);
210-
expect(messages[0].filePath).toBe(configStandardLessPath);
195+
expect(messages[0].filePath).toBe(badLess);
211196
expect(messages[0].range).toEqual([[0, 5], [0, 7]]);
212197
});
213198

@@ -219,13 +204,14 @@ describe('The stylelint provider for Linter', () => {
219204
});
220205

221206
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+
222210
beforeEach(async () => {
223-
atom.config.set('linter-stylelint.useStandard', true);
224-
atom.config.set('linter-stylelint.disableWhenNoConfig', false);
225211
await atom.packages.activatePackage('language-postcss');
226212
});
227213

228-
it('works with stylelint-config-standard', async () => {
214+
it('shows lint messages when found', async () => {
229215
const editor = await atom.workspace.open(issuesPostCSS);
230216
const messages = await lint(editor);
231217
expect(messages.length).toBeGreaterThan(0);
@@ -247,13 +233,14 @@ describe('The stylelint provider for Linter', () => {
247233
});
248234

249235
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+
250239
beforeEach(async () => {
251-
atom.config.set('linter-stylelint.useStandard', true);
252-
atom.config.set('linter-stylelint.disableWhenNoConfig', false);
253240
await atom.packages.activatePackage('language-postcss');
254241
});
255242

256-
it('works with stylelint-config-standard', async () => {
243+
it('shows lint messages when found', async () => {
257244
const nlzMessage = 'Expected a leading zero (<a href="http://stylelint.io/user-guide/rules/number-leading-zero">number-leading-zero</a>)';
258245
const editor = await atom.workspace.open(badSugarSS);
259246
const messages = await lint(editor);

0 commit comments

Comments
 (0)