Open3

biomeでeslint-plugin-importを再現

Nakano as a ServiceNakano as a Service
{
  "$schema": "./node_modules/@biomejs/biome/configuration_schema.json",
  "extends": ["@yoshinani/style-guide/biome"],
  "files": {
    "includes": ["**", "!**/.next", "!**/.turbo"]
  },
  "assist": {
    "enabled": true,
    "actions": {
      "recommended": true,
      "source": {
        "organizeImports": {
          "level": "on",

          // eslintの設定
          // "import/order": [
          //   "warn",
          //   {
          //     groups: [
          //       "builtin",
          //       "external",
          //       "internal",
          //       "parent",
          //       "sibling",
          //       "index",
          //     ],
          //     "newlines-between": "always",
          //     alphabetize: { order: "asc" },
          //   },
          // ],

          "options": {
            "groups": [
              [":NODE:", ":BUN:", ":URL:"],
              ":BLANK_LINE:",
              [":PACKAGE:", ":PACKAGE_WITH_PROTOCOL:"],
              ":BLANK_LINE:",
              ":ALIAS:",
              ":BLANK_LINE:",
              ":PATH:"
            ]
          }
        }
      }
    }
  }
}

Nakano as a ServiceNakano as a Service

以下のようにすれば、モノレポの@repo/から始まるパッケージだけでグルーピングできる。

{
  "options": {
    "groups": [
      [":NODE:", ":BUN:", ":URL:"],
      ":BLANK_LINE:",
      [":PACKAGE:", ":PACKAGE_WITH_PROTOCOL:", "!@repo/**"],
      ":BLANK_LINE:",
      "@repo/**",
      ":BLANK_LINE:",
      ":ALIAS:",
      ":BLANK_LINE:",
      ":PATH:"
    ]
  }
}
Nakano as a ServiceNakano as a Service

biomeではインポートのソートはformatでもlintでもなく、actionというカテゴリに分類される。

以下のコマンドでformat、lint、actionすべてが実行される。

biome check