Skip to content

Commit

Permalink
update parser and fix some bugs (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
ota-meshi committed Jan 8, 2023
1 parent 5fffa40 commit 5d48578
Show file tree
Hide file tree
Showing 14 changed files with 183 additions and 1 deletion.
13 changes: 13 additions & 0 deletions lib/rules/indentation.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,19 @@ function withWalkerWrapNodes(root) {
},
})
}

if (node.type === "decl" && node.raws.stylusBetween) {
const rawsWrapper = {}
Object.defineProperty(rawsWrapper, "between", {
get() {
return node.raws.stylusBetween
},
set(between) {
node.raws.stylusBetween = between
},
})
wrapper.raws = newProxy(node.raws, rawsWrapper)
}
if (Object.getOwnPropertyNames(wrapper).length) {
callback(newProxy(node, wrapper), ...args)
} else {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
"postcss-html": "^1.0.1",
"postcss-media-query-parser": "^0.2.3",
"postcss-selector-parser": "^6.0.2",
"postcss-styl": "^0.11.1",
"postcss-styl": "^0.12.2",
"style-search": "^0.1.0",
"stylelint-config-html": "^1.0.0",
"svg-tags": "^1.0.0"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
div
box-shadow \
0 0 0 black \
1 0 0 black \
0 0 1 black
color: white
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
div
box-shadow \
0 0 0 black \
1 0 0 black \
0 0 1 black
color: white
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[
{
"line": 2,
"column": 5,
"endLine": 5,
"endColumn": 16,
"rule": "stylus/indentation",
"severity": "error",
"text": "Expected indentation of 2 spaces (stylus/indentation)"
},
{
"line": 6,
"column": 5,
"endLine": 6,
"endColumn": 17,
"rule": "stylus/indentation",
"severity": "error",
"text": "Expected indentation of 2 spaces (stylus/indentation)"
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
div
box-shadow 0 0 0 black \
1 0 0 black \
0 0 1 black
color: white
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
div
box-shadow 0 0 0 black \
1 0 0 black \
0 0 1 black
color: white
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[
{
"line": 2,
"column": 5,
"endLine": 4,
"endColumn": 16,
"rule": "stylus/indentation",
"severity": "error",
"text": "Expected indentation of 2 spaces (stylus/indentation)"
},
{
"line": 5,
"column": 5,
"endLine": 5,
"endColumn": 17,
"rule": "stylus/indentation",
"severity": "error",
"text": "Expected indentation of 2 spaces (stylus/indentation)"
}
]
16 changes: 16 additions & 0 deletions tests/fixtures/lib/rules/indentation/2/multiline-value3/input.styl
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
div
box-shadow 0 0 0 black \
1 0 0 black \
0 0 1 black

div
box-shadow \
0 0 0 black \
1 0 0 black \
0 0 1 black

div
box-shadow \
0 0 0 black \
1 0 0 black \
0 0 1 black
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
div
box-shadow 0 0 0 black \
1 0 0 black \
0 0 1 black

div
box-shadow \
0 0 0 black \
1 0 0 black \
0 0 1 black

div
box-shadow \
0 0 0 black \
1 0 0 black \
0 0 1 black
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
[
{
"line": 3,
"column": 14,
"endLine": 3,
"endColumn": 15,
"rule": "stylus/indentation",
"severity": "error",
"text": "Expected indentation of 4 spaces (stylus/indentation)"
},
{
"line": 4,
"column": 14,
"endLine": 4,
"endColumn": 15,
"rule": "stylus/indentation",
"severity": "error",
"text": "Expected indentation of 4 spaces (stylus/indentation)"
},
{
"line": 8,
"column": 3,
"endLine": 8,
"endColumn": 4,
"rule": "stylus/indentation",
"severity": "error",
"text": "Expected indentation of 4 spaces (stylus/indentation)"
},
{
"line": 9,
"column": 3,
"endLine": 9,
"endColumn": 4,
"rule": "stylus/indentation",
"severity": "error",
"text": "Expected indentation of 4 spaces (stylus/indentation)"
},
{
"line": 10,
"column": 3,
"endLine": 10,
"endColumn": 4,
"rule": "stylus/indentation",
"severity": "error",
"text": "Expected indentation of 4 spaces (stylus/indentation)"
}
]
4 changes: 4 additions & 0 deletions tests/fixtures/lib/rules/indentation/2/test1/input.styl
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.someClass
margin-top 5px // comment
#someId
padding 0
4 changes: 4 additions & 0 deletions tests/fixtures/lib/rules/indentation/2/test1/output.styl
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.someClass
margin-top 5px // comment
#someId
padding 0
20 changes: 20 additions & 0 deletions tests/fixtures/lib/rules/indentation/2/test1/warnings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[
{
"line": 2,
"column": 5,
"endLine": 2,
"endColumn": 30,
"rule": "stylus/indentation",
"severity": "error",
"text": "Expected indentation of 2 spaces (stylus/indentation)"
},
{
"line": 4,
"column": 5,
"endLine": 4,
"endColumn": 14,
"rule": "stylus/indentation",
"severity": "error",
"text": "Expected indentation of 2 spaces (stylus/indentation)"
}
]

0 comments on commit 5d48578

Please sign in to comment.