-
Notifications
You must be signed in to change notification settings - Fork 22
/
index.js
67 lines (59 loc) · 2.05 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
import {lint} from './utils/index.js'
import stylelint from 'stylelint'
const SAFE_SCSS_EXAMPLE = `
.Component { float: left; }
`
describe('stylelint-config', () => {
it('stylelint runs with our config', () => {
return lint('.uppercase { text-transform: uppercase; }').then(data => {
expect(data).not.toHaveErrored()
expect(data).toHaveResultsLength(1)
})
})
it('produces zero warnings with valid css', () => {
return lint(`
.selector-x { width: 10%; }
.selector-y { width: 20%; }
.selector-z { width: 30%; }
`).then(data => {
expect(data).not.toHaveErrored()
expect(data).toHaveResultsLength(1)
expect(data).toHaveWarningsLength(0)
})
})
it('generates two warnings with invalid css', () => {
return lint(`
.foo {
width: 10px;
top: .2em;
max-width: initial;
}
`).then(data => {
expect(data).toHaveErrored()
expect(data).toHaveWarningsLength(2)
expect(data).toHaveWarnings([
'Expected "top" to come before "width" (order/properties-order)',
'Unexpected value "initial" for property "max-width" (declaration-property-value-disallowed-list)',
])
})
})
it('does not report any deprecations', () => {
return lint(SAFE_SCSS_EXAMPLE).then(data => {
expect(data).not.toHaveErrored()
expect(data).not.toHaveResultsLength(0)
expect(data).toHaveDeprecationsLength(0)
})
})
it('resolves css files correctly', async () => {
const config = await stylelint.resolveConfig('./__fixtures__/good/example.css')
expect(config).not.toHaveProperty('customSyntax')
})
it('resolves tsx files correctly', async () => {
const config = await stylelint.resolveConfig('./__fixtures__/good/example.tsx')
expect(config).toHaveProperty('customSyntax', 'postcss-styled-syntax')
})
it('resolves scss files correctly', async () => {
const config = await stylelint.resolveConfig('./__fixtures__/good/example.scss')
expect(config).toHaveProperty('customSyntax', 'postcss-scss')
})
})