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

@truckhome/eslint-config

v2.0.0

Published

```bash pnpm add @truckhome/eslint-config -D ```

Downloads

1

Readme

使用

pnpm add @truckhome/eslint-config -D
// .eslintrc 中
module.exports = {
  extends: ['@truckhome/eslint-config']
}

rules

module.exports = {
  env: {
    browser: true,
    node: true,
    es2021: true
  },
  rules: {
    'vue/multi-word-component-names': 0,
    'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
    'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
    // 数组和对象键值对最后一个逗号,never参数:不能带末尾逗号,always:必须带
    'comma-dangle': [2, 'never'],
    // 不必要的;
    semi: [2, 'never'],
    quotes: [2, 'single', 'avoid-escape'],
    // 强制操作符使用一致的换行符
    'operator-linebreak': [
      2,
      'after',
      {
        overrides: {
          '?': 'before',
          ':': 'before'
        }
      }
    ],
    // 强制将对象属性放在不同的行上
    'object-property-newline': 2,
    // 强制对象花括号内使用一致的空格
    // 'object-curly-spacing': 2,
    'object-curly-spacing': [2, 'always'],
    // 强制花括号内换行一致性
    'object-curly-newline': 2,
    // switch语句强制default分支,也可以添加// no default 注释取消警告
    'default-case': 2,
    // 强制object.key中 . 的位置与object、property在同一行
    'dot-location': [2, 'property'],
    // 强制所有控制语句使用一致的括号风格 ?? if(condition) return 还是 if(condition){return}
    // curly: [2, 'all'],
    // 限制圈复杂度,类似if else可以连续接多少个
    complexity: [2, 7],
    // 强制typeof 表达式与有效的字符串进行比较
    'valid-typeof': 2,
    // 使用isNaN()检查NaN
    'use-isnan': 2,
    // 禁止在return、throw、continue、break语句之后出现不可达代码
    'no-unreachable': 2,
    // 禁止出现令人困惑的多行表达式
    'no-unexpected-multiline': 2,
    // 禁用稀疏数组
    'no-sparse-arrays': 2,
    // 禁止在嵌套块中出现function或var声明
    'no-inner-declarations': [2, 'functions'],
    // 禁止对function声明重新赋值
    'no-func-assign': 2,
    // 禁止不必要的分号
    'no-extra-semi': 2,
    // 禁止不必要的括号 (a * b) + c 报错
    'no-extra-parens': 2,
    // 禁止不必要的布尔值转换
    'no-extra-boolean-cast': 2,
    // 强制在对象字面量的属性中键和值之间使用一致的间距
    'key-spacing': [
      2,
      {
        beforeColon: false,
        afterColon: true
      }
    ],
    // 双驼峰
    camelcase: 2,
    // 禁止或强制在单行代码块中使用空格
    'block-spacing': [2, 'never'],
    // 不允许在变量定义之前使用他们
    'no-use-before-define': 2,
    // 禁止出现未使用过的变量
    'no-unused-vars': [
      2,
      {
        vars: 'all',
        args: 'none'
      }
    ],
    // 禁止将undefined作为标识符
    'no-undefined': 2,
    // 禁用未声明变量,除非他们在/* global */注释中被提到
    'no-undef': 2,
    // 禁止var声明与外层作用域的变量同名
    'no-shadow': 2,
    // 不允许catch子句参数与外层作用域中的变量同名
    'no-catch-shadow': 2,
    // 禁止对catch子句参数赋值
    'no-ex-assign': 2,
    // 禁止空语句块
    'no-empty': 2,
    // 禁用with语句
    'no-with': 2,
    // 要求iife使用括号括起来
    'wrap-iife': [2, 'any'],
    // 禁止不必要的字符串字面量和模板字面量的连接
    'no-useless-concat': 2,
    // 禁止不必要的.call .apply
    'no-useless-call': 2,
    'no-extra-bind': 2,
    // 禁止出现未使用过的表达式
    'no-unused-expressions': 2,
    // 禁用一成不变的循环条件
    'no-unmodified-loop-condition': 2,
    // 禁止抛出非异常字面量
    'no-throw-literal': 2,
    // 禁用逗号操作符 ??
    // 'no-sequences': 2,
    // 禁止自我赋值
    'no-self-assign': 2,
    // 禁止自身比较
    'no-self-compare': 2,
    // 禁止使用javascript: url
    'no-script-url': 1,
    // 禁用 __proto__
    'no-proto': 2,
    // 禁止对function的参数进行重新赋值
    'no-param-reassign': 2,
    // 禁止对String,Number,Boolean使用new
    'no-new-wrappers': 2,
    // 禁止对Function使用new
    'no-new-func': 2,
    // 禁止在非赋值、条件语句中使用new
    'no-new': 2,
    // 禁止对原生对象赋值
    'no-native-reassign': 2,
    // 禁止使用多个空格
    'no-multi-spaces': 2,
    // 禁止在循环中出现function声明和表达式
    'no-loop-func': 2,
    // 禁用不必要的嵌套块
    'no-lone-blocks': 2,
    // 禁止使用类似eval方法
    'no-implied-eval': 2,
    'no-eval': 2,
    // 禁止case语句落空
    'no-fallthrough': 2,
    // 禁用不必要的标签
    'no-extra-label': 2,
    // 指定数组的元素之间要以空格隔开(, 后),never:[之前和]之后不能带空格
    'array-bracket-spacing': [2, 'never'],
    // if while function 后面 { 必须与if 在同一行
    'brace-style': [
      2,
      '1tbs',
      {
        allowSingleLine: true
      }
    ],
    // 禁用空解构模式 ??
    'no-empty-pattern': 2,
    // 禁止出现空函数,如果函数包含一条注释,它将不会被认为有问题
    'no-empty-function': 2,
    // 禁止if语句中有return后有else
    'no-else-return': 2,
    // 禁用arguments.caller或arguments.callee
    'no-caller': 2,
    // 使用===代替== allow-null允许null和undefined==
    eqeqeq: [2, 'allow-null'],
    // 禁止重复的case标签
    'no-duplicate-case': 2,
    // 不允许在case子句中使用词法声明
    // 'no-case-declarations': 0,
    // 禁止对象字面量中出现重复的key
    'no-dupe-keys': 2,
    // 禁止function定义中出现重名参数
    'no-dupe-args': 2,
    // 以方括号取对象属性时,[后面和]前面是否需要空格
    'computed-property-spacing': [2, 'never'],
    // 禁止在可以有更简单的可替代表达式时使用三元操作符
    'no-unneeded-ternary': 2,
    // 禁止行尾空格
    'no-trailing-spaces': 2,
    // 不允许多个空行
    'no-multiple-empty-lines': [
      2,
      {
        max: 2
      }
    ],
    // 不允许空格和tab混合缩进
    'no-mixed-spaces-and-tabs': 2,
    // 禁止混合使用不同的操作符
    'no-mixed-operators': 2,
    // 禁止if作为唯一语句出现在else中
    'no-lonely-if': 2,
    // 要求方法链中每个调用都有一个换行符
    'newline-per-chained-call': 2,
    // 强制在块之前使用一致的空格 function () {}
    // 'space-before-blocks': [2, 'always'],
    // // 强制在 function的左括号之前使用一致的空格
    // 'space-before-function-paren': [2, 'always'],
    // 强制generator函数中*号周围使用一致的空格
    'generator-star-spacing': [
      2,
      {
        before: true,
        after: true
      }
    ],
    // 要求箭头函数体使用大括号
    'arrow-body-style': 2,
    // 要求箭头函数的参数使用圆括号
    // 'arrow-parens': 1,
    'arrow-spacing': [
      2,
      {
        before: true,
        after: true
      }
    ],
    // 要求调用无参构造函数时有圆括号
    'new-parens': 2,
    // 要求构造函数首字母大写,new 操作符有首字母大小写的函数,允许调用首字母大写的函数时,省略new
    'new-cap': [
      2,
      {
        newIsCap: true,
        capIsNew: false
      }
    ],
    // 强制回调函数最大嵌套深度
    'max-nested-callbacks': [1, 4],
    // 强制关键字前后使用一致的空格
    'keyword-spacing': 2,
    // 强制使用一致的换行风格
    'linebreak-style': [1, 'unix'],
    // 强制一行最大长度
    'max-len': [1, 200],
    // 强制最大行数
    // 'max-lines': 1000,
    // 强制function块中最多允许的语句数量
    'max-statements': [1, 200],
    // 强制function中最多允许的参数数量
    'max-params': [1, 6],
    // 强制在注释中 // 或 /*使用一致的空格
    'spaced-comment': [
      2,
      'always',
      {
        markers: [
          'global',
          'globals',
          'eslint',
          'eslint-disable',
          '*package',
          '!'
        ]
      }
    ],
    // 强制在圆括号内使用一致的空格 ( x )
    'space-in-parens': [2, 'never'],
    // 不能使用var
    'no-var': 2,
    // 要求使用模板字面量、而不是字符串拼接
    'prefer-template': 2,
    // 要求const声明不在被修改的变量
    'prefer-const': 2,
    // 禁止修改const声明的变量
    'no-const-assign': 2,
    // 要求使用箭头函数作为回调
    'prefer-arrow-callback': 2,
    // 禁止类成员出现重复名字
    'no-dupe-class-members': 2,
    // 要求操作符周围有空格
    'space-infix-ops': 2,
    // 强制模块内的 import 按照字母排序 ?? 是否强制
    // 'sort-imports': 2,
    // 强制yield*表达式中*周围使用空格
    'yield-star-spacing': [2, { before: true, after: true }]
  }
}