D
D
Drovosek012019-09-26 11:44:57
Visual Studio Code
Drovosek01, 2019-09-26 11:44:57

How to disable array folding to string when saving json file?

I'm setting up code formatting in an Angular 7 project.
At the root of the project in the .prettierrc file, I wrote the following settings:

{
  "singleQuote": true,
  "printWidth": 140,
  "tabWidth": 2,
  "useTabs": false,
  "semi": true,
  "bracketSpacing": true,
  "arrowParens": "avoid",
  "requirePragma": false,
  "insertPragma": false,
  "proseWrap": "preserve",
  "htmlWhitespaceSensitivity": "ignore",
  "endOfLine": "lf"
}

+ Prettier extension in VSCode installed.
I started looking through the files and noticed that prettier has no effect on JSON files. I googled that you need to add the line to the VSCode settings
"[jsonc]": {
        "editor.defaultFormatter": "esbenp.prettier-vscode"
    },

Here are all my settings:
{
    "emmet.triggerExpansionOnTab": true,
    "terminal.integrated.shell.windows": "C:\\Program Files\\Git\\bin\\bash.exe",
    "window.zoomLevel": 0,
    "editor.suggestSelection": "first",
    "vsintellicode.modify.editor.suggestSelection": "automaticallyOverrodeDefaultValue",
    "python.jediEnabled": false,
    "editor.formatOnSave": true,
    "html.format.wrapLineLength": 120,
    "editor.codeActionsOnSave": {
        "source.organizeImports": true,
    },
    "beautify.config": {
        "indent_size": 2,
        "html": {
            "wrap_attributes": "force"
        }
    },
    "beautify.language": {
        "css": []
    },
    "[typescript]": {
        "editor.defaultFormatter": "esbenp.prettier-vscode"
    },
    "[html]": {
        "editor.defaultFormatter": "HookyQR.beautify"
    },
    "prettier.singleQuote": true,
    "prettier.printWidth": 120,
    "prettier.tabWidth": 2,
    "[jsonc]": {
        "editor.defaultFormatter": "esbenp.prettier-vscode"
    },
}

Now if I save such JSON file
{
  "extends": "./tsconfig.json",
  "compilerOptions": {
    "outDir": "../../dist/out-tsc/apps/appeals",
    "types": []
  },
  "include": [
    "**/*.ts"
  ],
  "exclude": [
    "src/test-setup.ts",
    "**/*.spec.ts",
    "**/*.stories.ts"
  ]
}

Then it will be converted to this:
{
  "extends": "./tsconfig.json",
  "compilerOptions": {
    "outDir": "../../dist/out-tsc/apps/appeals",
    "types": []
  },
  "include": ["**/*.ts"],
  "exclude": ["src/test-setup.ts", "**/*.spec.ts", "**/*.stories.ts"]
}

I don't want the arrays to be folded into one line, but the code is formatted by Prettier'om (so that the indents are aligned according to the rule, etc.), how can I do this?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question