3.0.17 • Published 5 months ago

@anolilab/lint-staged-config v3.0.17

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

Package that contains shareable configuration for lint-staged / nano-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 / nano-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 / nano-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 nano-staged
// or
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 nano-staged
// or
yarn add -D @anolilab/lint-staged-config lint-staged

Optional:

yarn add -D husky is-ci
pnpm add -D @anolilab/lint-staged-config nano-staged
// or
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 or .nano-staged.js, we can create the file for you after installing @anolilab/lint-staged-config, call pnpm lint-stage-config:install.

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

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

The content of the .lintstagedrc.js or .nano-staged.js should look like this:

// or

import { defineConfig } from "@anolilab/lint-staged-config";

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

module.exports = defineConfig();

export default defineConfig();

Config

You can configure @anolilab/lint-staged-config options inside the defineConfig function.

// or

import { defineConfig } from "@anolilab/lint-staged-config";

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

module.exports = defineConfig({
    // Add your configuration here
});

export default defineConfig({
    // Add your configuration here
});

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"

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

./node_modules/.bin/lint-staged --verbose --concurrent false

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

or with nano-staged:

#!/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

./node_modules/.bin/nano-staged

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

Our package includes a lint-stage-config:install command to add the pre-commit, common.sh, prepare-commit-msg hooks to your.husky` folder.

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

3.0.12

5 months ago

3.0.4

5 months ago

3.0.13

5 months ago

3.0.3

5 months ago

3.0.10

5 months ago

3.0.2

5 months ago

3.0.11

5 months ago

3.0.1

5 months ago

3.0.16

5 months ago

3.0.8

5 months ago

3.0.17

5 months ago

3.0.7

5 months ago

3.0.14

5 months ago

3.0.6

5 months ago

3.0.15

5 months ago

3.0.5

5 months ago

3.0.0

5 months ago

3.0.9

5 months ago

2.1.7

2 years ago

2.1.2

2 years ago

2.1.4

2 years ago

2.1.3

2 years ago

2.1.6

2 years ago

2.1.5

2 years ago

2.1.1

2 years ago

2.1.0

2 years ago

2.0.15

2 years ago

2.0.14

2 years ago

2.0.13

2 years ago

2.0.12

2 years ago

2.0.11

2 years ago

2.0.10

2 years ago

2.0.9

2 years ago

2.0.8

2 years ago

2.0.7

2 years ago

2.0.6

2 years ago

2.0.5

2 years ago

2.0.4

2 years ago

2.0.3

2 years ago

2.0.2

2 years ago

2.0.1

2 years ago

2.0.0

2 years ago

1.1.2

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago