Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto format will remove all codes in current file #107

Open
molinla opened this issue Dec 4, 2024 · 8 comments
Open

Auto format will remove all codes in current file #107

molinla opened this issue Dec 4, 2024 · 8 comments

Comments

@molinla
Copy link

molinla commented Dec 4, 2024

Overview
When checked Run format on save or Run save fixed save options, it will remove my current file whole code. i test on .tsx, .ts, .css. Their code will also be removed.

Env Info

Tag Version
System Windows 11 23H2
IDE Webstorm 2024.3
BiomePlugin 1.5.2
pnpm 9.12.1

Bug Reproduction GIF Preview

this gif wants to show when I type useless whitespace hope biome can remove useless whitespace, but it not remove useless whitespace it directly removes whole codes.

PixPin_2024-12-04_14-12-24

Biome Config

{
  "$schema": "./node_modules/@biomejs/biome/configuration_schema.json",
  "vcs": {
    "enabled": false,
    "clientKind": "git",
    "useIgnoreFile": false
  },
  "files": {
    "ignore": ["node_modules", "dist"]
  },
  "formatter": {
    "enabled": true,
    "indentStyle": "space"
  },
  "organizeImports": {
    "enabled": true
  },
  "linter": {
    "enabled": true,
    "rules": {
      "recommended": true,
      "a11y": {
        "noSvgWithoutTitle": "warn",
        "useKeyWithClickEvents": "off",
        "useKeyWithMouseEvents": "off"
      },
      "correctness": {
        "useExhaustiveDependencies": "warn"
      },
      "style": {
        "useNodejsImportProtocol": "off",
        "noNonNullAssertion": "warn",
        "noParameterAssign": "warn"
      },
      "complexity": {
        "noForEach": "off"
      },
      "suspicious": {
        "noExplicitAny": "warn",
        "noAssignInExpressions": "off",
        "noConsole": {
          "level": "warn",
          "fix": "none"
        }
      },
      "performance": {
        "noAccumulatingSpread": "warn"
      }
    }
  },
  "javascript": {
    "formatter": {
      "quoteStyle": "single"
    },
    "parser": {
      "unsafeParameterDecoratorsEnabled": true
    }
  },
  /*
    TODO: remove it when biome support monorepo or plugin
    1. biome don't support monorepo: https://github.com/biomejs/biome/issues/2228
    2. must be disable useImportType in backend, cause biome don't support emitDecoratorMetadata,
        biome team also does not intend to support it, ts eslint also rejected in last version
        https://github.com/biomejs/biome/issues/2003#issuecomment-2028665621
    3. biome roadmap: https://github.com/biomejs/biome/issues/2455
  */
  "overrides": [
    {
      "include": [
        "apps/comment-service.app/**",
        "apps/crdt.app/**",
        "apps/copilot.app/**",
        "apps/user-login.app/**",
        "apps/oss-service.app/**",
        "apps/platform.app/**",
        "packages/platform/db/**",
        "packages/platform/ai-chat/**"
      ],
      "linter": {
        "rules": {
          "style": {
            "useImportType": "off"
          }
        }
      }
    }
  ]
}

Related Info

I also tested on macbook air m1, with same webstorm version and same project. It works well.

@molinla
Copy link
Author

molinla commented Dec 4, 2024

Resolved

I try to set biome.exe manually, it works. I guess it is because my repo is pnpm monorepo. When I try to install it in workspace root its folder not include any executable files

image

but it does include in .pnpm/@[email protected] folders

image

Correctly Config

image

@molinla
Copy link
Author

molinla commented Dec 4, 2024

vscode works fine on this project, because its biome extension will use itself biome.exe not in this project installed @biomejs/biome

Here is vscode biome extension file path:

image

@denbezrukov
Copy link
Contributor

@molinla
Could you try please to use the night build?
https://plugins.jetbrains.com/plugin/22761-biome/versions/nightly

@molinla
Copy link
Author

molinla commented Dec 10, 2024

pretty sad, after installed nightly plugin, its not working in auto config mode it will still remove all my current file codes. and manuly set biome.exe now not working too.
preview:

ezgif-5-5653c5fe56.mp4

here is my monorepo project struct:

root
├── README.md
├── apps
│ ├── crdt.app
│ ├── oss-service.app
│ ├── platform.app
│ ├── uidl-crdt.app
│ ├── user-login.app
│ └── workspace.app
├── biome.jsonc
├── node_modules
│ ├── @antfu
│ ├── @biomejs
│ ├── @eslint
│ ├── @eslint-community
│ ├── @eslint-react
│ ├── @Stylistic
│ ├── @types
│ ├── @typescript-eslint
│ ├── @vitest
│ ├── eslint
│ ├── eslint-config-prettier
│ ├── eslint-plugin-prettier
│ ├── eslint-scope
│ ├── eslint-visitor-keys
│ ├── husky
│ ├── prettier
│ └── prettier-linter-helpers
├── package.json
├── packages
│ ├── base
│ ├── core
│ ├── platform
│ └── standard
├── pnpm-lock.yaml
├── pnpm-workspace.yaml
└── tools
├── figma-import
└── lint

i'm wondering pnpm install only install some js files, the realy exe files are still in node_modules/.pnpm/@[email protected]/node_modules/@biomejs/cli-win32-x64

in node_modules/@biomejs/biome has nothing.

image
image

@denbezrukov
Copy link
Contributor

@molinla
Could you create and share a minimal reproducible repo example?
It'll be very useful🙏

@molinla
Copy link
Author

molinla commented Dec 10, 2024

@molinla Could you create and share a minimal reproducible repo example? It'll be very useful🙏

here is minimal reproducible repo example: https://github.com/molinla/biome-format-testing

thansk for you help

@denbezrukov
Copy link
Contributor

@molinla
Thank you!

I'll try to investigate further. I need to find a computer with Windows. Do I understand correctly that it always occurs, regardless of what you do? I mean, even if you only turn on formatting or only fixing, it still happens?

@molinla
Copy link
Author

molinla commented Dec 11, 2024

yes, for now when my computer is windows, it always remove all my file codes when i turnning auto detect biome config, and turn on auto fix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants