Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: postcss/postcss-scss
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 4.0.0
Choose a base ref
...
head repository: postcss/postcss-scss
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 4.0.1
Choose a head ref
  • 6 commits
  • 6 files changed
  • 3 contributors

Commits on Jun 14, 2021

  1. Clean up docs

    ai committed Jun 14, 2021
    Copy the full SHA
    2e7b9f5 View commit details

Commits on Jun 21, 2021

  1. Bump set-getter from 0.1.0 to 0.1.1 (#127)

    Bumps [set-getter](https://github.com/doowb/set-getter) from 0.1.0 to 0.1.1.
    - [Release notes](https://github.com/doowb/set-getter/releases)
    - [Commits](https://github.com/doowb/set-getter/commits/0.1.1)
    
    ---
    updated-dependencies:
    - dependency-name: set-getter
      dependency-type: indirect
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    dependabot[bot] authored Jun 21, 2021
    Copy the full SHA
    99efeb6 View commit details

Commits on Sep 21, 2021

  1. Bump tmpl from 1.0.4 to 1.0.5 (#128)

    Bumps [tmpl](https://github.com/daaku/nodejs-tmpl) from 1.0.4 to 1.0.5.
    - [Release notes](https://github.com/daaku/nodejs-tmpl/releases)
    - [Commits](https://github.com/daaku/nodejs-tmpl/commits/v1.0.5)
    
    ---
    updated-dependencies:
    - dependency-name: tmpl
      dependency-type: indirect
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    dependabot[bot] authored Sep 21, 2021
    Copy the full SHA
    54a9f24 View commit details

Commits on Sep 29, 2021

  1. Verified

    This commit was signed with the committer’s verified signature.
    0xE282B0 Sven Pfennig
    Copy the full SHA
    5a203ea View commit details
  2. Update dependencies

    ai committed Sep 29, 2021

    Verified

    This commit was signed with the committer’s verified signature.
    0xE282B0 Sven Pfennig
    Copy the full SHA
    f955f12 View commit details
  3. Release 4.0.1 version

    ai committed Sep 29, 2021
    Copy the full SHA
    e5ffc96 View commit details
Showing with 1,023 additions and 1,000 deletions.
  1. +3 −0 CHANGELOG.md
  2. +4 −11 README.md
  3. +13 −5 lib/scss-parser.js
  4. +13 −13 package.json
  5. +30 −0 test/parse.test.js
  6. +960 −971 yarn.lock
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Change Log
This project adheres to [Semantic Versioning](http://semver.org/).

## 4.0.1
* Fixed source start line and column (by Ivan Nikolić).

## 4.0
* Removed Node.js 10 support.
* Moved `postcss` to `peerDependencies`.
15 changes: 4 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# PostCSS SCSS Syntax [![Build Status][ci-img]][ci]
# PostCSS SCSS Syntax

<img align="right" width="95" height="95"
title="Philosopher’s stone, logo of PostCSS"
@@ -11,25 +11,18 @@ at-rules & variables as properties, so that PostCSS plugins can then transform
SCSS source code alongside CSS.

[PostCSS]: https://github.com/postcss/postcss
[ci-img]: https://img.shields.io/travis/postcss/postcss-scss.svg
[SCSS]: http://sass-lang.com/
[ci]: https://travis-ci.org/postcss/postcss-scss

<a href="https://evilmartians.com/?utm_source=postcss">
<img src="https://evilmartians.com/badges/sponsored-by-evil-martians.svg" alt="Sponsored by Evil Martians" width="236" height="54">
<img src="https://evilmartians.com/badges/sponsored-by-evil-martians.svg"
alt="Sponsored by Evil Martians" width="236" height="54">
</a>


## Install

```sh
npm --save install postcss-scss
```

or (if you use [Yarn](https://yarnpkg.com/))

```sh
yarn add --dev postcss-scss
npm --save install postcss postcss-scss
```


18 changes: 13 additions & 5 deletions lib/scss-parser.js
Original file line number Diff line number Diff line change
@@ -5,11 +5,11 @@ let NestedDeclaration = require('./nested-declaration')
let scssTokenizer = require('./scss-tokenize')

class ScssParser extends Parser {
createTokenizer () {
createTokenizer() {
this.tokenizer = scssTokenizer(this.input)
}

rule (tokens) {
rule(tokens) {
let withColon = false
let brackets = 0
let value = ''
@@ -54,7 +54,15 @@ class ScssParser extends Parser {
while (tokens[0][0] !== 'word') {
node.raws.before += tokens.shift()[1]
}
node.source.start = { line: tokens[0][2], column: tokens[0][3] }

if (tokens[0][2]) {
let pos = this.input.fromOffset(tokens[0][2])
node.source.start = {
offset: tokens[0][2],
line: pos.line,
column: pos.col
}
}

node.prop = ''
while (tokens.length) {
@@ -128,7 +136,7 @@ class ScssParser extends Parser {
}
}

comment (token) {
comment(token) {
if (token[4] === 'inline') {
let node = new Comment()
this.init(node, token[2])
@@ -154,7 +162,7 @@ class ScssParser extends Parser {
}
}

raw (node, prop, tokens) {
raw(node, prop, tokens) {
super.raw(node, prop, tokens)
if (node.raws[prop]) {
let scss = node.raws[prop].raw
26 changes: 13 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "postcss-scss",
"version": "4.0.0",
"version": "4.0.1",
"description": "SCSS parser for PostCSS",
"keywords": [
"css",
@@ -36,24 +36,24 @@
"postcss": "^8.3.3"
},
"devDependencies": {
"@logux/eslint-config": "^45.4.4",
"clean-publish": "^2.2.0",
"eslint": "^7.28.0",
"@logux/eslint-config": "^45.4.8",
"clean-publish": "^3.0.3",
"eslint": "^7.32.0",
"eslint-config-standard": "^16.0.3",
"eslint-plugin-import": "^2.23.4",
"eslint-plugin-jest": "^24.3.6",
"eslint-plugin-import": "^2.24.2",
"eslint-plugin-jest": "^24.5.0",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prefer-let": "^1.1.0",
"eslint-plugin-promise": "^5.1.0",
"eslint-plugin-security": "^1.4.0",
"eslint-plugin-unicorn": "^33.0.1",
"jest": "^27.0.4",
"lint-staged": "^11.0.0",
"postcss": "^8.3.3",
"postcss-parser-tests": "^8.3.5",
"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",
"prettier": "^2.2.1",
"simple-git-hooks": "^2.4.1"
"prettier": "^2.4.1",
"simple-git-hooks": "^2.6.1"
},
"simple-git-hooks": {
"pre-commit": "npx lint-staged"
30 changes: 30 additions & 0 deletions test/parse.test.js
Original file line number Diff line number Diff line change
@@ -12,6 +12,11 @@ eachTest((name, css, json) => {
it('parses nested rules', () => {
let root = parse('a { b {} }')
expect(root.first.first.selector).toEqual('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)
})

it('parses at-rules inside rules', () => {
@@ -127,6 +132,11 @@ 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.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)
})

it('parses nested props with value', () => {
@@ -138,25 +148,45 @@ it('parses nested props with value', () => {

expect(root.first.first.first.prop).toEqual('left')
expect(root.first.first.first.value).toEqual('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)
})

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.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)
})

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.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)
})

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.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)
})

it('parses interpolation with variable', () => {
Loading