@fmit/eslint-config

中文文档
4.17.0发布于 2026/10/26MITTypeScriptES Module近 30 天下载 3738

FMIT's ESLint Config

原始使用文档
文档目录12 节
  1. Usage
  2. Install
  3. Create config file
  4. Add script for package.json
  5. Optional config
  6. Formatters
  7. React
  8. Type Aware Rules
  9. VS Code support (auto fix)
  10. Publish a new version
  11. Required CI/CD Variables
  12. How it works

@fmit/eslint-config

This package extends from @antfu/eslint-config, with some customizations.

  • Single quotes, semi
  • Auto fix for formatting (aimed to be used standalone without Prettier)
  • Sorted imports, dangling commas
  • Reasonable defaults, best practices, only one line of config
  • Designed to work with TypeScript, JSX, Vue out-of-box
  • Lints also for json, yaml, toml, markdown
  • Opinionated, but very customizable
  • ESLint Flat config, compose easily!
  • Using ESLint Stylistic
  • Respects .gitignore by default
  • Optional React, Nuxt support
  • Optional formatters support for CSS, HTML, etc.
  • Style principle: Minimal for reading, stable for diff, consistent

Usage

Install

pnpm i -D eslint @fmit/eslint-config

Create config file

With "type": "module" in package.json (recommended):

// eslint.config.js
import fmit from '@fmit/eslint-config';

export default fmit();

With CJS:

// eslint.config.js
const fmit = require('@fmit/eslint-config').default;

module.exports = fmit();

[!TIP] ESLint only detects eslint.config.js as the flat config entry, meaning you need to put type: module in your package.json or you have to use CJS in eslint.config.js. If you want explicit extension like .mjs or .cjs, or even eslint.config.ts, you can install eslint-ts-patch to fix it.

The .eslintignore file no longer works in Flat config, see customization for more details.

Add script for package.json

For example:

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

Optional config

We provide some optional configs for specific use cases, that we don't include their dependencies by default.

Formatters

Use external formatters to format files that ESLint cannot handle yet (.css, .html, etc). Powered by eslint-plugin-format.

// eslint.config.js
import fmit from '@fmit/eslint-config';

export default fmit({
  formatters: {
    /**
     * Format CSS, LESS, SCSS files, also the `<style>` blocks in Vue
     * By default uses Prettier
     */
    css: true,
    /**
     * Format HTML files
     * By default uses Prettier
     */
    html: true,
    /**
     * Format Markdown files
     * Supports Prettier and dprint
     * By default uses Prettier
     */
    markdown: 'prettier'
  }
});

Running npx eslint should prompt you to install the required dependencies, otherwise, you can install them manually:

npm i -D eslint-plugin-format

React

// eslint.config.js
import fmit from '@fmit/eslint-config';

export default fmit({
  react: true,
});

Running npx eslint should prompt you to install the required dependencies, otherwise, you can install them manually:

npm i -D eslint-plugin-react eslint-plugin-react-hooks eslint-plugin-react-refresh

Type Aware Rules

You can optionally enable the type aware rules by passing the options object to the typescript config:

// eslint.config.js
import fmit from '@fmit/eslint-config';

export default fmit({
  typescript: {
    tsconfigPath: 'tsconfig.json',
  },
});

VS Code support (auto fix)

Install VS Code ESLint extension

Add the following settings to your .vscode/settings.json:

{
  // Disable the default formatter, use eslint instead
  "prettier.enable": false,
  "editor.formatOnSave": false,

  // Auto fix
  "editor.codeActionsOnSave": {
    "source.fixAll.eslint": "explicit",
    "source.organizeImports": "never"
  },

  // Silent the stylistic rules in you IDE, but still auto fix them
  "eslint.rules.customizations": [
    { "rule": "style/*", "severity": "off", "fixable": true },
    { "rule": "format/*", "severity": "off", "fixable": true },
    { "rule": "*-indent", "severity": "off", "fixable": true },
    { "rule": "*-spacing", "severity": "off", "fixable": true },
    { "rule": "*-spaces", "severity": "off", "fixable": true },
    { "rule": "*-order", "severity": "off", "fixable": true },
    { "rule": "*-dangle", "severity": "off", "fixable": true },
    { "rule": "*-newline", "severity": "off", "fixable": true },
    { "rule": "*quotes", "severity": "off", "fixable": true },
    { "rule": "*semi", "severity": "off", "fixable": true }
  ],

  // Enable eslint for all supported languages
  "eslint.validate": [
    "javascript",
    "javascriptreact",
    "typescript",
    "typescriptreact",
    "vue",
    "html",
    "markdown",
    "json",
    "jsonc",
    "yaml",
    "toml",
    "xml",
    "gql",
    "graphql",
    "astro",
    "svelte",
    "css",
    "less",
    "scss",
    "pcss",
    "postcss"
  ]
}

To see all the available options and extended documentation, visit the original repo: @antfu/eslint-config.

Publish a new version

Releases are automatically managed by semantic-release through GitLab CI/CD when commits are pushed to the main branch.

Required CI/CD Variables

The following variables must be configured in Settings → CI/CD → Variables:

  • NPM_TOKEN: Authentication token for publishing to the npm registry

    • Generate at: https://www.npmjs.com/settings/[username]/tokens
    • Required scope: Automation or Publish
  • GITLAB_TOKEN: Personal or project access token for GitLab operations

    • Generate at: Settings → Access Tokens
    • Required scopes: api, write_repository
    • Used for: Creating releases, pushing version bumps and CHANGELOG updates

How it works

  1. Commit your changes using Conventional Commits
  2. Merge to main branch
  3. GitLab CI automatically:
    • Analyzes commits to determine version bump
    • Updates package.json and CHANGELOG.md
    • Creates a Git tag and GitLab release
    • Publishes to npm registry

版本与发布记录

@fmit/eslint-config 共发布 27 个版本,首次发布于 2024/01/24;过去 12 个月发布了 15 个版本。

版本发布日期距今
4.17.0latest2026/10/2620 天前
4.16.02026/09/221 个月前
4.15.02026/07/293 个月前
4.14.02026/06/284 个月前
4.13.02026/05/066 个月前
4.12.02026/04/107 个月前

关于 @fmit/eslint-config 的常见问题

@fmit/eslint-config 是什么?

FMIT's ESLint Config

如何安装 @fmit/eslint-config?

在项目目录运行 npm install @fmit/eslint-config,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:eslint(^9.10.0 || ^10.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@fmit/eslint-config 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@fmit/eslint-config 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@fmit/eslint-config 可以商用吗?

@fmit/eslint-config 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@fmit/eslint-config 的下载量有多少?

根据 npm 官方下载统计,@fmit/eslint-config 在 2026/10/15 – 2026/11/13 这 30 天内被下载 3,738 次,日均约 125 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@fmit/eslint-config 还在维护吗?

最新版本 4.17.0 发布于 2026/10/26(20 天前);至今共发布 27 个版本,其中过去 12 个月发布了 15 个;首次发布于 2024/01/24。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。