Détail du package

stylelint-find-new-rules

Donov4n8.4kMIT5.0.0

Find stylelint rules that you don't have in your config

readme

stylelint-find-new-rules

Find stylelint rules that are not configured in your stylelint config.

Use this for your own Stylelint shareable configuration to list current configured rules,
all-available rules unused rules, and invalid / deprecated rules.

Acknowledgment

This module is an extended version of stylelint-find-rules, created by Alex Ilyaev.

Installation

Install as a dev dependency of your project:

# - Yarn
yarn add stylelint-find-new-rules --dev

# - NPM
npm install --save-dev stylelint-find-new-rules

Usage

It is expected to be used as local utility, as it needs stylelint and the stylelint-plugins being referred by the stylelint-config file, to be installed. Using it as a global utility, will error out, if stylelint and the stylelint-plugins being referred by the stylelint-config file, are not installed globally.

The intended usage is as an npm script:

{
  ...
  "scripts": {
    "stylelint-find-rules": "stylelint-find-new-rules [options] <file>"
  }
  ...
}

Note: If the <file> argument is not passed, this module will use the same resolution mechanism as Stylelint (cosmiconfig) to find your config data.

Then run it with:

# - Yarn
yarn stylelint-find-rules

# - NPM
npm run --silent stylelint-find-rules

Options

-u, --unused      Find available rules that are not configured.         [default: true]
                  To disable, set to false or use --no-u

-d, --deprecated  Find deprecated configured rules.                     [default: true]
                  To disable, set to false or use --no-d

-i, --invalid     Find configured rules that are no longer available.   [default: true]
                  To disable, set to false or use --no-i

-c, --current     Find all currently configured rules.
-a, --available   Find all available stylelint rules.

API Usage

import stylelintRules from 'stylelint-find-new-rules';

const rules = await stylelintRules('./my-config-file.js');

// `rules` format:
// {
//     used       : [[RULE], [RULE], ...],
//     all        : [[RULE], [RULE], ...],
//     unused     : [[RULE], [RULE], ...],
//     deprecated : [[RULE], [RULE], ...],
//     invalid    : [[RULE], [RULE], ...]
// }
// 
// `[RULE]` format:
// {
//     name         : '[Rule name]',
//     url          : '[URL of the rule's documentation if available or `null`]',
//     isDeprecated : [boolean]
// }

changelog

5.0.0 (2024-01-17)

  • Update dependencies.
  • Add support for Stylelint 16.
  • [BREAKING] Remove support for Stylelint < 16.
  • [BREAKING] This package now require node >= 18.12.0.
  • [BREAKING] This package is now an ESM package. => require('stylelint-find-new-rules') is not supported anymore when using the node API (you should now use the ESM API, see the README).

4.1.2 (2023-09-02)

  • Fix support for "plugin objects" in configurations (#17).

4.1.1 (2023-08-17)

  • Fix peerDependencies declaration for Stylelint 14 (#16, 👏 @thibaudcolas)

4.1.0 (2023-03-18)

  • Add stylelint 15 to supported peer dependency versions (#14).

4.0.0 (2022-03-12)

  • BREAKING: Removed Stylelint 13 support.
  • Improves / Fixes configuration retrieval (#13).
  • Update dependencies.

3.0.4 (2021-11-07)

  • Update dependencies.
  • Update the stylelint rules URL.

3.0.3 (2021-11-07)

  • Add Stylelint 14 to the supported versions.

3.0.2 (2021-08-14)

  • Update dependencies.

3.0.1 (2020-10-03)

  • Update dependencies.
  • Fixes the detection of built-in deprecated rules.

3.0.0 (2020-09-04)

  • Update dependencies.
  • This library now require at least Stylelint 13.
  • Fixes the deprecated rules wrongly identified as "unused rules" (#9).

2.0.0 (2020-05-16)

  • Update dependencies.
  • Add stylelint 13 to supported peer dependency versions.
  • Require Node.js 10.
  • Fixes support for relative / absolute paths in extends and plugins config. keys (#7).
  • Displays the URL to the prettier plugin when its use is detected.

1.2.0 (2019-11-30)

  • Update dev dependencies.
  • Add stylelint 12 to supported peer dependency versions.

1.1.0 (2019-09-24)

  • Update dependencies.
  • Add stylelint 11 to supported peer dependency versions.

1.0.2 (2019-04-19)

  • Update dependencies.
  • Bump stylelint peer dependencies.
  • Show the "up-to-date" message only if there are no unused, invalids or outdated rules.
    (before this version, only unused rules was checked before showing this message)
  • Fix the exit-code when outdated, invalid or unused rules are reported, it will now be non-zero in this situation.

1.0.1 (2018-11-19)

  • Update dependencies.
  • Allow for empty rules in top-level stylelint config. (#1).

1.0.0 (2018-07-03)