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

@persagy2/eslint-plugin

v1.0.0-dev.6

Published

一个适用于 vue3.x、typescript 项目的通用eslint预设插件

Downloads

50

Readme

Tips:

  • 当前版本仅适用于 esm { "type": "module" } 项目, cjs项目需要使用老版本 [@persagy2/eslint-plugin@legacy](https://www.npmjs.com/package/@persagy2/eslint-plugin/v/0.2.0)
  • 安装前, 需要移除项目中存在的其他 eslint 依赖, 用来保证与 @pesagy2/eslint-plugin 不产生依赖冲突 (已内置了 eslint 相关的依赖项)~

简介

一个适用于 vue3.x, typescript 项目的通用 eslint 规则预设插件。相比于上一个版本, 这个版本对于规则的选用上做了大量减法 (不再进行大量的重复性校验), 所以请确保项目

开始使用

1. 安装依赖

npm install @persagy2/eslint-plugin -D
# or
yarn add @persagy2/eslint-plugin --dev

2. 配置规则

Tips: 遵循 eslint 插件配置 将这个库当作插件使用即可

在项目根目录下创建 eslint.config.ts 配置文件, 文件内容如下:

Plan.1 (推荐) 使用创建配置方法创建

import { createEslintConfig } from '@persagy2/eslint-plugin'

/** eslint 配置 */
export default createEslintConfig({})

Plan.2 自行配置

import type { Linter } from 'eslint'

/** eslint 配置 */
export default <Linter.Config>{
    root: true,
    /** 配置规则等级 */
    extends: ['plugin:@persagy2/<recommend>'],
    /** 全局变量配置 */
    globals: {},
    /** 自定义规则配置 */
    rules: {}
}

3. 修改 package.json, 添加 lint 命令

{
    "scripts": {
        "lint": "eslint ./src/**/*.{ts,js,vue,md,json,less,svg}",
        "lint:fix": "eslint ./src/**/*.{ts,js,vue,md,json,less,svg} --fix"
    }
}

最佳实践

合适的 lint 时机

在一个版本结束后, 做收尾工作时, 建议执行一下 lint:fix 命令, 对已有代码做一下规范性修正. 日常开发中, 遵循 ts 严格模式的策略即可.

规则等级

| 等级 | 描述 | 说明 | | --------- | -------- | -------------------------------------------------------------------------------------------------------- | | basic | 基础策略 | 强制性语义语法检查 (建议仅 js 项目使用) | | recommend | 推荐策略 | 编码范式检查, 提高 code 的工整性 | | strict | 严格策略 | 注释量、命名策略方面的检测, 提高代码可维护性 | | normal | 标准策略 | 全量代码检查 (注意: 此等级包含了原定于 basic, recommend 等级的全量规则, 所以可能导致 lint 过慢, 慎用!!!) |