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 thestylelint-plugins
being referred by thestylelint-config
file, to be installed. Using it as a global utility, will error out, ifstylelint
and thestylelint-plugins
being referred by thestylelint-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]
// }