npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

vite-plugin-biome-preset

v0.1.3

Published

Vite plugin for Biome integration with real-time formatting and linting

Downloads

16

Readme

Vite Biome 插件 vite-plugin-biome-preset

一个将 Biome 集成到 Vite 构建工具中的插件,提供实时代码格式化和代码检查功能。

🚀 特性

  • 实时格式化: 在开发模式下自动格式化保存的文件
  • 代码检查: 集成 Biome 的 linting 功能
  • 文件监听: 自动监听文件变化并执行相应操作
  • 可配置: 支持自定义 Biome 配置和插件选项
  • TypeScript 支持: 完整的 TypeScript 类型定义
  • 多文件格式支持: 支持 .js, .ts, .jsx, .tsx, .vue 等文件

📦 安装

npm install vite-plugin-biome-preset
# 或
yarn add vite-plugin-biome-preset
# 或
pnpm add vite-plugin-biome-preset

🔧 使用方法

基本配置

在你的 vite.config.ts 文件中添加插件:

import { defineConfig } from 'vite'
import viteBiomePlugin from 'vite-plugin-biome-preset'

export default defineConfig({
  plugins: [
    viteBiomePlugin({
      formatOnSave: true, // 启用保存时格式化
      extensions: ['.js', '.ts', '.jsx', '.tsx', '.vue'], // 支持的文件扩展名
      sourcePattern: './src', // 源代码目录
      configPath: 'biome.json' // Biome 配置文件路径
    })
  ]
})

插件选项

| 选项 | 类型 | 默认值 | 描述 | |------|------|--------|------| | formatOnSave | boolean | false | 是否在保存时自动格式化文件 | | extensions | string[] | ['.js', '.ts', '.jsx', '.tsx', '.vue'] | 支持的文件扩展名 | | sourcePattern | string | './src' | 源代码目录模式 | | configPath | string | 'biome.json' | Biome 配置文件路径 |

Biome 配置

项目包含一个默认的 Biome 配置文件 default-biome.json,你可以在项目根目录创建自己的biome.json

{
	"extends": ["vite-plugin-biome-preset/default-biome.json"]
}

🎯 功能说明

开发模式

在开发模式下,插件会:

  1. 监听文件变化: 当检测到支持的文件发生变化时,自动执行格式化或检查
  2. 实时反馈: 在控制台显示操作状态和结果
  3. 智能过滤: 自动忽略 node_modules.git 目录

构建模式

在构建模式下,插件会:

  1. 构建前检查: 在构建开始前执行一次完整的代码检查
  2. 确保代码质量: 帮助在构建前发现潜在问题

📝 使用示例

仅启用代码检查

import { defineConfig } from 'vite'
import viteBiomePlugin from 'vite-plugin-biome-preset'

export default defineConfig({
  plugins: [
    viteBiomePlugin({
      formatOnSave: false, // 禁用自动格式化
      sourcePattern: './src/**/*' // 检查 src 目录下的所有文件
    })
  ]
})

启用自动格式化

import { defineConfig } from 'vite'
import viteBiomePlugin from 'vite-plugin-biome-preset'

export default defineConfig({
  plugins: [
    viteBiomePlugin({
      formatOnSave: true, // 启用自动格式化
      extensions: ['.js', '.ts', '.jsx', '.tsx'], // 仅支持 JavaScript/TypeScript 文件
      configPath: './config/biome.json' // 自定义配置文件路径
    })
  ]
})

🔍 控制台输出

插件会在控制台显示详细的操作信息:

🔧 Biome 插件已加载 - Watch 模式: 开启
📝 检测到文件变化: /path/to/your/file.ts
🔄 执行 Biome format: biome check --write --config-path biome.json /path/to/your/file.ts
✅ Biome format 完成

🤝 贡献

欢迎提交 Issue 和 Pull Request!

📄 许可证

MIT License

🔗 相关链接