Skip to content

Repository files navigation

banner

@uni-helper/eslint-config

logo

License GitHub Stars NPM version npm downloads

Author Maintainer

基于 antfu/eslint-config,为 uni-app 项目提供开箱即用的 ESLint 配置。

不想看文档?直接问 AI 🤖 Ask DeepWiki

请考虑持续赞助以维持该项目的持续健康发展,非常感谢!🙏

  • uni-app 规则适配 — 关闭与 uni-app 冲突的 Vue 规则(如组件名大小写、自定义事件命名)
  • 平台全局变量 — 自动注册 uni、wx、my、tt 等平台全局变量
  • JSON 排序 — 按 uni-app 官方规范对 manifest.json、pages.json、theme.json 的键进行排序,保持配置文件一致性
  • 智能检测 — 安装了 @uni-helper/vite-plugin-uni-manifest 或 @uni-helper/vite-plugin-uni-pages 时,自动跳过对应 JSON 文件的排序

安装

pnpm i -D eslint @antfu/eslint-config @uni-helper/eslint-config

使用

在项目根目录创建 eslint.config.mjs:

// eslint.config.mjs
import uniHelper from '@uni-helper/eslint-config'

export default uniHelper()

在 package.json 中添加脚本:

{
  "scripts": {
    "lint": "eslint .",
    "lint:fix": "eslint . --fix"
  }
}

选项

export default uniHelper({
  // 启用 uni-app 规则适配,默认 true。开启时会强制启用 Vue 支持
  uni: true,
  // 启用 JSON 排序(manifest.json / pages.json / theme.json),默认 true
  uniJson: true,
})

平台全局变量的注册不受 uni 选项影响,始终启用。

所有 @antfu/eslint-config 选项 均可直接传递。

兼容性

建议始终使用 Node.js 最新的 LTS 版本。

eslint @antfu/eslint-config @uni-helper/eslint-config Node.js 备注
^10.0.0 ^7.0.0 || ^8.0.0 || ^9.0.0 ^0.7.4 ^20.19.0 || ^22.13.0 || >=24 仅 ESM
^10.0.0 ^5.0.0 || ^6.0.0 || ^7.0.0 0.7.1 ^20.19.0 || ^22.13.0 || >=24 仅 ESM
^9.10.0 ^5.0.0 || ^6.0.0 ^0.6.0 ^18.18.0 || ^20.9.0 || >=21.1.0 仅 ESM
^9.10.0 ^5.0.0 ^0.5.0 ^18.18.0 || ^20.9.0 || >=21.1.0 仅 ESM
^9.10.0 ^4.0.1 ^0.4.0 ^18.18.0 || ^20.9.0 || >=21.1.0 仅 ESM
^9.10.0 ^3.13.0 ^0.3.0 ^18.18.0 || ^20.9.0 || >=21.1.0
^9.5.0 ^3.0.0(v0.2.2 起 ^3.4.1) ^0.2.0 ^18.18.0 || ^20.9.0 || >=21.1.0
>=8.40.0 ^2.25.0 ^0.1.0 ^12.22.0 || ^14.17.0 || >=16.0.0

相关资源

参与贡献

欢迎通过 Issue 或 Pull Request 参与改进本项目。开始前请阅读 CONTRIBUTING.md,了解项目结构、本地开发流程、测试方式与提交规范。

License

MIT © KeJun

About

适用于 uni-app 的 Anthony's ESLint 配置预设

Topics

Resources

Code of conduct

Contributing

Stars

15 stars

Watchers

1 watching

Forks

Releases

Sponsor this project

Used by

Contributors

Languages