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

@anolilab/lint-staged-config

v2.1.7

Published

Shareable Lint-Staged Config for any project.

Downloads

1,841

Readme

Package that contains shareable configuration for lint-staged — a popular tool for running linters on staged Git files.

And optionally for husky — a popular choice for configuring git hooks.

typescript-image npm-image license-image



Simplify your project setup with our comprehensive collection of preconfigured configuration files. Designed for effortless integration, these ready-to-use files can be seamlessly imported into your projects. These functions streamline the utilization of lint-staged alongside popular tools such as ESLint, Prettier, StyleLint and SecretLint.

Say goodbye to complex configurations and enjoy a smoother development experience with our all-inclusive package.

Purpose

  • Enhance your development workflow with hassle-free and readily shareable lint-staged configuration files.
  • These files empower developers to maintain a uniform coding style and detect prevalent errors even before they are added to the source control system.
  • Additionally, our inclusive helper module offers convenient utility functions that seamlessly integrate lint-staged with popular linting and formatting tools.

Install

npm install --dev-save @anolilab/lint-staged-config lint-staged

Optional:

npm install --dev-save husky is-ci
yarn add -D @anolilab/lint-staged-config lint-staged

Optional:

yarn add -D husky is-ci
pnpm add -D @anolilab/lint-staged-config lint-staged

Optional:

pnpm add -D husky is-ci

Usage

If you don’t have a .lintstagedrc.js, we will create the file for you after installing @anolilab/lint-staged-config.

If you already have a .lintstagedrc.js, then you can extend the .lintstagedrc.js, with @anolilab/lint-staged-config.

Note: If the script detects an existing .lintstagedrc.js file, it will not overwrite it.

Note: It can happen that the postinstall script don't run, then you have to add the .lintstagedrc.js manually.

The content of the .lintstagedrc.js should look like this:

const config = require("@anolilab/lint-staged-config");

module.exports = {
    ...config,
};

Config

You can configure @anolilab/lint-staged-config options with your package.json file.

Add this property to your package.json:

{
    anolilab: {
        "lint-staged-config": {
            // ...options
        },
    },
}

typescript

Type: object

Options:

  • exclude - Exclude files from tsc linting. Provide the path to the tsconfig.json file.
    • Type: string[]
    • Default: []

Example using package.json:

{
    "anolilab": {
        "lint-staged-config": {
            "typescript": {
                // ...options
            }
        }
    }
}

eslint

Type: object

Options:

  • cache - Enable or disable caching.
    • Type: boolean
  • config - Change path to eslint config.
    • Type: string
  • "fix-type"
    • Type: string[]
  • "max-warnings"
    • Type: number | string | false
  • rules - Override rules from eslint config.
    • Type: string[]

Example using package.json:

{
    "anolilab": {
        "lint-staged-config": {
            "eslint": {
                // ...options
            }
        }
    }
}

Configuration

The default configuration, automatically adds the following linting and formatting tools, if the needed dependencies are installed.

All this tools configuration are exported at @anolilab/lint-staged-config/group/... and can be used to extend your configuration, without including the auto config.

Husky

If you want to use husky to run the lint-staged script, you can use the following configuration.

Adding the following script to your root package.json file makes it easier to run the husky command:

pnpm pkg set scripts.prepare="is-ci || husky install || exit 0"

For npm users, replace pnpm with npm in the above command.

This script will install husky only if it is not running in a CI environment.

After that you can find a .husky folder in your root directory, with a pre-commit (if not please create it) file.

The file content can look like this:

#!/bin/sh

. "$(dirname "$0")/_/husky.sh"

# The hook should exit with non-zero status after issuing
# an appropriate message if it wants to stop the commit.

echo --------------------------------------------
echo Starting Git hook: pre-commit

pnpx lint-staged --verbose --concurrent false

echo Finished Git hook: pre-commit
echo --------------------------------------------

Our package includes a postinstall script to automatically add the pre-commit, common.sh, prepare-commit-msg hooks to your .husky` folder.

Note: It can be that the postinstall script don't run, then you have to add the hooks manually.

If commitzen is installed, the prepare-commit-msg hook with predefined content will be added to your .husky folder.

Supported Node.js Versions

Libraries in this ecosystem make the best effort to track Node.js’ release schedule. Here’s a post on why we think this is important.

Contributing

If you would like to help take a look at the list of issues and check our Contributing guild.

Note: please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.

Credits

License

The anolilab javascript-style-guide is open-sourced software licensed under the MIT license