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

eslint-config-mbp

v0.0.35

Published

eslint配置的最佳实践

Downloads

12

Readme

eslint-config-mbp

eslint配置的最佳实践

参考来源

  • https://npmjs.com/package/eslint-config-ali
  • https://npmjs.com/package/stylelint-config-ali

参数选项

/**
 * eslint配置生成函数
 * @author HeavenSky
 * @date 2020-05-20
 * @param {object} opt - 配置参数
 * @param {"double"|"single"} [opt.quote="double"] - 单双引号
 * @param {"tab"|2|4} [opt.tab="tab"] - 缩进类型,tab或空格数
 * @param {boolean} opt.prettier - 是否启用prettier支持
 * @param {boolean} opt.order - 是否启用import排序
 * @param {boolean} opt.react - 是否启用react支持
 * @param {boolean} opt.babel - 是否启用babel支持
 * @param {boolean} opt.es5 - 是否启用es5支持
 * @returns {object} eslint配置
 */

函数用法

// .eslintrc.js
module.exports = require("./src")({ babel: 1, react: 1 });

eslint配置

$ npm i eslint-config-mbp

// FOR esm (tab)
{ "extends": "mbp" }
// FOR es5 (tab)
{ "extends": "mbp/es5" }
// ***BELOW*** 2 space indent and single quote
// FOR esm (ali)
{ "extends": "mbp/ali" }
// FOR es5 (ali)
{ "extends": "mbp/ali/es5" }
// FOR full
{ "extends": "mbp/prettier" }

stylelint配置

{ "extends": "eslint-config-mbp/style" }

查看eslint最终配置

$ npx --no -- eslint . --ext .ts,.tsx,.js,.jsx,.mjs,.mts,.es,.esm,.cjs,.vue --fix
$ npx --no -- eslint --print-config '*.{j,t}s{,x}'>config.json
$ npx --no -- eslint --print-config '*.vue'>config.json
  • config.json 即是该文件的对应配置

其他说明

  • 子依赖包内包含的命令不会自动安装,移除eslint依赖,常见使用组合
    • eslint + eslint-config-mbp
  • eslint规则属性值简介
    • "off" -- 0 -- 不启用这个规则
    • "warn" -- 1 -- 出现问题会有警告
    • "error" -- 2 -- 出现问题会报错