/
index.js
89 lines (80 loc) · 2.39 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
'use strict';
const standalone = require('../../../standalone');
const { messages, ruleName, meta } = require('..');
it('warns that the rule is deprecated', () => {
const config = {
rules: {
[ruleName]: { page: ['margin'] },
},
};
const code = '';
return standalone({ code, config }).then((output) => {
const result = output.results[0];
expect(result.deprecations).toHaveLength(1);
expect(result.deprecations[0].text).toEqual(
`'${ruleName}' has been deprecated. Instead use 'at-rule-property-required-list'.`,
);
expect(result.deprecations[0].reference).toEqual(
`https://github.com/stylelint/stylelint/blob/13.7.0/lib/rules/${ruleName}/README.md`,
);
});
});
it('also warns that the rule is deprecated via a meta', () => {
expect(meta).not.toBeUndefined();
expect(meta).toHaveProperty('deprecated', true);
});
testRule({
ruleName,
config: {
'font-face': ['font-display', 'font-family'],
page: ['margin'],
},
accept: [
{
code: "@font-face { font-display: auto; font-family: 'Arvo'; }",
description: '@font-face with both required properties',
},
{
code: "@font-face { font-display: auto; font-family: 'Arvo'; src: url('abc'); /* IE9 */ }",
description: '@font-face with inner comment',
},
{
code: "@FONT-FACE { FONT-DISPLAY: AUTO; FONT-FAMILY: 'ARVO'; }",
description: '@font-face with both required properties (case-sensitive)',
},
{
code: '@page { padding: 0.5cm; margin: 1cm; }',
description: '@page with required property',
},
{
code: '@counter-style counter { system: cyclic; }',
description: 'at-rule not specified in config',
},
{
code: '@mixin invalid-at-rule { @content; }',
description: '@mixin with invalid at-rule',
},
],
reject: [
{
code: '@font-face { font-display: auto; }',
description: '@font-face with missing property',
message: messages.expected('font-family', 'font-face'),
},
{
code: '@FONT-FACE { FONT-DISPLAY: AUTO; }',
description: '@font-face with missing property (case-sensitive)',
message: messages.expected('font-family', 'font-face'),
},
{
code: "@font-face { font-family: 'Arvo'; font-weight: normal }",
description: '@font-face with missing property',
message: messages.expected('font-display', 'font-face'),
},
{
code: '@page { padding: 0.5cm }',
description: '@page with missing property',
message: messages.expected('margin', 'page'),
},
],
});