Более красивый VSCode JSON Ошибка формата - SyntaxError: ';' ожидаемый - PullRequest
1 голос
/ 09 января 2020

Я пытаюсь отформатировать файл JSON в VSCode, используя Prettier. Однако мне не повезло с форматированием файлов JSON. Я гуглил на возможные исправления или идеи без удачи.

Я пытаюсь выяснить, как заставить Преттира отформатировать файл JSON или как отключить использование Преттира для форматирования JSON и использовать внутренний форматер VSCode.

Ниже пример файла JSON, за которым следует ошибка Prettier:

{
    "Requester": {
        "City": "USBOS",
        "PostCode": "02143"
    }
}

>["INFO" - 7:14:16 AM] Extension Name: "prettier-vscode". ["INFO" - 7:14:16 AM] Extension Version: "3.18.0". ["INFO" - 7:14:17 AM] Loaded
> module 'prettier@1.19.1' from
> 'C:\JSONTest\node_modules\prettier\index.js' ["INFO" - 7:14:17 AM]
> Loaded module 'prettier@1.19.1' from
> 'C:\JSONTest\node_modules\prettier\index.js' ["INFO" - 7:14:17 AM]
> Enabling prettier for languages [   "css",   "graphql",   "html",  
> "javascript",   "javascriptreact",   "json",   "json5",   "jsonc",  
> "less",   "markdown",   "mdx",   "mongo",   "postcss",   "scss",  
> "typescript",   "typescriptreact",   "vue",   "yaml" ] ["INFO" -
> 7:14:17 AM] Enabling prettier for range supported languages [  
> "graphql",   "javascript",   "javascriptreact",   "json",  
> "typescript",   "typescriptreact" ] ["INFO" - 7:14:22 AM] Loaded
> module 'prettier@1.19.1' from
> 'C:\JSONTest\node_modules\prettier\index.js' ["INFO" - 7:14:24 AM]
> Loaded module 'prettier@1.19.1' from
> 'C:\JSONTest\node_modules\prettier\index.js' ["INFO" - 7:14:26 AM]
> Formatting C:\JSONTest\cypress\fixtures\request-form-data.json ["INFO"
> - 7:14:26 AM] Loaded module 'prettier@1.19.1' from 'C:\JSONTest\node_modules\prettier\index.js' ["INFO" - 7:14:26 AM]
> Using ignore file (if present) at C:\JSONTest\.prettierignore ["INFO"
> - 7:14:26 AM] File Info: {   "ignored": false,   "inferredParser": "json" } ["INFO" - 7:14:26 AM] Detected local configuration (i.e.
> .prettierrc or .editorconfig), VS Code configuration will not be used
> ["INFO" - 7:14:26 AM] Prettier Options: {   "filepath":
> "d:\\TFS.Git\\Portal\\Develop\\Portal.Web\\cypress\\fixtures\\request-form-data.json",
> "parser": "typescript",   "useTabs": false,   "tabWidth": 2,  
> "printWidth": 120,   "trailingComma": "none",   "singleQuote": true,  
> "bracketSpacing": true,   "jsxBracketSameLine": false,  
> "arrowParens": "always",   "endOfLine": "auto",  
> "htmlWhitespaceSensitivity": "css",   "insertPragma": false,  
> "jsxSingleQuote": false,   "proseWrap": "preserve",   "quoteProps":
> "as-needed",   "requirePragma": false,   "semi": true } ["ERROR" -
> 7:14:26 AM] Error formatting document. ';' expected. (2:12)   1 | {
> > 2 | "Requester": {
>     |            ^   3 | "City": "USBOS",   4 | "PostCode": "02143"   5 | }, SyntaxError: ';' expected. (2:12)   1 | {
> > 2 | "Requester": {
>     |            ^   3 | "City": "USBOS",   4 | "PostCode": "02143"   5 | },
>     at t (C:\JSONTest\node_modules\prettier\parser-typescript.js:1:285)
>     at Object.parse (C:\JSONTest\node_modules\prettier\parser-typescript.js:14:180461)
>     at Object.parse (C:\JSONTest\node_modules\prettier\index.js:9739:19)
>     at coreFormat (C:\JSONTest\node_modules\prettier\index.js:13252:23)
>     at format (C:\JSONTest\node_modules\prettier\index.js:13510:73)
>     at formatWithCursor (C:\JSONTest\node_modules\prettier\index.js:13526:12)
>     at C:\JSONTest\node_modules\prettier\index.js:44207:15
>     at Object.format (C:\JSONTest\node_modules\prettier\index.js:44226:12)
>     at c:\Users\mmartins.BROKER\.vscode\extensions\esbenp.prettier-vscode-3.18.0\src\PrettierEditService.ts:382:30
>     at t.default.safeExecution (c:\Users\mmartins.BROKER\.vscode\extensions\esbenp.prettier-vscode-3.18.0\src\PrettierEditService.ts:414:27)
>     at t.default.<anonymous> (c:\Users\mmartins.BROKER\.vscode\extensions\esbenp.prettier-vscode-3.18.0\src\PrettierEditService.ts:381:17)
>     at Generator.next (<anonymous>)
>     at s (c:\Users\mmartins.BROKER\.vscode\extensions\esbenp.prettier-vscode-3.18.0\dist\extension.js:1:346242)
> ["INFO" - 7:14:26 AM] Formatting completed in 405.797699ms. ["INFO" -
> 7:25:14 AM] Loaded module 'prettier@1.19.1' from
> 'C:\JSONTest\node_modules\prettier\index.js' ["INFO" - 7:25:16 AM]
> Loaded module 'prettier@1.19.1' from
> 'C:\JSONTest\node_modules\prettier\index.js' ["INFO" - 7:27:53 AM]
> Loaded module 'prettier@1.19.1' from
> 'C:\JSONTest\node_modules\prettier\index.js' ["INFO" - 7:28:36 AM]
> Loaded module 'prettier@1.19.1' from
> 'C:\JSONTest\node_modules\prettier\index.js' ["INFO" - 7:29:00 AM]
> Loaded module 'prettier@1.19.1' from
> 'C:\JSONTest\node_modules\prettier\index.js'
...