Giter Club home page Giter Club logo

Comments (5)

dsherret avatar dsherret commented on May 26, 2024 2

Similar to #10. Maybe this could be a setting where you can specify the files you want trailing commas in or there could be a list of defaults.

from dprint-plugin-json.

Zamiell avatar Zamiell commented on May 26, 2024 1

Hi there. I'm investigating moving my monorepo from prettier to dprint, and this issue is one of the pain points for me. An option for this would be great!

I would even go so as far to say that files like "tsconfig.json" and "./.vscode/settings.json" should be parsed as JSONC by default without the end-user having to specify anything in their config. (Because this is what VSCode reports in the bottom-right-hand-corner as what the file actually is.)

from dprint-plugin-json.

davidbludlow avatar davidbludlow commented on May 26, 2024

Yes!

I propose that we either enforce trailing commas in these types of files or that we make a new setting to allow this. I imagine it looking something like

"filesWithTrailingCommas": [
  "**/.vscode/extensions.json",
  "**/.vscode/launch.json",
  "**/.vscode/settings.json",
  "**/.vscode/tasks.json",
  "**/tsconfig*.json",
  "**/jsconfig*.json"
]

and it could default to that value that I said right there

You may have a better idea of what to call the setting or how to structure it. I am just saying an idea.

from dprint-plugin-json.

davidbludlow avatar davidbludlow commented on May 26, 2024

In a perfect world, Microsoft would have decided to name those files .jsonc instead of .json, but I don't think that is going to happen :)

from dprint-plugin-json.

davidbludlow avatar davidbludlow commented on May 26, 2024
You may skip reading this. It isn't that important. Click to expand this section:

This was also a problem, back when I used prettier, until I found this hacky workarround. I tried to do that same hacky workaround with dprint but it didn't work because dprint/dprint-plugin-prettier#39 is still broken. The hack I tried was to have dprint.json say

{
  "json": {
    "associations": [
      "**/*.json",
      "!**/.vscode/extensions.json",
      "!**/.vscode/launch.json",
      "!**/.vscode/settings.json",
      "!**/tsconfig*.json",
      "!**/jsconfig.json"
    ]
  },
  "prettier": {
    "overrides": [
      {
        "files": [
          "**/.vscode/extensions.json",
          "**/.vscode/launch.json",
          "**/.vscode/settings.json",
          "**/tsconfig*.json",
          "**/jsconfig*.json"
        ],
        "options": {
          "parser": "json5",
          "quoteProps": "preserve",
          "singleQuote": false,
          "trailingComma": "all"
        }
      }
    ]
  },
  "includes": [
    "**/*.{ts,tsx,js,jsx,cjs,mjs,json,yaml,md,mdx,toml,vue,html,css,scss,sass,less,hbs,graphql,gql}"
  ],
  "excludes": [
    "**/node_modules",
    "**/*-lock.json"
  ],
  "plugins": [
    "https://plugins.dprint.dev/typescript-0.84.0.wasm",
    "https://plugins.dprint.dev/json-0.17.1.wasm",
    "https://plugins.dprint.dev/markdown-0.15.2.wasm",
    "https://plugins.dprint.dev/toml-0.5.4.wasm",
    "https://plugins.dprint.dev/prettier-0.24.0.json@9a57d0d8e440ad90d07a503166af47e7a6a886abd46767933f9c279f72468596"
  ]
}

But that hack is ugly! I would much prefer we do something different. And, like I said, it doesn't work anyway.

from dprint-plugin-json.

Related Issues (17)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.