Skip to content

Commit

Permalink
Update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
ai committed Oct 29, 2021
1 parent c021e23 commit 77809e0
Show file tree
Hide file tree
Showing 5 changed files with 866 additions and 929 deletions.
12 changes: 8 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ name: Test
"on":
push: null
pull_request: null
env:
FORCE_COLOR: 2
jobs:
full:
name: Node.js 16 Full
Expand All @@ -15,10 +13,13 @@ jobs:
uses: actions/setup-node@v2
with:
node-version: 16
cache: yarn
- name: Install dependencies
uses: bahmutov/npm-install@v1
run: yarn install --frozen-lockfile
- name: Run tests
run: yarn test
env:
FORCE_COLOR: 2
short:
runs-on: ubuntu-latest
strategy:
Expand All @@ -34,7 +35,10 @@ jobs:
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
cache: yarn
- name: Install dependencies
uses: bahmutov/npm-install@v1
run: yarn install --frozen-lockfile
- name: Run unit tests
run: npx jest
env:
FORCE_COLOR: 2
33 changes: 18 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,24 +36,24 @@
"postcss": "^8.3.3"
},
"devDependencies": {
"@logux/eslint-config": "^45.4.8",
"clean-publish": "^3.0.3",
"eslint": "^7.32.0",
"@logux/eslint-config": "^46.0.1",
"clean-publish": "^3.4.2",
"eslint": "^8.1.0",
"eslint-config-standard": "^16.0.3",
"eslint-plugin-import": "^2.24.2",
"eslint-plugin-jest": "^24.5.0",
"eslint-plugin-import": "^2.25.2",
"eslint-plugin-jest": "^25.2.2",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prefer-let": "^1.1.0",
"eslint-plugin-promise": "^5.1.0",
"eslint-plugin-prefer-let": "^3.0.0",
"eslint-plugin-promise": "^5.1.1",
"eslint-plugin-security": "^1.4.0",
"eslint-plugin-unicorn": "^36.0.0",
"jest": "^27.2.3",
"lint-staged": "^11.1.2",
"postcss": "^8.3.8",
"postcss-parser-tests": "^8.3.6",
"postcss-sharec-config": "^0.4.1",
"eslint-plugin-unicorn": "^37.0.1",
"jest": "^27.3.1",
"lint-staged": "^11.2.6",
"postcss": "^8.3.11",
"postcss-parser-tests": "^8.3.7",
"postcss-sharec-config": "^0.5.1",
"prettier": "^2.4.1",
"simple-git-hooks": "^2.6.1"
"simple-git-hooks": "^2.7.0"
},
"simple-git-hooks": {
"pre-commit": "npx lint-staged"
Expand Down Expand Up @@ -86,8 +86,11 @@
}
}
},
"clean-publish": {
"cleanDocs": true
},
"sharec": {
"config": "postcss-sharec-config",
"version": "0.4.1"
"version": "0.5.1"
}
}
152 changes: 76 additions & 76 deletions test/parse.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,49 +11,49 @@ eachTest((name, css, json) => {

it('parses nested rules', () => {
let root = parse('a { b {} }')
expect(root.first.first.selector).toEqual('b')
expect(root.first.first.selector).toBe('b')

expect(root.first.first.source.start.line).toEqual(1)
expect(root.first.first.source.start.column).toEqual(5)
expect(root.first.first.source.end.line).toEqual(1)
expect(root.first.first.source.end.column).toEqual(8)
expect(root.first.first.source.start.line).toBe(1)
expect(root.first.first.source.start.column).toBe(5)
expect(root.first.first.source.end.line).toBe(1)
expect(root.first.first.source.end.column).toBe(8)
})

it('parses at-rules inside rules', () => {
let root = parse('a { @media {} }')
expect(root.first.first.name).toEqual('media')
expect(root.first.first.name).toBe('media')
})

it('parses variables', () => {
let root = parse('$var: 1;')
expect(root.first.prop).toEqual('$var')
expect(root.first.value).toEqual('1')
expect(root.first.prop).toBe('$var')
expect(root.first.value).toBe('1')
})

it('parses inline comments', () => {
let root = parse('\n// a \n/* b */')
expect(root.nodes).toHaveLength(2)
expect(root.first.text).toEqual('a')
expect(root.first.text).toBe('a')
expect(root.first.raws).toEqual({
before: '\n',
left: ' ',
right: ' ',
inline: true,
text: 'a'
})
expect(root.last.text).toEqual('b')
expect(root.last.text).toBe('b')
})

it('parses empty inline comments', () => {
let root = parse('//\n// ')
expect(root.first.text).toEqual('')
expect(root.first.text).toBe('')
expect(root.first.raws).toEqual({
before: '',
left: '',
right: '',
inline: true
})
expect(root.last.text).toEqual('')
expect(root.last.text).toBe('')
expect(root.last.raws).toEqual({
before: '\n',
left: ' ',
Expand All @@ -64,172 +64,172 @@ it('parses empty inline comments', () => {

it('parses inline comments inside selector', () => {
let root = parse('a\n// c/**/\nb { }')
expect(root.first.raws.selector.scss).toEqual('a\n// c/**/\nb')
expect(root.first.raws.selector.raw).toEqual('a\n/* c*//**//**/\nb')
expect(root.first.raws.selector.scss).toBe('a\n// c/**/\nb')
expect(root.first.raws.selector.raw).toBe('a\n/* c*//**//**/\nb')
})

it('does not parse comments inside brackets', () => {
let root = parse('a { cursor: url(http://ya.ru) }')
expect(root.first.first.value).toEqual('url(http://ya.ru)')
expect(root.first.first.value).toBe('url(http://ya.ru)')
})

it('does not parse comments inside brackets and spaces', () => {
let root = parse('a { cursor: url( http://ya.ru ) }')
expect(root.first.first.value).toEqual('url( http://ya.ru )')
expect(root.first.first.value).toBe('url( http://ya.ru )')
})

it('parses interpolation', () => {
let root = parse('#{$selector}:hover { #{$prop}-size: #{$color} }')
expect(root.first.selector).toEqual('#{$selector}:hover')
expect(root.first.first.prop).toEqual('#{$prop}-size')
expect(root.first.first.value).toEqual('#{$color}')
expect(root.first.selector).toBe('#{$selector}:hover')
expect(root.first.first.prop).toBe('#{$prop}-size')
expect(root.first.first.value).toBe('#{$color}')
})

it('parses interpolation inside word', () => {
let root = parse('.#{class} {}')
expect(root.first.selector).toEqual('.#{class}')
expect(root.first.selector).toBe('.#{class}')
})

it('parses non-interpolation', () => {
let root = parse('\\#{ color: black }')
expect(root.first.selector).toEqual('\\#')
expect(root.first.selector).toBe('\\#')
})

it('parses interpolation inside interpolation', () => {
let root = parse('$column: #{"#{&}__column"};')
expect(root.first.value).toEqual('#{"#{&}__column"}')
expect(root.first.value).toBe('#{"#{&}__column"}')
})

it("parses interpolation that's the entire at-rule", () => {
let root = parse('@#{$var} param { }')
expect(root.first.name).toEqual('#{$var}')
expect(root.first.params).toEqual('param')
expect(root.first.name).toBe('#{$var}')
expect(root.first.params).toBe('param')
})

it('parses interpolation at the beginning of at-rule', () => {
let root = parse('@#{$var}suffix param { }')
expect(root.first.name).toEqual('#{$var}suffix')
expect(root.first.params).toEqual('param')
expect(root.first.name).toBe('#{$var}suffix')
expect(root.first.params).toBe('param')
})

it('parses interpolation within at-rule', () => {
let root = parse('@before#{$var}after param { }')
expect(root.first.name).toEqual('before#{$var}after')
expect(root.first.params).toEqual('param')
expect(root.first.name).toBe('before#{$var}after')
expect(root.first.params).toBe('param')
})

it('parses interpolation right after at-rule', () => {
let root = parse('@media#{$var} { }')
expect(root.first.name).toEqual('media#{$var}')
expect(root.first.params).toEqual('')
expect(root.first.name).toBe('media#{$var}')
expect(root.first.params).toBe('')
})

it('parses interpolation in at-rule value', () => {
let root = parse('@media #{$var} { }')
expect(root.first.name).toEqual('media')
expect(root.first.params).toEqual('#{$var}')
expect(root.first.name).toBe('media')
expect(root.first.params).toBe('#{$var}')
})

it('parses interpolation in url()', () => {
let root = parse('image: url(#{get(path)}.png)')
expect(root.first.value).toEqual('url(#{get(path)}.png)')
expect(root.first.value).toBe('url(#{get(path)}.png)')
})

it('parses text in rules', () => {
let root = parse('a { margin:text { left: 10px; }}')
expect(root.first.first.selector).toEqual('margin:text')
expect(root.first.first.first.prop).toEqual('left')
expect(root.first.first.selector).toBe('margin:text')
expect(root.first.first.first.prop).toBe('left')
})

it('parses semicolon in rules', () => {
let root = parse('a { test(a: 1) { left: 10px; }}')
expect(root.first.first.selector).toEqual('test(a: 1)')
expect(root.first.first.first.prop).toEqual('left')
expect(root.first.first.selector).toBe('test(a: 1)')
expect(root.first.first.first.prop).toBe('left')
})

it('parsers prefixed pseudo in rules', () => {
let root = parse('input:-moz-focusring { left: 1px }')
expect(root.first.selector).toEqual('input:-moz-focusring')
expect(root.first.first.prop).toEqual('left')
expect(root.first.selector).toBe('input:-moz-focusring')
expect(root.first.first.prop).toBe('left')
})

it('parses nested props as rule', () => {
let root = parse('a { margin: { left: 10px; }}')
expect(root.first.first.selector).toEqual('margin:')
expect(root.first.first.first.prop).toEqual('left')
expect(root.first.first.selector).toBe('margin:')
expect(root.first.first.first.prop).toBe('left')

expect(root.first.first.source.start.line).toEqual(1)
expect(root.first.first.source.start.column).toEqual(5)
expect(root.first.first.source.end.line).toEqual(1)
expect(root.first.first.source.end.column).toEqual(27)
expect(root.first.first.source.start.line).toBe(1)
expect(root.first.first.source.start.column).toBe(5)
expect(root.first.first.source.end.line).toBe(1)
expect(root.first.first.source.end.column).toBe(27)
})

it('parses nested props with value', () => {
let root = parse('a { margin: 0 { left: 10px; }}')

expect(root.first.first.prop).toEqual('margin')
expect(root.first.first.value).toEqual('0')
expect(root.first.first.raws.between).toEqual(': ')
expect(root.first.first.prop).toBe('margin')
expect(root.first.first.value).toBe('0')
expect(root.first.first.raws.between).toBe(': ')

expect(root.first.first.first.prop).toEqual('left')
expect(root.first.first.first.value).toEqual('10px')
expect(root.first.first.first.prop).toBe('left')
expect(root.first.first.first.value).toBe('10px')

expect(root.first.first.source.start.line).toEqual(1)
expect(root.first.first.source.start.column).toEqual(5)
expect(root.first.first.source.end.line).toEqual(1)
expect(root.first.first.source.end.column).toEqual(29)
expect(root.first.first.source.start.line).toBe(1)
expect(root.first.first.source.start.column).toBe(5)
expect(root.first.first.source.end.line).toBe(1)
expect(root.first.first.source.end.column).toBe(29)
})

it('parses nested props with space-less digit', () => {
let root = parse('a { margin:0 { left: 10px; }}')
expect(root.first.first.prop).toEqual('margin')
expect(root.first.first.value).toEqual('0')
expect(root.first.first.first.prop).toEqual('left')
expect(root.first.first.prop).toBe('margin')
expect(root.first.first.value).toBe('0')
expect(root.first.first.first.prop).toBe('left')

expect(root.first.first.source.start.line).toEqual(1)
expect(root.first.first.source.start.column).toEqual(5)
expect(root.first.first.source.end.line).toEqual(1)
expect(root.first.first.source.end.column).toEqual(28)
expect(root.first.first.source.start.line).toBe(1)
expect(root.first.first.source.start.column).toBe(5)
expect(root.first.first.source.end.line).toBe(1)
expect(root.first.first.source.end.column).toBe(28)
})

it('parses nested props with new line as rule', () => {
let root = parse('a { \n margin \n:0 { left: 10px; }}')
expect(root.first.first.selector).toEqual('margin \n:0')
expect(root.first.first.selector).toBe('margin \n:0')

expect(root.first.first.source.start.line).toEqual(2)
expect(root.first.first.source.start.column).toEqual(2)
expect(root.first.first.source.end.line).toEqual(3)
expect(root.first.first.source.end.column).toEqual(18)
expect(root.first.first.source.start.line).toBe(2)
expect(root.first.first.source.start.column).toBe(2)
expect(root.first.first.source.end.line).toBe(3)
expect(root.first.first.source.end.column).toBe(18)
})

it('parses nested props with important', () => {
let root = parse('a { margin: 0!important { left: 10px; }}')
expect(root.first.first.prop).toEqual('margin')
expect(root.first.first.value).toEqual('0')
expect(root.first.first.prop).toBe('margin')
expect(root.first.first.value).toBe('0')
expect(root.first.first.important).toBe(true)

expect(root.first.first.source.start.line).toEqual(1)
expect(root.first.first.source.start.column).toEqual(5)
expect(root.first.first.source.end.line).toEqual(1)
expect(root.first.first.source.end.column).toEqual(39)
expect(root.first.first.source.start.line).toBe(1)
expect(root.first.first.source.start.column).toBe(5)
expect(root.first.first.source.end.line).toBe(1)
expect(root.first.first.source.end.column).toBe(39)
})

it('parses interpolation with variable', () => {
let root = parse('&:#{$var} {}')
expect(root.first.selector).toEqual('&:#{$var}')
expect(root.first.selector).toBe('&:#{$var}')
})

it('parses comment inside comment', () => {
let root = parse('a {\n//a/*b*/c\n}')
expect(root.toString()).toEqual('a {\n/*a*//*b*//*c*/\n}')
expect(root.toString()).toBe('a {\n/*a*//*b*//*c*/\n}')
})

it('parses complex interpolation', () => {
let root = parse('content: #{fn("\\"}")};')
expect(root.first.value).toEqual('#{fn("\\"}")}')
expect(root.first.value).toBe('#{fn("\\"}")}')
})

it('parses interpolation inside string', () => {
let root = parse('content: "#{fn("\\"}")}";')
expect(root.first.value).toEqual('"#{fn("\\"}")}"')
expect(root.first.value).toBe('"#{fn("\\"}")}"')
})
Loading

0 comments on commit 77809e0

Please sign in to comment.