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

🐛 npx @biomejs/biome migrate command crashes #3179

Closed
1 task done
sparrowsl opened this issue Jun 11, 2024 · 5 comments · Fixed by #3207 · 4 remaining pull requests
Closed
1 task done

🐛 npx @biomejs/biome migrate command crashes #3179

sparrowsl opened this issue Jun 11, 2024 · 5 comments · Fixed by #3207 · 4 remaining pull requests
Assignees
Labels
A-Analyzer Area: analyzer A-CLI Area: CLI S-Bug-confirmed Status: report has been confirmed as a valid bug

Comments

@sparrowsl
Copy link

Environment information

CLI:
  Version:                      1.8.1
  Color support:                true

Platform:
  CPU Architecture:             x86_64
  OS:                           linux

Environment:
  BIOME_LOG_DIR:                unset
  NO_COLOR:                     unset
  TERM:                         "xterm-256color"
  JS_RUNTIME_VERSION:           "v20.14.0"
  JS_RUNTIME_NAME:              "node"
  NODE_PACKAGE_MANAGER:         "npm/10.7.0"

Biome Configuration:
  Status:                       Loaded successfully
  Formatter disabled:           false
  Linter disabled:              false
  Organize imports disabled:    false
  VCS disabled:                 true

Workspace:
  Open Documents:               0

What happened?

npx @biomejs/biome migrate

Biome encountered an unexpected error                                                                                                                                  
This is a bug in Biome, not an error in your code, and we would appreciate it if you could report it to https://github.com/biomejs/biome/issues/ along with the following information to help us fixing the issue:
                                                                         
Source Location: /home/runner/work/biome/biome/crates/biome_rowan/src/ast/mod.rs:686:41 
Thread Name: main                                             
Message: Malformed list, node expected but found token [email protected] "," [] [] instead. You must add missing markers for missing elements.

Expected result

It should update the biome.json file or something positive on what next to do, but not an error or bug report like this.

Code of Conduct

  • I agree to follow Biome's Code of Conduct
@ematipico
Copy link
Member

ematipico commented Jun 11, 2024

Is it possible that you have a leading comma in biome.json and that you enabled it in the configuration file? e.g.

{
	"json": { "parser": { "allowTrailingCommas": true } }
}

@sparrowsl
Copy link
Author

I have it in the javascript.formatter property section, and it is "trailingCommas": "es5"

@ematipico
Copy link
Member

ematipico commented Jun 12, 2024

Could you share your biome.json file? Or a reproduction. Without more information we can't understand where the issue comes from

@ematipico ematipico added S-Needs response Status: await response from OP S-Needs repro Status: needs a reproduction labels Jun 12, 2024
@sparrowsl
Copy link
Author

{
  "$schema": "https://biomejs.dev/schemas/1.8.1/schema.json",
  "formatter": {
    "enabled": true,
    "formatWithErrors": false,
    "indentStyle": "space",
    "lineEnding": "lf",
    "lineWidth": 100,
    "ignore": [
      "node_modules",
      ".svelte-kit",
      ".husky",
      "**/.DS_Store",
      "**/node_modules",
      "./build",
      "./.svelte-kit",
      "./package",
      "**/.env",
      "**/.env.*",
      "**/*.db",
      "**/pnpm-lock.yaml",
      "**/package-lock.json",
      "**/yarn.lock"
    ]
  },
  "organizeImports": { "enabled": true },
  "linter": {
    "rules": {
      "recommended": true,
      "a11y": { "recommended": true },
      "complexity": {
        "recommended": true,
        "noUselessTernary": "error",
        "noVoid": "warn",
        "useSimplifiedLogicExpression": "warn"
      },
      "correctness": {
        "recommended": true,
        "noNewSymbol": "warn",
        "noUndeclaredVariables": "warn",
        "noUnusedImports": "warn",
        "noUnusedVariables": "warn",
        "useHookAtTopLevel": "error"
      },
      "nursery": {
        "recommended": true,
        "noDuplicateElseIf": "warn",
        "noDuplicateJsonKeys": "error",
        "useImportRestrictions": "warn",
        "useSortedClasses": {
          "level": "warn",
          "options": { "attributes": ["class"] }
        }
      },
      "performance": { "recommended": true },
      "security": { "recommended": true },
      "style": {
        "recommended": true,
        "noImplicitBoolean": "error",
        "noNegationElse": "warn",
        "noShoutyConstants": "error",
        "useBlockStatements": "error",
        "useCollapsedElseIf": "warn",
        "useForOf": "warn",
        "useFragmentSyntax": "warn",
        "useShorthandAssign": "warn",
        "useSingleCaseStatement": "error"
      },
      "suspicious": {
        "recommended": true,
        "noApproximativeNumericConstant": "error",
        "noConsoleLog": "warn",
        "noEmptyBlockStatements": "warn",
        "noMisrefactoredShorthandAssign": "error",
        "useAwait": "warn"
      }
    },
    "ignore": ["node_modules", ".svelte-kit", ".husky"]
  },
  "javascript": {
    "formatter": {
      "jsxQuoteStyle": "double",
      "quoteProperties": "asNeeded",
      "trailingCommas": "es5",
      "semicolons": "asNeeded",
      "arrowParentheses": "always",
      "bracketSpacing": true,
      "bracketSameLine": false,
      "quoteStyle": "double",
      "attributePosition": "auto"
    }
  },
  "overrides": [{ "include": ["*.svelte"] }]
}

This is the biome.json and this is the repo

@Sec-ant
Copy link
Member

Sec-ant commented Jun 12, 2024

I can reproduce from your repo. I narrowed it down and found it was triggered by the promotion of the once nursery rule useImportRestrictions when it is not the last rule in the nursery group. In your example it is followed by useSortedClasses. When I put it as the last rule of that group, or delete it from the group, the migration command succeeds.

This might be caused by the left over comma when a promoted rule was deleted from that object:

{
-  "ruleA": "error",
+  ,
   "ruleB": "error"
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment