Skip to content

Commit 26a1793

Browse files
Rewrote tests
1 parent a7abfb8 commit 26a1793

File tree

4 files changed

+48
-58
lines changed

4 files changed

+48
-58
lines changed

packages/stylelint-config-airbnb/index.js

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,19 @@ module.exports = {
33
'stylelint-scss',
44
],
55
rules: {
6+
indentation: 2,
7+
'max-nesting-depth': 2,
8+
'selector-no-id': true,
9+
'selector-list-comma-newline-after': 'always',
10+
'rule-non-nested-empty-line-before': ['always', { ignore: ['after-comment'] }],
11+
'no-invalid-double-slash-comments': true,
12+
'comment-empty-line-before': ['always', { ignore: ['stylelint-commands'] }],
613
'at-rule-empty-line-before': 'never',
714
'block-opening-brace-space-before': 'always',
8-
'comment-empty-line-before': ['always', {
9-
ignore: ['stylelint-commands'],
10-
}],
1115
'declaration-colon-space-after': 'always',
1216
'declaration-colon-space-before': 'never',
13-
indentation: 2,
14-
'max-nesting-depth': 3,
15-
'no-invalid-double-slash-comments': true,
16-
'rule-non-nested-empty-line-before': ['always', {
17-
ignore: ['after-comment'],
18-
}],
19-
'selector-list-comma-newline-after': 'always',
20-
'selector-no-id': true,
21-
2217
'scss/dollar-variable-pattern': '^[_a-z][\\w-]*$',
2318
'scss/at-extend-no-missing-placeholder': true,
24-
25-
'declaration-property-value-blacklist': {
26-
'/^border/': ['none'],
27-
},
19+
'declaration-property-value-blacklist': { '/^border/': ['none'] },
2820
},
2921
};

packages/stylelint-config-airbnb/test/test-base-invalid.scss

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ $BadVariable: none;
1111
border: none;
1212
}
1313

14-
// .bad-comment { color: pink }
15-
14+
// bad comment
1615
.foo {
1716
border: none;
1817
}
@@ -21,10 +20,8 @@ $BadVariable: none;
2120
.page-container {
2221
.content {
2322
.profile {
24-
.image {
25-
.toodeep {
23+
.toodeep {
2624

27-
}
2825
}
2926
}
3027
}

packages/stylelint-config-airbnb/test/test-base-valid.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ $_my-private-variable: 2px;
1212
border: 2px;
1313
}
1414

15+
/* good comment */
1516
.foo {
1617
border: 0;
1718
}

packages/stylelint-config-airbnb/test/test-base.js

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -31,112 +31,112 @@ test('warnings with invalid css', t => {
3131
const { errored, results } = data;
3232
const { warnings } = results[0];
3333
t.truthy(errored, 'errored');
34-
t.is(warnings.length, 21, 'flags one warning');
34+
t.is(warnings.length, 21, 'flags 21 warnings');
3535

3636
t.is(warnings[0].text,
37-
'Unexpected empty line before at-rule (at-rule-empty-line-before)',
38-
'correct warning text'
37+
'Expected indentation of 2 spaces (indentation)',
38+
'flags wrong indentation'
3939
);
4040

4141
t.is(warnings[1].text,
42-
'Expected single space before "{" (block-opening-brace-space-before)',
43-
'correct warning text'
42+
'Expected indentation of 2 spaces (indentation)',
43+
'flags wrong indentation'
4444
);
4545

4646
t.is(warnings[2].text,
47-
'Expected empty line before comment (comment-empty-line-before)',
48-
'correct warning text'
47+
'Expected nesting depth to be no more than 2 (max-nesting-depth)',
48+
'flags nesting depth when more than 2'
4949
);
5050

5151
t.is(warnings[3].text,
52-
'Expected single space after ":" (declaration-colon-space-after)',
53-
'correct warning text'
52+
'Unexpected id selector (selector-no-id)',
53+
'flags id selector'
5454
);
5555

5656
t.is(warnings[4].text,
57-
'Expected single space after ":" (declaration-colon-space-after)',
58-
'correct warning text'
57+
'Expected newline after "," (selector-list-comma-newline-after)',
58+
'flags missing newline after ","'
5959
);
6060

6161
t.is(warnings[5].text,
62-
'Unexpected whitespace before ":" (declaration-colon-space-before)',
63-
'correct warning text'
62+
'Expected newline after "," (selector-list-comma-newline-after)',
63+
'flags missing newline after ","'
6464
);
6565

6666
t.is(warnings[6].text,
67-
'Expected indentation of 2 spaces (indentation)',
68-
'correct warning text'
67+
'Expected empty line before non-nested rule (rule-non-nested-empty-line-before)',
68+
'flags missing empty line before non-nested rule'
6969
);
7070

7171
t.is(warnings[7].text,
72-
'Expected indentation of 2 spaces (indentation)',
73-
'correct warning text'
72+
'Expected empty line before non-nested rule (rule-non-nested-empty-line-before)',
73+
'flags missing empty line before non-nested rule'
7474
);
7575

7676
t.is(warnings[8].text,
77-
'Expected nesting depth to be no more than 3 (max-nesting-depth)',
78-
'correct warning text'
77+
'Expected empty line before non-nested rule (rule-non-nested-empty-line-before)',
78+
'flags missing empty line before non-nested rule'
7979
);
8080

8181
t.is(warnings[9].text,
8282
'Unexpected double-slash CSS comment (no-invalid-double-slash-comments)',
83-
'correct warning text'
83+
'flags double-slash comments'
8484
);
8585

8686
t.is(warnings[10].text,
87-
'Expected empty line before non-nested rule (rule-non-nested-empty-line-before)',
88-
'correct warning text'
87+
'Expected empty line before comment (comment-empty-line-before)',
88+
'flags missing empty line before comment'
8989
);
9090

9191
t.is(warnings[11].text,
92-
'Expected empty line before non-nested rule (rule-non-nested-empty-line-before)',
93-
'correct warning text'
92+
'Unexpected empty line before at-rule (at-rule-empty-line-before)',
93+
'flags missing empty line before non-nested rule'
9494
);
9595

9696
t.is(warnings[12].text,
97-
'Expected empty line before non-nested rule (rule-non-nested-empty-line-before)',
98-
'correct warning text'
97+
'Expected single space before "{" (block-opening-brace-space-before)',
98+
'flags missing single space before "{"'
9999
);
100100

101101
t.is(warnings[13].text,
102-
'Expected newline after "," (selector-list-comma-newline-after)',
103-
'correct warning text'
102+
'Expected single space after ":" (declaration-colon-space-after)',
103+
'flags missing single space after ":"'
104104
);
105105

106106
t.is(warnings[14].text,
107-
'Expected newline after "," (selector-list-comma-newline-after)',
108-
'correct warning text'
107+
'Expected single space after ":" (declaration-colon-space-after)',
108+
'flags missing single space after ":"'
109109
);
110110

111111
t.is(warnings[15].text,
112-
'Unexpected id selector (selector-no-id)',
113-
'correct warning text'
112+
'Unexpected whitespace before ":" (declaration-colon-space-before)',
113+
'flags whitepace before ":"'
114114
);
115115

116116
t.is(warnings[16].text,
117117
'Expected $ variable name to match specified pattern (scss/dollar-variable-pattern)',
118-
'correct warning text'
118+
'flags variables of wrong convention'
119119
);
120120

121121
t.is(warnings[17].text,
122122
'Expected a placeholder selector (e.g. %placeholder) to be used in ' +
123123
'@extend (scss/at-extend-no-missing-placeholder)',
124-
'correct warning text'
124+
'flags wrong @extend statements'
125125
);
126126

127127
t.is(warnings[18].text,
128128
'Unexpected value "none" for property "border" (declaration-property-value-blacklist)',
129-
'correct warning text'
129+
'flags "border: none" statements'
130130
);
131131

132132
t.is(warnings[19].text,
133133
'Unexpected value "none" for property "border" (declaration-property-value-blacklist)',
134-
'correct warning text'
134+
'flags "border: none" statements'
135135
);
136136

137137
t.is(warnings[20].text,
138138
'Unexpected value "none" for property "border" (declaration-property-value-blacklist)',
139-
'correct warning text'
139+
'flags "border: none" statements'
140140
);
141141
});
142142

0 commit comments

Comments
 (0)