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

moga-lint

v1.0.1

Published

moga-lint是用于moga应用代码校验而封装的各种校验工具集

Downloads

5

Readme

moga-lint

介绍

moga-lint是用于moga应用代码校验而封装的各种校验工具集,其内部集成了大量经过实践而设置的代码校验规则。

用法

安装moga-lint

npm i moga-lint -D

安装moga-lint后,无须在单独安装eslint、stylelint、prettier、husky等工具,直接开箱即用。

使用moga-lint

moga-lint目前支持eslint、stylelint、prettier、commitlint,共四种类型lint tool。

eslint配置

在项目根目录下新增.eslintrc.js文件,添加如下代码:

const { getESLintConfig } = require('moga-lint');

module.exports = getESLintConfig('react-ts', {
    // 自定义规则,优先级大于moga-lint中内部的规则
});

目前getESLintConfig支持common-ts、common、react-ts、react四种规则集的获取。

stylelint配置

在项目根目录下新增.stylelintrc.js文件,添加如下代码:

const { getStylelintConfig } = require('moga-lint');

module.exports = getStylelintConfig('react', {
    // 自定义规则,优先级大于moga-lint中内部的规则
});

目前getStylelintConfig支持common、react两种规则集的获取。

prettier配置

在项目根目录下新增.prettierrc.js文件,添加如下代码:

const {getPrettierConfig}  = require("moga-lint")

module.exports = getPrettierConfig('react', {
    // 自定义规则,优先级大于moga-lint中内部的规则
});

目前getPrettierConfig支持common、react两种规则集的获取。

commlint配置

在项目根目录下新增commitlint.config.js文件,添加如下代码:

const {getCommitlintConfig} = require("moga-lint");

module.exports = getCommitlintConfig('react', {
    // 自定义规则,优先级大于moga-lint中内部的规则
})

目前getCommitlintConfig支持common、react两种规则集的获取。

package.json配置

{
    "scripts": {
        "eslint": "eslint --ext .js,.jsx,.ts,.tsx ./",
        "eslint:fix": "eslint --ext .js,.ts,.tsx ./ --fix",
        "stylelint": "stylelint \"**/*.{css,scss,less}\"",
        "stylelint:fix": "stylelint --fix \"**/*.{css,scss,less}\"",
        "prelint": "prettier --check **/*{.js,.ts,.tsx}",
        "prelint:fix": "prettier --write **/*{.js,.ts,.tsx}",
        "lint": "npm run eslint && npm run stylelint && npm run prelint",
        "lint:fox": "npm run eslint:fix && npm run stylelint:fix && npm run prelint:fix",
        "prepublishOnly": "npm run lint"
    },
    "husky": {
        "hooks": {
            "commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
        }
    },
}

scripts中的配置只是一个综合演示,开发中可以根据实际情况进行修改。

说明

moga-lint没有做任何代码使用和配置脚本上的限制,它仅仅只是一个校验工具集合而已。通过get***Config函数中,添加自定义配置对象,就可以对moga-lint中的配置进行修改。

配置对象的配置规则参考eslintstylelintprettiercommitlint配置。