sveltejs / prettier-plugin-svelte

Format your svelte components using prettier.
MIT License
735 stars 95 forks source link

SCSS comments defined using // are considered as lint error #390

Closed nielk closed 1 year ago

nielk commented 1 year ago

Since the v3.0.0 I got error on comment in my scss:

not ok:

<div>foo</div>

<style lang="scss">
    $color: red;

    div {
        color: $color; // comment
    }
</style>

ok

<div>foo</div>

<style lang="scss">
    $color: red;

    div {
        color: $color; /* comment */
    }
</style>

It seems incorrect because scss support both /* */ and // syntax.

❯ yarn test
yarn run v1.22.19
$ ava

SyntaxError: CssSyntaxError: Unknown word (5:24)
  3 |
  4 |     div {
> 5 |         color: $color; // colors
    |                        ^
  6 |     }
  7 |
    at Jp (file:///Users/xxx/repo/prettier/node_modules/prettier/plugins/postcss.mjs:52:8888)
    at Ts (file:///Users/xxx/repo/prettier/node_modules/prettier/plugins/postcss.mjs:52:16052)
    at Object.Bl [as parse] (file:///Users/xxx/repo/prettier/node_modules/prettier/plugins/postcss.mjs:52:16259)
    at parse (file:///Users/xxx/repo/prettier/node_modules/prettier/index.mjs:17080:24)
    at async textToDoc (file:///Users/xxx/repo/prettier/node_modules/prettier/index.mjs:18032:19) {
  loc: { start: { line: 5, column: 24 } },
  cause: t [CssSyntaxError]: <css input>:5:24: Unknown word
      at Ie.error (file:///Users/xxx/repo/prettier/node_modules/prettier/plugins/postcss.mjs:23:801)
      at Cn.unknownWord (file:///Users/xxx/repo/prettier/node_modules/prettier/plugins/postcss.mjs:22:6886)
      at Cn.other (file:///Users/xxx/repo/prettier/node_modules/prettier/plugins/postcss.mjs:22:2297)
      at Cn.parse (file:///Users/xxx/repo/prettier/node_modules/prettier/plugins/postcss.mjs:22:1243)
      at ir (file:///Users/xxx/repo/prettier/node_modules/prettier/plugins/postcss.mjs:23:2131)
      at Ts (file:///Users/xxx/repo/prettier/node_modules/prettier/plugins/postcss.mjs:52:15963)
      at Object.Bl [as parse] (file:///Users/xxx/repo/prettier/node_modules/prettier/plugins/postcss.mjs:52:16259)
      at parse (file:///Users/xxx/repo/prettier/node_modules/prettier/index.mjs:17080:24)
      at async textToDoc (file:///Users/xxx/repo/prettier/node_modules/prettier/index.mjs:18032:19) {
    reason: 'Unknown word',
    source: '\n    $color: red;\n\n    div {\n        color: $color; // colors\n    }\n',
    line: 5,
    column: 24,
    endLine: 5,
    endColumn: 26,
    input: {
      line: 5,
      column: 24,
      endLine: 5,
      endColumn: 26,
      source: '\n    $color: red;\n\n    div {\n        color: $color; // colors\n    }\n'
    }
  },
  codeFrame: '  3 |\n' +
    '  4 |     div {\n' +
    '> 5 |         color: $color; // colors\n' +
    '    |                        ^\n' +
    '  6 |     }\n' +
    '  7 |'
}
Tuditi commented 1 year ago

Is there any update on this? It would be great to have this fixed :pray: