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

@utilx/tslint-rules

v0.0.0

Published

```bash npm install tslint @typeshell/tslint-rules --save-dev ```

Downloads

2

Readme

tslint-rulesss

npm install tslint @typeshell/tslint-rules --save-dev

在项目目录建立tslint.json

extends表示采用的集合 rules可以覆盖在extends中引入的规则集合

{
    "defaultSeverity": "error",
    "extends": [
        // "tslint:recommended"
        "tslint-auto-fixable-format"
    ],
    "jsRules": {},
    "rules": {
        "no-boolean-literal-compare": true,
        "variable-name": [
            true, 
            "ban-keywords", 
            "check-format", 
            "allow-leading-underscore", 
            "allow-snake-case"
        ],
        "object-literal-sort-keys": false,

        "no-any": false
    },
    "rulesDirectory": []
}
tslint --project tsconfig.json # 列出
tslint --fix --project tsconfig.json # 尝试修复

使用

package.json

"scripts": {
    "lintfix": "tslint --fix --project .",
    "lintfix1": "tslintlevel=1 tslint --fix --project .; exit 0",
    "lintfix2": "tslintlevel=2 tslint --fix --project .; exit 0"
}

tslint.json

{
    "extends": [
        "@typeshell/tslint-rules"
    ],
    "jsRules": {},
    "rules": {},
    "rulesDirectory": [],
    "linterOptions": {
        "exclude": [
            "src/**/*.test.ts"
        ]
    }
}

规则分类

  1. 格式类,可自动修复 -> rule set 1,不提示;采用保存即自动格式化/提交自动格式化的设计,确保代码在repo按照统一的代码规范
  2. 不可自动修复 -> 作为第二个rule set,不断提示
  3. 其他未定义的ruleset

规则

  1. 开发环境:增加开发和调试效率,但需要借助tslint来去掉可能的bug
  2. 发布环境:保证代码的clean,去掉重复的代码

Tag

  1. has fixer
  2. novel unfriendly
  3. dev unfriendly

TODO: 采用 microsoft-contribute

https://github.com/Microsoft/tslint-microsoft-contrib

TODO: 不同变量名称的命名规范

TODO: 参考术语体系的命名规范

TODO

部分规则在大部分时候不需强制,但在某些情况下需要。例如 object-literal-sort-keys 这个规则,在大部分时候不使用,但在某些代码却可以作为自动格式化的一种方案。

与tsfmt

多一事不如少一事,虽然tsfmt会参考tslint的配置,但tslint已经起到格式化代码的效用,因此暂定无需引入。 如果我在此事有考虑不周的情况,请告知

https://github.com/vvakame/typescript-formatter