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

lintgpt

v0.1.0

Published

LintGPT scans your code for bugs using AI.

Downloads

15

Readme

LintGPT

LintGPT scans your code for bugs using AI.

Status: Alpha ⚡

Features

  • Discover bugs in source code that can be difficult to detect with other tools.
  • Automatically fix problems using the --fix option.
  • Smart caching to only make OpenAI requests for files that have changed.
  • Works with many common programming languages.

Setup

  1. Run npm install lintgpt to install.
  2. Make sure you have an $OPENAI_API_KEY environment variable which you can generate here.

Example

Below is an example User class in TypeScript. It passes type-checking, and there are no eslint style errors. However, this program still contains a few bugs:

export class User {
  constructor (readonly firstName: string, readonly lastName: string, readonly age: number) {
  }

  getFirstName (): string {
    return this.firstName
  }

  getLastName (): string {
    return this.firstName
  }

  getFullName (): string {
    return this.firstName + this.lastName
  }

  isLegalDrinkingAge (): boolean {
    return this.age > 10
  }
}

Using lintgpt can understand intent and catch logic errors that are difficult to detect with other tools:

$ npx lintgpt user.ts

✘ getLastName method returns firstName instead of lastName

    user.ts:10:12
      10 │     return this.firstName
         │            ~~~~~~~~~~~~~~

✘ getFullName method does not include a space between firstName and lastName

    user.ts:14:12
      14 │     return this.firstName + this.lastName
         │            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

✘ isLegalDrinkingAge method checks if age is greater than 10, not the legal drinking age in most countries

    user.ts:18:23
      18 │     return this.age > 10
         │                       ~~

Found 3 problems in user.ts.

You can even pass --fix to automatically apply suggested changes to your files.

$ npx lintgpt user.ts --fix

✔ getLastName method returns firstName instead of lastName

    user.ts:10:12
      10 │     return this.firstName
         │            ~~~~~~~~~~~~~~
    Fixed:
         │     return this.lastName

✔ getFullName method does not include a space between firstName and lastName

    user.ts:14:12
      14 │     return this.firstName + this.lastName
         │            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Fixed:
         │     return this.firstName + ' ' + this.lastName

✔ isLegalDrinkingAge method checks if age is greater than 10, not the legal drinking age in most countries

    user.ts:18:23
      18 │     return this.age > 10
         │                       ~~
    Fixed:
         │     return this.age > 21

For more options, see lintgpt --help.

Caveats

GPT isn't perfect, and frequently reports things that are not errors, or suggests incorrect fixes. Take care when using the --fix option to review any changes.

A good way to think about LintGPT is as a team of highschool interns who just completed their first computer science course. Have them review your code and they might find a few things, but take their output with a grain of salt.

Please also be aware that LintGPT sends the files you pass it to OpenAI. Don't use it in files containing sensitive information.