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

tslint-config-gravity

v1.0.3

Published

This is the tslint configuration that we use at Gravity Payments. Follow the steps below to add this to any TypeScript project.

Downloads

622

Readme

Gravity Payment's tslint config

This is the tslint configuration that we use at Gravity Payments. Follow the steps below to add this to any TypeScript project.

Using in a TS project

make sure you have all the peer dependencies installed

$ yarn add --dev typescript tslint

install this project as a dependency

$ yarn add --dev tslint-config-gravity

add a tslint.json file in the root dir that looks like this

{
    "extends": "tslint-config-gravity"
}

this tells tslint to grab the tslint.json file at ./node_modules/tslint-config-gravity

make sure you have tslint and typescript installed globally

$ npm install -g tslint typescript

now run the linter

$ tslint --project ./tsconfig.json

strictNullChecks

The strict-type-predicates tslint rule requires that your tsconfig.json file has the strictNullChecks prop set to true. To do this, make sure your tsconfig.json file has the following prop. Here is some more info on this.

{
    "compilerOptions": {
        "strictNullChecks": true
    }
}

Auto fixing

tslint has the option to auto fix some of the simpler checks. To do this, simply add the --fix flag when you run the tslint command.

$ tslint --project tsconfig.json --fix

Using with webpack

You can setup webpack to run your code through tslint during the bundle process. Errors will not prevent your code from being bundled, but will provide warnings in the console. To set this up follow the instructions below.

install the tslint-webpack-plugin

$ yarn add --dev tslint-webpack-plugin

edit your webpack config file to include the following

const TSLintPlugin = require('tslint-webpack-plugin');

module.exports = {
    plugins: [
        new TSLintPlugin({
            files: ['./path/to/ts/files/**/*.ts', './another/path/**.tsx'],
            project: './tsconfig.json'
        })
    ]
}

then run webpack. you will see warnings in terminal after the webpack output like...

Hash: eb3f77073bfc7eb5a3d3
Version: webpack 3.5.5
Child index:
    Hash: eb3f77073bfc7eb5a3d3
    Time: 3503ms
        Asset     Size  Chunks                    Chunk Names
    bundle.js  1.17 MB       0  [emitted]  [big]  main
       [7] ./node_modules/react/react.js 56 bytes {0} [built]
      [10] ./node_modules/mobx/lib/mobx.module.js 142 kB {0} [built]
      [12] ./node_modules/mobx-react/index.js 29.7 kB {0} [built]
      [20] ./node_modules/react/lib/React.js 5.08 kB {0} [built]
      [29] ./src/actions/index.ts 2.08 kB {0} [built]
      [30] ./node_modules/@trevorhanus/reactx/dist/index.js 650 bytes {0} [built]
      [39] ./node_modules/@trevorhanus/reactx/dist/router/Router.js 8.63 kB {0} [built]
      [42] ./node_modules/react-dom/index.js 59 bytes {0} [built]
     [102] multi ./src/index.tsx 28 bytes {0} [built]
     [103] ./src/index.tsx 695 bytes {0} [built]
     [215] ./src/routes/routes.ts 1.65 kB {0} [built]
     [233] ./src/components/App.tsx 698 bytes {0} [built]
     [238] ./src/components/Auth.tsx 642 bytes {0} [built]
     [242] ./src/stores/Store.ts 1.27 kB {0} [built]
     [243] ./src/stores/TodoStore.ts 4.53 kB {0} [built]
        + 230 hidden modules

[tslint-plugin] Starting linter in separate process...

/Users/thanus/dev/reactx-todo/src/actions/index.ts
[Error 35,9]: Expression is always true. (strict-type-predicates)

/Users/thanus/dev/reactx-todo/src/routes/routes.ts
[Error 36,21]: Expression is always true. (strict-type-predicates)
[Error 36,46]: Expression is always true. (strict-type-predicates)

/Users/thanus/dev/reactx-todo/src/components/AddTodoControl.tsx
[Error 19,13]: Expression is always true. (strict-type-predicates)

/Users/thanus/dev/reactx-todo/src/components/TodoFooter.tsx
[Error 17,24]: Expression is always true. (strict-type-predicates)
[Error 29,55]: Use '=== undefined' instead. (strict-type-predicates)

[tslint-plugin] Linting complete.

Setting up vscode to run tslint

You can configure vscode to run tslint while you are editing code.

  • open the extensions window shift+command+x
  • search for 'tslint' and install the TSLint for Visual Studio Code extension
  • restart VSCode and it should be linting!