Giter Site home page Giter Site logo

Comments (5)

wojtekmaj avatar wojtekmaj commented on May 24, 2024 1

It looks like a good temporary workaround is

  "overrides": [
    {
      "include": ["**/package.json"],
      "formatter": {
        "lineWidth": 1
      }
    }
  ]

thanks for pointing me in the right direction!

from biome.

ematipico avatar ematipico commented on May 24, 2024

@wojtekmaj Unfortunately, the playground isn't sufficient for reproduction. Can you please give us more information about the issue and how can we reproduce it, maybe with a repository?

from biome.

wojtekmaj avatar wojtekmaj commented on May 24, 2024

Sorry, there was no place for that in the template, I'm working on an actual issue description.

from biome.

wojtekmaj avatar wojtekmaj commented on May 24, 2024

Sorry, the issue I'm seeing has a different cause than I initially presumed. I thought I'm seeing the opposite errors on macOS and Linux, but that's not the case. Here's full explanation.

I migrated from Prettier to Biome for formatting. Immediately, I was met with the following error:

./package.json format โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

  โœ– Formatter would have printed the following content:
  
     4  4 โ”‚       "access": "public"
     5  5 โ”‚     },
     6    โ”‚ - ยทยท"files":ยท[
     7    โ”‚ - ยทยทยทยท"dist",
     8    โ”‚ - ยทยทยทยท"src"
     9    โ”‚ - ยทยท],
        6 โ”‚ + ยทยท"files":ยท["dist",ยท"src"],
    10  7 โ”‚     "repository": {
    11  8 โ”‚       "type": "git",
  

Checked 32 files in 11ms. No fixes needed.
Found 1 error.
format โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

  โœ– Some errors were emitted while running checks.

Of course, running biome format . --write fixed the issue.

However, other tools in my toolchain attempt to format JSON in a Prettier-compatible way. Notably, running Yarn (4.1.1), reformats the package.json back so that files is split into multiple lines.

Since CI is basically yarn install + biome format, this causes the latter to fail.

I would still consider it a formatting bug in Biome. Here's why I believe so:

  • Quoting documentation, "The formatting style of Biome is also considered relatively stable, continuing to match Prettier as much as possible". This is a difference between the two, and one not listed on Differences with Prettier page.
  • These particular arrays found in package.json (workspaces, files) are FAR more readable when split into multiple lines.
  • While technically correct, this discrepancy causes incompatibilities with other tools as described above.

from biome.

ematipico avatar ematipico commented on May 24, 2024

That's expected. Prettier formats package.json files using JSON.stringify(content, null, 2), which package managers usually do.

Biome, instead, uses the classic heuristic, that's why you see all these changes. I am considering creating an option for making the formatting similar to Prettie, however it will take a bit to create it.

For the time being, you can use overrides to ignore package.json files from being formatted with Biome.

from biome.

Related Issues (20)

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.