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

@coolh/eslint-config

v1.0.0

Published

eslint配置规则

Downloads

1

Readme

eslint-config

eslint 配置规则

使用方法

快速使用(推荐)

使用 npm:

  npm install --save-dev eslint prettier babel-eslint typescript @typescript-eslint/parser @typescript-eslint/eslint-plugin eslint-plugin-react eslint-plugin-react-hooks @coolh/eslint-config

使用 yarn:

  yarn add --dev eslint prettier babel-eslint typescript @typescript-eslint/parser @typescript-eslint/eslint-plugin eslint-plugin-react eslint-plugin-react-hooks @coolh/eslint-config

配置 .eslintrc :

{
  "extends": ["@trip/eslint-config"]
}

该规则支持自动识别.js.jsx.ts.tsx文件并启用对应的规则,大部分项目使用此种配置即可。

JavaScript

若你希望开仅启针对 .js 文件的校验,使用方法如下 使用 npm:

  npm install --save-dev eslint prettier babel-eslint @coolh/eslint-config

使用 yarn:

  yarn add --dev eslint prettier babel-eslint @coolh/eslint-config

配置 .eslintrc :

{
  "extends": ["@eslint-config/javascript"]
}

TypeScript

若你希望仅开启针对 .ts 文件的校验,使用方法如下 使用 npm:

  npm install --save-dev eslint prettier typescript @typescript-eslint/parser @typescript-eslint/eslint-plugin @coolh/eslint-config

使用 yarn:

  yarn add --dev eslint prettier typescript @typescript-eslint/parser @typescript-eslint/eslint-plugin @coolh/eslint-config

配置 .eslintrc :

{
  "extends": ["@coolh/eslint-config/typescript"]
}

React

如果项目中使用到 react,那么可以按照如下方式启用 react 相关规则 使用 npm:

  npm install --save-dev eslint prettier babel-eslint eslint-plugin-react eslint-plugin-react-hooks @coolh/eslint-config

使用 yarn:

  yarn add --dev eslint prettier babel-eslint eslint-plugin-react eslint-plugin-react-hooks @coolh/eslint-config

配置 .eslintrc :

{
  "extends": [
    "@coolh/eslint-config/javascript", //或是 "@coolh/eslint-config/typescript"
    "@coolh/eslint-config/react"
  ]
}

最后配置 package.json 的 scripts:

{
  "scripts": {
    "lint": "eslint *.js lib test xxx",
    "lintfix": "eslint --fix *.js lib test xxx"
  }
}

运行:

  npm run lint

扩展

搭配 VSCode 使用

vscode 扩展-搜索 eslint-安装并重启 vscode

开启 ESLint 错误提示

在 VSCode 中,ESLint 无法识别 .ts.tsx 等文件,需要在设置的 json 文件添加以下配置:

{
  "eslint.validate": [
    "javascript",
    "javascriptreact",
    "typescript",
    "typescriptreact"
  ]
}

保存时自动修复ESLint错误(推荐)

如果想要开启「保存时自动修复」的功能,额外配置以下条件:

{
  "eslint.validate": [
    "javascript",
    "javascriptreact",
    "typescript",
    "typescriptreact"
  ],
  "editor.codeActionsOnSave": {
    "source.fixAll.eslint": true
  }
}

注意:如果已安装 Prettier 等插件并开启了自动格式化,请将其关闭,否则存在冲突的可能

文档链接