sveltejs / prettier-plugin-svelte

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

Broken Tests #419

Closed curran closed 5 months ago

curran commented 5 months ago

I noticed that in the current master, the npm test command fails with the following error:

$ npm test

> prettier-plugin-svelte@3.1.2 test
> ava

SyntaxError: Unexpected token (3:21)
  1 |
  2 |         {
> 3 |           "@context": "https://schema.org",
    |                     ^
  4 |           "@type": "etc..."
  5 |         }
  6 |     
    at Ka (file:///home/curran/repos/prettier-plugin-svelte-browser/node_modules/prettier/plugins/babel.mjs:15:1323)
    at qa (file:///home/curran/repos/prettier-plugin-svelte-browser/node_modules/prettier/plugins/babel.mjs:15:1472)
    at Object.parse (file:///home/curran/repos/prettier-plugin-svelte-browser/node_modules/prettier/plugins/babel.mjs:16:17099)
    at parse (file:///home/curran/repos/prettier-plugin-svelte-browser/node_modules/prettier/index.mjs:17080:24)
    at async textToDoc (file:///home/curran/repos/prettier-plugin-svelte-browser/node_modules/prettier/index.mjs:18032:19) {
  loc: { start: { line: 3, column: 21 } },
  cause: SyntaxError: Unexpected token (3:20)
      at Hi (file:///home/curran/repos/prettier-plugin-svelte-browser/node_modules/prettier/plugins/babel.mjs:1:1666)
      at s (file:///home/curran/repos/prettier-plugin-svelte-browser/node_modules/prettier/plugins/babel.mjs:3:11189)
      at tt.raise (file:///home/curran/repos/prettier-plugin-svelte-browser/node_modules/prettier/plugins/babel.mjs:5:19557)
      at tt.unexpected (file:///home/curran/repos/prettier-plugin-svelte-browser/node_modules/prettier/plugins/babel.mjs:5:19959)
      at tt.parseExprAtom (file:///home/curran/repos/prettier-plugin-svelte-browser/node_modules/prettier/plugins/babel.mjs:7:94078)
      at tt.parseExprAtom (file:///home/curran/repos/prettier-plugin-svelte-browser/node_modules/prettier/plugins/babel.mjs:7:5406)
      at tt.parseExprSubscripts (file:///home/curran/repos/prettier-plugin-svelte-browser/node_modules/prettier/plugins/babel.mjs:7:86651)
      at tt.parseUpdate (file:///home/curran/repos/prettier-plugin-svelte-browser/node_modules/prettier/plugins/babel.mjs:7:86279)
      at tt.parseMaybeUnary (file:///home/curran/repos/prettier-plugin-svelte-browser/node_modules/prettier/plugins/babel.mjs:7:85908)
      at tt.parseMaybeUnary (file:///home/curran/repos/prettier-plugin-svelte-browser/node_modules/prettier/plugins/babel.mjs:7:63844) {
    code: 'BABEL_PARSER_SYNTAX_ERROR',
    reasonCode: 'UnexpectedToken',
    loc: B { line: 3, column: 20, index: 31 },
    pos: [Getter/Setter]
  },
  codeFrame: '  1 |\n' +
    '  2 |         {\n' +
    '> 3 |           "@context": "https://schema.org",\n' +
    '    |                     ^\n' +
    '  4 |           "@type": "etc..."\n' +
    '  5 |         }\n' +
    '  6 |     '
}
  285 tests passed
dummdidumm commented 5 months ago

The test isn't broken, it's just emitting the inner error but proceeds with the outer format. This is all working as expected. That said, we can certainly silence it by supporting JSON in script tags.