MeWrite Docs

Biome: Parse error - Expected expression

BiomeでJavaScript/TypeScriptのパースに失敗した場合のエラー

概要

Biome(旧Rome)でJavaScript/TypeScriptファイルのパースに失敗した場合に発生するエラーです。構文エラーや設定の問題が原因です。

エラーメッセージ

biome  parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

  × Expected an expression but instead found ';'.

    1 │ const x = ;
      │           ^
biome  parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

  × Expected a semicolon or an implicit semicolon after a statement, but found none

解決策

1. 基本設定ファイルの作成

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
// biome.json
{
  "$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
  "organizeImports": {
    "enabled": true
  },
  "linter": {
    "enabled": true,
    "rules": {
      "recommended": true
    }
  },
  "formatter": {
    "enabled": true,
    "indentStyle": "space",
    "indentWidth": 2
  }
}

2. JavaScript/TypeScriptの設定

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
// biome.json
{
  "javascript": {
    "parser": {
      "unsafeParameterDecoratorsEnabled": true
    },
    "formatter": {
      "quoteStyle": "single",
      "semicolons": "always"
    }
  }
}

3. ファイルを除外

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
// biome.json
{
  "files": {
    "ignore": [
      "node_modules",
      "dist",
      ".next",
      "*.min.js",
      "generated/**"
    ]
  }
}

4. JSXの設定

1
2
3
4
5
6
7
// biome.json
{
  "javascript": {
    "jsxRuntime": "reactClassic"
    // または "transparent" (自動検出)
  }
}

5. 特定のルールを無効化

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
// biome.json
{
  "linter": {
    "rules": {
      "recommended": true,
      "style": {
        "noNonNullAssertion": "off"
      },
      "suspicious": {
        "noExplicitAny": "warn"
      }
    }
  }
}

6. インラインで無効化

1
2
3
4
5
6
7
8
9
// biome-ignore lint/suspicious/noExplicitAny: 動的な型が必要
const data: any = fetchData()

// biome-ignore format: 特殊なフォーマットを維持
const matrix = [
  [1, 0, 0],
  [0, 1, 0],
  [0, 0, 1],
]

7. コマンドラインオプション

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
# フォーマット
npx biome format --write .

# リント
npx biome lint .

# 両方実行
npx biome check --write .

# 特定のファイルのみ
npx biome check src/

8. VS Code統合

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
// .vscode/settings.json
{
  "editor.defaultFormatter": "biomejs.biome",
  "editor.formatOnSave": true,
  "[javascript]": {
    "editor.defaultFormatter": "biomejs.biome"
  },
  "[typescript]": {
    "editor.defaultFormatter": "biomejs.biome"
  },
  "[typescriptreact]": {
    "editor.defaultFormatter": "biomejs.biome"
  }
}

9. ESLint/Prettierからの移行

1
2
3
4
5
# ESLintルールをBiomeに移行
npx @biomejs/biome migrate eslint --write

# Prettierルールを移行
npx @biomejs/biome migrate prettier --write

関連エラー

関連エラー

最終更新: 2025-12-19