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

lint-config-web

v2.0.2

Published

from [email protected]

Downloads

2

Readme

lint-config-web

用于智能化react技术栈项目的编码语法规范、格式规范检查, 及保存文件时, 根据此规范,编辑器中提示或自动fix或通过prettier进行格式化。

包含四部分:

  1. js、ts的编码规范、输写规范: eslint的规范";
  2. 样式编码规范: stylelint;
  3. 格式化处理: prettier;
  4. git提交时lint检查: husky、lint-staged; (lint验查失败、git提交会被阻止)

安装vscode插件

为了在编辑代码文件时,或保存文件时,能够通过编辑器功能(高亮波浪下划线):

  1. 提示eslint检验后错误项,并支持在保存时自动修复能修复的,如强制单引、强制缩进;
  2. 在输入、保存、粘贴时,根据prettier规则自动格式化: 强制单引、强制缩进、是否换行;

播件有:

  • ESlint
  • Prettier - Code formatter

在项目中进行配置

第一步:安装依赖(在项目根目录终端执行)

npm i lint-config-web --save-dev -S

npm run lint-config-web

第二步:项目的package.json加上scripts、husky、lint-staged

{
  ...
  "scripts": {
    ...
    "lint": "npm run lint:js && npm run lint:style",
    "lint:js": "eslint --cache --ext .js,.jsx,.ts,.tsx ./src",
    "lint:style": "stylelint --fix \"src/**/*.less\" --syntax less",
    "prettier": "prettier -c --write \"**/*\"",
    "lint-staged": "lint-staged"
  },
  "husky": {
    "hooks": {
      "pre-commit": "npm run lint-staged"
    }
  },
  "lint-staged": {
    "**/*.less": "stylelint --syntax less",
    "**/*.{js,jsx,ts,tsx}": "npm run lint"
  },
  ...
}

第三步:lint初始化

npm run lint:init

lint初始化,会在项目根目录创建或修改以下文件, 目的是把lint-config-web中的规则应用到当前项目中,.vscode > settings.json中的内容,定义了当前项目,在编辑是、保存时,是否进行eslint修复及prettier自动格式化。

  • .vscode
    • settings.json //根据当前项目在保存时定义:1)eslint检查,自动修复, 2)是否prettier自动化格式
  • .editorconfig //编辑器中新建文件时,会以这个配置定义缩进、charset等
  • .eslintignore //不进行eslint检查的文件
  • .eslintrc.js //lint-config-web eslint规则的引入, 并且可以在这增加规则项。
  • .prettierignore //不进行自动格式化的文件
  • .prettierrc.js //lint-config-web prettier规则的引入
  • .stylelintrc.js //lint-config-web stylelint规则的引入