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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@ithinkdt/lint

v4.2.1

Published

iThinkDT 项目的 ESLint、StyleLint 配置

Readme

@ithinkdt/lint

iThinkDT 项目的 ESLint、StyleLint 统一配置。

许可证

MIT

安装

npm i -D @ithinkdt/lint

需要您自行安装 peer 依赖 eslint@>=9stylelint@>=16typescript@>=5.8

介绍

  • 集成 @eslint/jsrecommended 推荐规则;
  • 集成 @eslint/json 的 JSON 校验规则;
  • 集成 @eslint/markdown 的 Markdown 代码块校验;
  • 集成 typescript-eslintrecommendedTypeChecked,启用 Type Aware Rules 类型感知规则,检查 ts、vue 文件的类型错误;
  • 集成 eslint-plugin-vueflat/recommended 推荐规则;
  • 集成 eslint-plugin-unicornflat/recommended 推荐规则;
  • 集成 @unocss/eslint-config 的 flat 推荐规则(可选开启);
  • 集成 @stylistic/eslint-plugin 代码风格规则(可选开启);
  • 集成 eslint-plugin-tsdoc 规则;
  • 集成 eslint-plugin-import-x 规则;
  • 集成 eslint-plugin-format 格式化规则(CSS / SCSS / Less 等);
  • 集成 @eslint-community/eslint-plugin-eslint-comments 规则;
  • 集成 eslint-plugin-playwright@vitest/eslint-plugineslint-plugin-no-only-tests 测试代码规则;
  • 提供自定义规则 @ithinkdt/no-relative-parent-imports@ithinkdt/prefer-import-alias
  • 支持 StyleLint 配置。

由于启用了类型感知规则,TypeScript 会在整个项目上执行类型检查,lint-staged 效果可能不佳。

ESLint

安装 npm i -D eslint,在项目根目录创建 eslint.config.js

// eslint.config.js
import ithinkdt from '@ithinkdt/lint'

export default ithinkdt({
    unocss: true,
    stylistic: true,
    tsconfigRootDir: import.meta.dirname,
}).append({
    // 在此追加项目自定义配置
})

配置选项 LintOptions

| 选项 | 类型 | 默认值 | 说明 | |------|------|--------|------| | unocss | boolean | false | 是否启用 @unocss/eslint-config/flat | | stylistic | boolean \| StylisticCustomizeOptions | false | 是否启用 @stylistic/eslint-plugin | | tsconfigRootDir | string | — | TSConfig 根目录路径,用于类型感知规则的项目引用 |

stylistic 设为 true 时,使用以下默认风格:

{
    indent: 4,          // 4 空格缩进
    quotes: 'single',   // 单引号
    semi: false,        // 不加分号
    jsx: true,          // 启用 JSX 支持
    braceStyle: '1tbs', // One True Brace Style
}

你也可以传入自定义的 StylisticCustomizeOptions 对象来覆盖默认值。

CI 环境

在 CI 环境中(CI 环境变量为真值),ESLint 会将所有规则设为 error 级别,确保 CI 流程严格阻断。

针对测试文件

测试文件(**/tests/****/*.test.***/*.spec.* 等)会自动应用以下配置:

import { playwright, vitest } from '@ithinkdt/lint'

// 使用方式
export default ithinkdt().append(
    playwright.configs.recommended,
    vitest.configs.recommended,
)

导出的工具

| 导出 | 说明 | |------|------| | defaultEsFiles | 默认匹配的 ES 文件 glob | | defaultTsFiles | 默认匹配的 TS 文件 glob | | defaultJsFiles | 默认匹配的 JS 文件 glob | | defaultTsWithVueFiles | 默认匹配的 TS + Vue 文件 glob | | disableTypeChecked | 禁用类型检查的配置(仅作用于 JS 文件) | | createTypeScriptImportResolver | 创建 TypeScript 路径别名解析器,用于 eslint-plugin-import-x | | tsParser | TypeScript 解析器(支持 .vue 额外扩展名) | | vueParser | vue-eslint-parser | | playwright | eslint-plugin-playwright | | vitest | @vitest/eslint-plugin | | vue | eslint-plugin-vue |

自定义规则

| 规则 | 级别 | 说明 | |------|------|------| | @ithinkdt/no-relative-parent-imports | warn | 禁止使用 ../ 相对父级导入 | | @ithinkdt/prefer-import-alias | warn | 建议使用路径别名替代深层相对导入 |

StyleLint

安装 npm i -D stylelint,在项目根目录创建 stylelint.config.js

// stylelint.config.js
import stylelintConfig from '@ithinkdt/lint/stylelint'

export default stylelintConfig({
    // 在此追加或覆盖自定义配置
})

内置配置

  • 继承 stylelint-config-standardstylelint-config-standard-vue
  • 集成 stylelint-order 插件;
  • 忽略 *.js*.ts*.json*.md*.yaml 等非样式文件;
  • selector-class-pattern:强制 kebab-case 或 BEM 命名规范;
  • custom-property-empty-line-before:CSS 自定义属性前不要求空行。
// stylelint.config.js

import ithinkdt from '@ithinkdt/lint/stylelint'

export default ithinkdt({
    rules: {
        // 规则配置
    },
})