-
-
Notifications
You must be signed in to change notification settings - Fork 85
Expand file tree
/
Copy pathindex.test.mjs
More file actions
57 lines (50 loc) · 1.34 KB
/
index.test.mjs
File metadata and controls
57 lines (50 loc) · 1.34 KB
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
import { spawn } from 'node:child_process';
import { platform } from 'node:process';
import assert from 'node:assert';
{
const child = spawn(
'npx',
[
'stylelint',
'--stdin',
'--stdin-filename',
'/example.css',
'--custom-formatter',
'@csstools/stylelint-formatter-github',
],
{
shell: platform === 'win32',
},
);
let stdoutBuffer = '';
let stderrBuffer = '';
child.stdout.setEncoding('utf8');
child.stdout.on('data', (data) => {
data = data.toString();
stdoutBuffer += data;
});
child.stderr.setEncoding('utf8');
child.stderr.on('data', (data) => {
data = data.toString();
stderrBuffer += data;
});
child.stdin.write(`
a {}
b {
color: red;
color: blue;
}
`);
child.stdin.end();
child.on('close', () => {
assert.strictEqual(
stdoutBuffer,
'',
);
assert.strictEqual(
stderrBuffer,
'::warning file=/example.css,line=3,col=3,endLine=6,endColumn=4,title=Stylelint problem::Expected empty line before rule (rule-empty-line-before) [maybe fixable] - https://stylelint.io/user-guide/rules/rule-empty-line-before\n' +
'::error file=/example.css,line=4,col=4,endLine=4,endColumn=9,title=Stylelint problem::Duplicate property "color" (declaration-block-no-duplicate-properties) [maybe fixable] - https://stylelint.io/user-guide/rules/declaration-block-no-duplicate-properties\n',
);
});
}