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

@ranwawa/eslint-plugin

v1.1.1

Published

eslint配置文件

Downloads

2

Readme

@ranwawa/eslint-plugin

1. 快速开始

安装依赖

pnpm

pnpm i

npm 7+

npm install --save-dev @ranwawa/eslint-plugin

npm

npm install --save-dev @ranwawa/eslint-plugin \
                       @typescript-eslint/eslint-plugin \
                       eslint-plugin-import \
                       eslint-plugin-jsx-a11y \
                       eslint-plugin-node \
                       eslint-plugin-prettier \
                       eslint-plugin-react \
                       eslint-plugin-react-hooks \
                       eslint-plugin-vue

yarn

yarn add --save-dev @ranwawa/eslint-plugin \
                       @typescript-eslint/eslint-plugin \
                       eslint-plugin-import \
                       eslint-plugin-jsx-a11y \
                       eslint-plugin-node \
                       eslint-plugin-prettier \
                       eslint-plugin-react \
                       eslint-plugin-react-hooks \
                       eslint-plugin-vue

创建配置文件

vue2

echo '{ "extends": ["plugin:@ranwawa/eslint-plugin/vue2"] }' > .eslintrc

vue3 + ts

echo '{ "extends": ["plugin:@ranwawa/eslint-plugin/vue3"] }' > .eslintrc

react + ts

echo '{ "extends": ["plugin:@ranwawa/eslint-plugin/react"] }' > .eslintrc

uni-app

echo '{ "extends": ["plugin:@ranwawa/eslint-plugin/react"], "plugins": ["@ranwawa/eslint-plugin"], "env": { "@ranwawa/uni-app": true } }' > .eslintrc

添加 lint 命令

npm7+

npm set-script lint:script "eslint ./ --ext .js,.ts,.vue,.jsx,.tsx"
npm set-script lint-fix:script "eslint ./ --ext .js,.ts,.vue,.jsx,.tsx --fix"

手动添加到 package.json 文件

{
  "scripts": {
    "lint:script": "eslint ./ --ext .js,.ts,.vue,.jsx,.tsx",
    "lint-fix:script": "eslint ./ --ext .js,.ts,.vue,.jsx,.tsx --fix"
  }
}

运行 lint 命令

npm run lint:script

2. 业务介绍

业务简介

eslint 规范.集中管理所有项目的 eslint 规范.包括介不限于vue2,vue3,react

相关文档

| 文档类型 | 链接 | | --------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 重新认识 eslint | 钉钉文档 |

3. 技术介绍

框架简介

| | 工具 | | ------------ | ----- | | 包管理工具 | pnpm | | 版本管理工具 | lerna |

目录结构

├── README.md # 项目介绍
├── configs # 配置文件目录
│   ├── javascript.js # eslint配置文件: js相关
│   ├── node-module.js
│   ├── node-script.js
│   ├── react.js
│   ├── vue2.js
│   └── vue3.js
├── configs # 环境变量目录
│   ├── uni-app.json # uni-app相关的环境变量
│   └── vue3.js
├── index.js # 项目入口文件
└── rules # 规则目录
    ├── imports # import相关规则
    │   ├── README.md # 文档
    │   └── index.js # eslint规则
    ├── javascript
    ├── node
    ├── react
    ├── typescript
    ├── vue2
    └── vue3

项目入口文件

index.js 实际上是一个 eslint 插件,通过 configs 字段可以暴露出多个 eslint 配置文件,以供其他项目引入.

4. 常见问题

vue3 setup 模式下 template 中使用的变量报 no-unused-vars 错误

这是老版本 vue-eslint-parser 不兼容 setup 语法导致.先删除本地的 vue-eslint-parser 然后重新安装即可

npm uninstall vue-eslint-parser

npm install --save-dev vue-eslint-parser

参考: eslint-plugin-vue 官网

一下扫描出几百几千个错误怎么办?

对于老项目这种现象非常正常.我们只需要关心自己修改的文件即可.可以将 npm 命令修改成只扫描对应文件

{
  "scripts": {
    "lint-fix:script": "eslint ./src/App.vue --ext .js,.ts,.vue,.jsx,.tsx --fix"
  }
}