@guilhermetod/lintr

中文文档
0.1.0-beta.2发布于 2022/02/24ISCTypeScriptCommonJS近 30 天下载 9040

A Listr2 runner optimized for running your linters

原始使用文档
文档目录4 节
  1. Why ❔
  2. Optimized runs
  3. Clean out the clutter with presets
  4. How to use it

Lintr

A Listr2 runner optimized for running your linters

Why ❔

If you like to maintain a strict code style, there's a good chance you have more than one linter/formatter/validator on your projects. Lintr comes to provide a more clean and straightforward approach to set up and run all of these. It does this by running Listr2 behind the scenes and providing presets for the most common linters out there.

Optimized runs

By using Listr2, Lintr provides you the ability of running all the linters configured in parallel and collecting the potential errors all at once with a much better performance and output.

Lintr

Clean out the clutter with presets

Is common to see projects with multiple linters that have scripts similar like the following:

Without Lintr

  "scripts": {
    "lint:all": "npm run lint:eslint && npm run lint:prettier && npm run lint:types",
    "lint:fix:all": "npm run lint:eslint:fix && npm run lint:prettier:fix && npm run lint:types",
    "lint:eslint": "eslint .",
    "lint:eslint:fix": "eslint . --fix",
    "lint:prettier": "prettier . --check",
    "lint:prettier:fix": "prettier . --write",
    "lint:types": "tsc --noEmit"
  },
  "lint-staged": {
    "*.ts": ["npm run lint:eslint:fix", "npm run lint:prettier:fix", "npm run lint:types"],
    "*.html": ["npm run lint:prettier"]
  }

With Lintr, all you need to do in order to setup setup multiple linters is have your configuration file with your defined presets. Lintr's presets automatically know how to include and ignore files, how to run against the current directory and also the linter's fix flag, so you don't have to write multiple commands for all of these scenarios. Given the mentioned scripts, the following configuration would be enough (checkout below for configuration file):

With Lintr

  "scripts": {
    "lint": "lintr",
    "lint:fix": "lintr --fix"  
  },
  "lint-stages": {
    "*": "npm run lint:fix"
  }

How to use it

All you need to do in order to use Lintr is install it with npm install --save-dev lintr and set a very simple config file. First, create a lintr.config.js file (or any file in the cosmiconfig's default searchPlaces)

Then, register your linters, preferably by finding a preset and you're ready to go. Given the example from the previous `` package.json, you'd have the following config:

const { presets } = require('@guilhermetod/lintr');

module.exports = {
  linters: [
    presets.eslint(),
    presets.prettier(),
    presets.typescript(),
  ],
};

You can also find the global settings available for usage withing the config file or via CLI by running npx lintr --help.

More features and detailed documentation to come soon.

版本与发布记录

@guilhermetod/lintr 共发布 4 个版本,首次发布于 2021/08/20;过去 12 个月发布了 0 个版本。

版本发布日期距今
0.1.0-beta.2latest2022/02/244 年前
0.1.0-beta.12022/02/184 年前
0.1.0-beta.02021/11/304 年前
0.1.0-alpha.02021/08/205 年前

关于 @guilhermetod/lintr 的常见问题

@guilhermetod/lintr 是什么?

A Listr2 runner optimized for running your linters

如何安装 @guilhermetod/lintr?

在项目目录运行 npm install @guilhermetod/lintr,或使用 pnpm add / yarn add / bun add。它还提供命令行工具 lintr,可以用 npx lintr 直接运行。

@guilhermetod/lintr 支持 TypeScript 吗?

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

@guilhermetod/lintr 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@guilhermetod/lintr 可以商用吗?

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

@guilhermetod/lintr 的下载量有多少?

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

@guilhermetod/lintr 还在维护吗?

最新版本 0.1.0-beta.2 发布于 2022/02/24(4 年前);至今共发布 4 个版本,其中过去 12 个月发布了 0 个;首次发布于 2021/08/20。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。