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

lintroll

v1.11.0

Published

privatenumber's linting CLI

Downloads

398

Readme

An opinionated JavaScript, TypeScript, Vue.js, React, etc. linter.

Powered by ESLint that's enhanced with 12 plugins, covering a wide scope including TypeScript, React, Vue.js, JSON & YAML, and even Markdown code blocks.

Features

  • Streamlined syntax: Single quotes, semicolons, tabs, and arrow functions for a clear & intentional coding style.

  • Versatile language support: Lints TypeScript, Vue.js, React, JSON & YAML, and even Markdown code blocks ensuring a wide scope of code.

  • CLI command Comes with a quick and easy-to-use CLI command, which even supports eslint.config.ts.

  • ESLint config: Also exports an ESLint config so you can itegrate it into your own config!

What does the linted code look like?

Checkout the code fixtures from the passing tests here.

Install

npm i -D lintroll

Using as a CLI command

The lintroll command can be used as drop-in replacement for eslint, allowing you to lint your code with this config without any extra configuration.

Lint files in the current directory

lintroll .

Apply auto fix

lintroll . --fix

Lint with caching enabled

lintroll --cache .

Lint only staged files

lintroll --staged .

Specify Node.js files

lintroll --node=./build .

Optional package.json script

Adding it to package.json#scripts allows you to simply run npm run lint (or pnpm lint) without needing to pass in the current directory (.) every time.

This also follows the best practice of documenting available commands in a central place.

  "scripts": {
+   "lint": "lintroll .",
    "build": "..."
    "dev": "..."
  }

Configuration

If you'd like to customize the linting rules further, you can add one of these ESLint config files to your project root and lint will detect them automatically:

  • eslint.config.ts: The typed version of the configuration file, ideal if you are working with TypeScript.

  • eslint.config.js: A standard JavaScript file for ESLint configuration, suitable for projects not using TypeScript.

[!NOTE] When creating your own ESLint config file, you must manually add the pvtnbr config. Read the section below to learn how.

--help

lintroll

by @privatenumber (Hiroki Osame)

Usage:
  lintroll [flags...] <files...>

Flags:
      --cache                          Only check changed files
      --cache-location <string>        Path to the cache file or directory
      --fix                            Automatically fix problems
  -h, --help                           Show help
      --ignore-pattern <string>        Pattern of files to ignore
      --node <string>                  Enable Node.js rules. Pass in a glob to specify files
      --quiet                          Report errors only
      --staged                         Only lint staged files within the files passed in

Using as an ESLint config

To use the eslint command, create a flat configuration file eslint.config.js at your project root.

[!TIP] If you'd like to use TypeScript for your config file (eslint.config.ts), use the lint command from the previous section. The eslint command only supports eslint.config.js.

Simple config

If you want a simple setup with no customization, create the following eslint.config.js:

Module:

export { default } from 'lintroll'

CommonJS:

module.exports = require('lintroll')

Extended config

In eslint.config.js:

Module:

// @ts-check

import { defineConfig, pvtnbr } from 'lintroll'

export default defineConfig([
    {
        // Don't lint these files
        ignores: [
            'tests/fixtures/**/*'
        ]
    },

    // Configure the pvtnbr config
    ...pvtnbr({

        // Indicate Node.js project
        node: true,

        // Indicate Vue.js project (auto-detected by default)
        vue: true
    })

    // Other configs...
])

CommonJS:

// @ts-check

const { defineConfig, pvtnbr } = require('lintroll')

module.exports = defineConfig([
    {
        // Don't lint these files
        ignores: [
            'tests/fixtures/**/*'
        ]
    },

    // Configure the pvtnbr config
    ...pvtnbr({

        // Indicate Node.js project or pass in file paths
        node: true
    })

    // Other configs...
])

[!TIP] If you'd like to type check your eslint.config.js file, you can add // @ts-check to the top.

Linting coverage

This ESLint config comprehensively supports a variety of languages and file types, ensuring coding standards and best practices across your project.

| Language/File Type | Extensions | | ------------------ | -------------------- | | JavaScript | .js, .cjs, .mjs | | Node.js | .cjs, .mjs | | Service Workers | .sw.js, .sw.ts | | TypeScript | .ts, .cts, .mts, .d.ts | | Vue.js | .vue | | React | .jsx, .tsx | | JSON | .json, .json5, .jsonc | | YML | .yml, .yaml | | Markdown | .md |

Integrated plugins

Each plugin in this ESLint configuration targets specific aspects of your code, ensuring quality and consistency.

| Plugin | Focus area | | ------ | ---------- | | eslint-comments | ESLint directive comments | | node | Node.js coding practices | | @typescript-eslint | TypeScript coding Practices | | @stylistic | JavaScript & TypeScript code style | | promise | Promises best practices | | regexp | Regular Expressions best practices | | import | ES6+ Import/Export | | jsonc | JSON, JSON5, and JSONC style | | yml | YAML style | | vue | Vue.js Templates & Scripts | | react | React best practices | | markdown | Markdown embedded code blocks | | no-use-extend-native | Native prototype extensions | | unicorn | Miscellaneous code quality rules | | Custom | Custom rules made for this config |

API

pvtbr(options)

The main config factory. It takes an object of options and returns a config object.

options.node

Type: boolean | string[]

Default: false

Whether to lint Node.js code. When true, it will treat all files as Node.js files. You can also pass in an array of glob patterns to specify which files are Node.js files.

defineConfig(configs)

An identity function to enforce type checking on the config.

configs

Type: FlatConfig | FlatConfig[]

Awesome ESLint configs

Make sure you also check out these awesome ESLint configs. They are a constant source of inspiration for me, and are great alternatives to consider.