-
-
Notifications
You must be signed in to change notification settings - Fork 19
/
linters.js
54 lines (47 loc) · 1.23 KB
/
linters.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
/* Results on Node 20.3.1, Github Actions:
PostCSS: 577 ms
*/
let { existsSync, readFileSync } = require('node:fs')
let stylelint = require('stylelint')
let { join } = require('node:path')
let postcss = require('postcss')
let example = join(__dirname, 'cache', 'bootstrap.css')
let origin = readFileSync(example).toString()
let css = origin
.replace(/\s+filter:[^;}]+;?/g, '')
.replace('/*# sourceMappingURL=bootstrap.css.map */', '')
// PostCSS
let processor = postcss([
stylelint({ config: { extends: 'stylelint-config-standard' } })
])
module.exports = {
maxTime: 15,
name: 'Linters',
tests: [
{
defer: true,
fn: done => {
processor.process(css, { from: example, map: false }).then(() => {
done.resolve()
})
},
name: 'PostCSS'
}
]
}
let devPath = join(__dirname, '../postcss/lib/postcss.js')
if (existsSync(devPath)) {
let devPostcss = require(devPath)
let devProcessor = devPostcss([
stylelint({ config: { extends: 'stylelint-config-standard' } })
])
module.exports.tests.splice(1, 0, {
defer: true,
fn: done => {
devProcessor.process(css, { from: example, map: false }).then(() => {
done.resolve()
})
},
name: 'Next PostCSS'
})
}