Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update parser and fix some bugs #23

Merged
merged 1 commit into from
Jan 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)"
}
]