diff --git a/lib/rules/indentation.js b/lib/rules/indentation.js index 298c9b6..5b29b01 100644 --- a/lib/rules/indentation.js +++ b/lib/rules/indentation.js @@ -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 { diff --git a/package.json b/package.json index fad88eb..9ac628d 100644 --- a/package.json +++ b/package.json @@ -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" diff --git a/tests/fixtures/lib/rules/indentation/2/multiline-value1/input.styl b/tests/fixtures/lib/rules/indentation/2/multiline-value1/input.styl new file mode 100644 index 0000000..71bc0c3 --- /dev/null +++ b/tests/fixtures/lib/rules/indentation/2/multiline-value1/input.styl @@ -0,0 +1,6 @@ +div + box-shadow \ + 0 0 0 black \ + 1 0 0 black \ + 0 0 1 black + color: white diff --git a/tests/fixtures/lib/rules/indentation/2/multiline-value1/output.styl b/tests/fixtures/lib/rules/indentation/2/multiline-value1/output.styl new file mode 100644 index 0000000..c937785 --- /dev/null +++ b/tests/fixtures/lib/rules/indentation/2/multiline-value1/output.styl @@ -0,0 +1,6 @@ +div + box-shadow \ + 0 0 0 black \ + 1 0 0 black \ + 0 0 1 black + color: white diff --git a/tests/fixtures/lib/rules/indentation/2/multiline-value1/warnings.json b/tests/fixtures/lib/rules/indentation/2/multiline-value1/warnings.json new file mode 100644 index 0000000..a38bfc0 --- /dev/null +++ b/tests/fixtures/lib/rules/indentation/2/multiline-value1/warnings.json @@ -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)" + } +] \ No newline at end of file diff --git a/tests/fixtures/lib/rules/indentation/2/multiline-value2/input.styl b/tests/fixtures/lib/rules/indentation/2/multiline-value2/input.styl new file mode 100644 index 0000000..734b99f --- /dev/null +++ b/tests/fixtures/lib/rules/indentation/2/multiline-value2/input.styl @@ -0,0 +1,5 @@ +div + box-shadow 0 0 0 black \ + 1 0 0 black \ + 0 0 1 black + color: white diff --git a/tests/fixtures/lib/rules/indentation/2/multiline-value2/output.styl b/tests/fixtures/lib/rules/indentation/2/multiline-value2/output.styl new file mode 100644 index 0000000..3d0d2ef --- /dev/null +++ b/tests/fixtures/lib/rules/indentation/2/multiline-value2/output.styl @@ -0,0 +1,5 @@ +div + box-shadow 0 0 0 black \ + 1 0 0 black \ + 0 0 1 black + color: white diff --git a/tests/fixtures/lib/rules/indentation/2/multiline-value2/warnings.json b/tests/fixtures/lib/rules/indentation/2/multiline-value2/warnings.json new file mode 100644 index 0000000..b2c6ce0 --- /dev/null +++ b/tests/fixtures/lib/rules/indentation/2/multiline-value2/warnings.json @@ -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)" + } +] \ No newline at end of file diff --git a/tests/fixtures/lib/rules/indentation/2/multiline-value3/input.styl b/tests/fixtures/lib/rules/indentation/2/multiline-value3/input.styl new file mode 100644 index 0000000..c3821e2 --- /dev/null +++ b/tests/fixtures/lib/rules/indentation/2/multiline-value3/input.styl @@ -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 diff --git a/tests/fixtures/lib/rules/indentation/2/multiline-value3/output.styl b/tests/fixtures/lib/rules/indentation/2/multiline-value3/output.styl new file mode 100644 index 0000000..b5ab0c3 --- /dev/null +++ b/tests/fixtures/lib/rules/indentation/2/multiline-value3/output.styl @@ -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 diff --git a/tests/fixtures/lib/rules/indentation/2/multiline-value3/warnings.json b/tests/fixtures/lib/rules/indentation/2/multiline-value3/warnings.json new file mode 100644 index 0000000..45f9d96 --- /dev/null +++ b/tests/fixtures/lib/rules/indentation/2/multiline-value3/warnings.json @@ -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)" + } +] \ No newline at end of file diff --git a/tests/fixtures/lib/rules/indentation/2/test1/input.styl b/tests/fixtures/lib/rules/indentation/2/test1/input.styl new file mode 100644 index 0000000..1c3dc37 --- /dev/null +++ b/tests/fixtures/lib/rules/indentation/2/test1/input.styl @@ -0,0 +1,4 @@ +.someClass + margin-top 5px // comment +#someId + padding 0 diff --git a/tests/fixtures/lib/rules/indentation/2/test1/output.styl b/tests/fixtures/lib/rules/indentation/2/test1/output.styl new file mode 100644 index 0000000..cae09fc --- /dev/null +++ b/tests/fixtures/lib/rules/indentation/2/test1/output.styl @@ -0,0 +1,4 @@ +.someClass + margin-top 5px // comment +#someId + padding 0 diff --git a/tests/fixtures/lib/rules/indentation/2/test1/warnings.json b/tests/fixtures/lib/rules/indentation/2/test1/warnings.json new file mode 100644 index 0000000..14d635a --- /dev/null +++ b/tests/fixtures/lib/rules/indentation/2/test1/warnings.json @@ -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)" + } +] \ No newline at end of file