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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@lzwme/fed-lint-helper

v2.6.4

Published

前端项目编码质量 lint 检测辅助工具。用于辅助大型长期研发的前端项目渐进式的迁移与改进编码规范约束。

Downloads

338

Readme

@lzwme/fed-lint-helper

@lzwme/fed-lint-helper

NPM version node version license MIT

build status npm download GitHub issues GitHub forks GitHub stars

一个前端项目编码质量静态检查(Lint)辅助工具。用于辅助长期研发的大型前端项目渐进式的升级、迁移或改进编码规范约束规则。

功能特性(Features)

  • 白名单机制。升级新版本、引入新规则时开启白名单模式,技术栈更新改造影响成本低
  • 可选的多线程、多进程执行模式。多项静态检查并行执行效率更高
  • 支持缓存能力。开启缓存二次执行效率显著提升,避免重复执行浪费时间

已支持的 Lint 能力:

  • eslint 自定义 ESLint 检测执行
  • tscheck 自定义 TypeScript 检测执行
  • jest 自定义 jest 单元测试的执行
  • prettier 自定义 prettier 编码风格检测与格式化
  • commitlint 自定义遵循 Angular commit style 的 git 提交规范(用于 git hooks)
  • jira 自定义关联 jira 的检测逻辑(TODO: 方案说明)
  • more...

安装(Install)

# use pnpm
pnpm add -D @lzwme/fed-lint-helper
# use yarn
yarn add -D @lzwme/fed-lint-helper
# use npm
npm i -D @lzwme/fed-lint-helper

使用(Useage)

命令行方式(Command Line Interface)

flh --help

# 在当前目录下生成默认的配置文件 .flh.config.cjs
flh init --config

# typescript check
flh --tscheck
# eslint check
flh --eslint
# jest check
flh --jest
# git commit lint
flh --commitlint
# prettier fix
flh --prettier --fix

# Multitask parallel execution
flh --tscheck --eslint --jest

其他辅助工具命令(Others):

# 目录删除
flh rm --help
# 示例:删除目录 a 和 dist
flh rm ./a ./dist -f

# 消息通知
flh notify --help
# 示例:企业微信机器人消息通知
flh notify "任务执行失败!@all" --wx-work <web hook key1> <web hook key2>

结合 huskygit hooks 使用

推荐结合 husky 配置本地 git hooks。参考示例:

# .husky/commit-msg
npm exec flh --commitlint

# .husky/pre-commit
npm exec flh -- --eslint --tscheck --jest --only-staged
npm exec flh -- --prettier --only-staged --fix
# git add --update

CI 持续集成过程中可视具体需求配置。

API 调用

提供了 TsCheckESLintCheck 等类对象供 API 方式调用,以便自定义处理逻辑在 CI 构建中的集成。

import { TsCheck, ESLintCheck } from '@lzwme/fed-lint-helper';

// typescript check
const tsCheck = new TsCheck({
  exitOnError: false,
  src: ['src'],
  // checkOnInit: false,
  // debug: true,
  // toWhiteList: true,
  // cache: true,
  // removeCache: false,
  // tsConfigFileName: 'tsconfig.eslint.json',
  // silent: false,
});
const res = await tsCheck.start();
console.log(res);

// eslint check
const eslintCheck = new ESLintCheck({
  exitOnError: false,
  src: ['src'],
  eslintOptions: {
    overrideConfig: {
      rules: { eqeqeq: 'warn' },
      // rulePaths: ['./eslint-rules/'],
      // errorOnUnmatchedPattern: true,
    },
  },
  // checkOnInit: false,
  // cache: argv.includes('cache'),
  // removeCache: argv.includes('nocache'),
  // silent: argv.includes('silent'),
  // debug: argv.includes('debug'),
  // toWhiteList: true,
  // fix: argv.includes('fix'),
});

let res = await eslintCheck.start();
console.log(res);
res = await eslintCheck.start(['test/test/test-cases/ts-check-test-1.ts', 'src/ts-check.ts']);
console.log(res);

更多细节可参考 API 文档

API 文档

开发(Development)

本地二次开发:

git clone https://github.com/lzwme/fed-lint-helper
pnpm install
pnpm dev
# npm link

或者 fork 本项目进行代码贡献。

欢迎贡献想法与代码。

License

@lzwme/fed-lint-helper is released under the MIT license.

该插件由志文工作室开发和维护。