GithubHelp home page GithubHelp logo

donov4n / stylelint-find-new-rules Goto Github PK

View Code? Open in Web Editor NEW
14.0 2.0 4.0 801 KB

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

Home Page: https://npm.im/stylelint-find-new-rules

License: MIT License

JavaScript 100.00%
stylelint

stylelint-find-new-rules's Introduction

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]
// }

stylelint-find-new-rules's People

Contributors

alexilyaev avatar axten avatar donov4n avatar ntwb avatar thibaudcolas avatar vincentbriglia avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

stylelint-find-new-rules's Issues

CLI should use a non-zero exit code if rules are outdated

At the moment the CLI stops with an exit code of 0 regardless of what outdated / invalid / unused rules it found.

I would like to use this tool so I know exactly what rules have been introduced in the selection of plugins I'm using, and what might be changing in plugins. It would be nice to be able to do this in CI, so the build of my config breaks if an outdated / invalid rule is used โ€“ย a non-zero exit code would be a nice way to do that.

In the meantime I'm manually checking the output from the tool:

stylelint-find-new-rules src/unused.js --unused --deprecated --invalid | tee /dev/tty | grep 'All rules are up-to-date!' -c -q

This works, but feels unnecessarily complex.

Why not collaborate?

Hi @Donov4n,

I created stylelint-find-rules

It's really cool that you took it a step forward.
I was wondering what was the reasoning behind making a new package instead of trying to collaborate on the exiting one (besides me not being so active on it)?

Ignore `deprecated` rules

I'm using the stylelint-find-new-rules script to find all rules which are currently not configured.
In Stylelint v15, all stylistic rules are marked as deprecated, so I've removed them from my configuration.

Now stylelint-find-new-rules lists all of them as [UNUSED] Available rules that are not configured.
Is it possible through the command line tool to show all unused rules, which are NOT marked as deprecated? Because it does not make sense to add deprecated rules.

--no-d has no effect.

Support for Stylelint v15

Similar to #12, can this package be updated to support Stylelint v15?

https://github.com/stylelint/stylelint/blob/main/docs/migration-guide/to-15.md

npm ERR! Found: [email protected]
npm ERR! node_modules/stylelint
npm ERR!   dev stylelint@"^15.2.0" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer stylelint@"^14" from [email protected]
npm ERR! node_modules/stylelint-find-new-rules
npm ERR!   dev stylelint-find-new-rules@"*" from the root project
npm ERR! 
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.

Doesn't work with `extends: [stylelint-prettier/recommended]`

[adrian@blackhole:~/dev/indico/src:style-lint *$]> npx stylelint-find-new-rules
npx: installed 68 in 2.488s
Error: Cannot use import statement outside a module

This happens during _gatherPluginsRules(extendedConfig); if I skip it for the stylelint-prettier/recommended extends entry everything works fine; same if I remove this particular extend from my config.

"Error: The "id" argument must be of type string. Received [Object: null prototype] [Module]" on `plugin objects`

stylelint allows to use

[...] either plugin objects or "locaters" identifying the plugins [...]

See https://stylelint.io/user-guide/configure/#plugins

If I'm using plugin objects (either directly or by importing them using require/dynamic imports), stylelint-find-new-rules stops with the error:

Error: The "id" argument must be of type string. Received [Object: null prototype] [Module]

The problem is here:

https://github.com/Donov4n/stylelint-find-new-rules/blob/5c2e6813775da19689a5656d45e71c4ce0712e54/lib/utils/rules.js#L14C24-L14C24

were you don't check if the plugin is a "locater" or a plugin object.

Stylelint v14 support

It would be great if this code could be updated to support Stylelint v14, because right now npm returns this error on installation:

npm ERR! Found: [email protected]
npm ERR! node_modules/stylelint
npm ERR! stylelint@"14.0.1" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer stylelint@"^13" from [email protected]
npm ERR! node_modules/stylelint-find-new-rules
npm ERR! dev stylelint-find-new-rules@"3.0.2" from the root project

Doesn't work with local configuration

We inherit from a local file, which causes an error with stylelint-find-new-rules:

$ stylelint-find-new-rules
Error: Invalid or unexpected token

Here's our .stylelintrc.yml:

extends:
  - stylelint-config-standard-scss
  - ./.stylelint_todo.yml
And here's our `.stylelint_todo.yml`:
# This configuration was generated by `exe/stylelint_autogen`
# on 2022-03-02 23:08:55 UTC.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.

overrides:

  # Offense count: 11
  - rules: { 'at-rule-empty-line-before': null }
    files:
    - app/assets/stylesheets/application.scss
    - app/assets/stylesheets/jquery_ui.scss
    - app/assets/stylesheets/legacy.scss

  # Offense count: 2
  - rules: { 'block-closing-brace-empty-line-before': null }
    files:
    - app/assets/stylesheets/refresh/_layouts.scss
    - app/assets/stylesheets/refresh/pages/_campaigns.scss

  # Offense count: 1
  - rules: { 'block-closing-brace-newline-before': null }
    files:
    - app/assets/stylesheets/refresh/pages/_steps.scss

  # Offense count: 5
  - rules: { 'declaration-block-no-redundant-longhand-properties': null }
    files:
    - app/assets/stylesheets/refresh/_layouts.scss
    - app/assets/stylesheets/refresh/pages/_console.scss
    - app/assets/stylesheets/refresh/pages/_forms_team.scss
    - app/assets/stylesheets/refresh/pages/_inbox.scss

  # Offense count: 1
  - rules: { 'declaration-block-trailing-semicolon': null }
    files:
    - app/assets/stylesheets/refresh/pages/_steps.scss

  # Offense count: 4
  - rules: { 'declaration-colon-newline-after': null }
    files:
    - app/assets/stylesheets/components/_fields.scss
    - app/assets/stylesheets/doc_editor/_context_menu.scss
    - app/assets/stylesheets/vendor/_fonts.scss

  # Offense count: 2
  - rules: { 'font-family-name-quotes': null }
    files:
    - app/assets/stylesheets/refresh/pages/_campaigns.scss

  # Offense count: 2
  - rules: { 'font-family-no-missing-generic-family-keyword': null }
    files:
    - app/assets/stylesheets/refresh/pages/_campaigns.scss

  # Offense count: 16
  - rules: { 'indentation': null }
    files:
    - app/assets/stylesheets/components/_fields.scss
    - app/assets/stylesheets/doc_editor/_context_menu.scss
    - app/assets/stylesheets/vendor/_fonts.scss

  # Offense count: 73
  - rules: { 'max-empty-lines': null }
    files:
    - app/assets/stylesheets/legacy/variables/_bootstrap.scss
    - app/assets/stylesheets/refresh/pages/_campaigns.scss
    - app/assets/stylesheets/refresh/pages/_test_approvers.scss
    - app/assets/stylesheets/refresh/variables/_bootstrap.scss

  # Offense count: 19
  - rules: { 'max-line-length': null }
    files:
    - app/assets/stylesheets/legacy/variables/_bootstrap.scss
    - app/assets/stylesheets/mailer.css.scss
    - app/assets/stylesheets/refresh/variables/_bootstrap.scss
    - app/assets/stylesheets/vendor/_fonts.scss

  # Offense count: 1
  - rules: { 'no-extra-semicolons': null }
    files:
    - app/assets/stylesheets/refresh/pages/_campaigns.scss

  # Offense count: 1
  - rules: { 'property-no-unknown': null }
    files:
    - app/assets/stylesheets/mailer.css.scss

  # Offense count: 3
  - rules: { 'property-no-vendor-prefix': null }
    files:
    - app/assets/stylesheets/admin.scss
    - app/assets/stylesheets/mailer.css.scss

  # Offense count: 25
  - rules: { 'scss/at-extend-no-missing-placeholder': null }
    files:
    - app/assets/stylesheets/doc_editor/_toolbar.scss
    - app/assets/stylesheets/legacy.scss
    - app/assets/stylesheets/legacy/bootstrap_with_overrides.scss
    - app/assets/stylesheets/refresh/extensions/_bootstrap.scss
    - app/assets/stylesheets/refresh/overrides/_bootstrap.scss
    - app/assets/stylesheets/refresh/pages/_responses.scss
    - app/assets/stylesheets/wizard.scss

  # Offense count: 1
  - rules: { 'scss/at-import-partial-extension': null }
    files:
    - app/assets/stylesheets/jquery_ui.scss

  # Offense count: 1
  - rules: { 'scss/at-mixin-argumentless-call-parentheses': null }
    files:
    - app/assets/stylesheets/group_wizard/_reviewer_column.scss

  # Offense count: 88
  - rules: { 'scss/comment-no-empty': null }
    files:
    - app/assets/stylesheets/actiontext.scss
    - app/assets/stylesheets/legacy/variables/_bootstrap.scss
    - app/assets/stylesheets/refresh/variables/_bootstrap.scss

  # Offense count: 274
  - rules: { 'scss/dollar-variable-colon-space-after': null }
    files:
    - app/assets/stylesheets/legacy/variables/_bootstrap.scss
    - app/assets/stylesheets/refresh/variables/_bootstrap.scss

  # Offense count: 1
  - rules: { 'scss/dollar-variable-empty-line-before': null }
    files:
    - app/assets/stylesheets/wizard.scss

  # Offense count: 437
  - rules: { 'scss/double-slash-comment-whitespace-inside': null }
    files:
    - app/assets/stylesheets/actiontext.scss
    - app/assets/stylesheets/components/_fields.scss
    - app/assets/stylesheets/form_filler/_tooltips.scss
    - app/assets/stylesheets/legacy/variables/_bootstrap.scss
    - app/assets/stylesheets/legacy/variables/_colors.scss
    - app/assets/stylesheets/refresh/variables/_bootstrap.scss

  # Offense count: 15
  - rules: { 'scss/no-global-function-names': null }
    files:
    - app/assets/stylesheets/legacy/variables/_bootstrap.scss
    - app/assets/stylesheets/legacy/variables/_colors.scss
    - app/assets/stylesheets/refresh/pages/_inbox.scss
    - app/assets/stylesheets/refresh/variables/_bootstrap.scss

  # Offense count: 4
  - rules: { 'selector-attribute-quotes': null }
    files:
    - app/assets/stylesheets/refresh/extensions/_bootstrap.scss
    - app/assets/stylesheets/refresh/pages/_header.scss
    - app/assets/stylesheets/tree/_search_results.scss

  # Offense count: 3
  - rules: { 'selector-id-pattern': null }
    files:
    - app/assets/stylesheets/tree/campaigns/_new.scss

  # Offense count: 2
  - rules: { 'selector-no-vendor-prefix': null }
    files:
    - app/assets/stylesheets/components/_html_form_validation.scss
    - app/assets/stylesheets/tree/_main.scss

  # Offense count: 1
  - rules: { 'selector-pseudo-class-no-unknown': null }
    files:
    - app/assets/stylesheets/admin.scss

  # Offense count: 12
  - rules: { 'value-keyword-case': null }
    files:
    - app/assets/stylesheets/legacy/variables/_bootstrap.scss
    - app/assets/stylesheets/refresh/variables/_bootstrap.scss

  # Offense count: 1
  - rules: { 'value-list-comma-newline-after': null }
    files:
    - app/assets/stylesheets/vendor/_fonts.scss

  # Offense count: 1
  - rules: { 'value-no-vendor-prefix': null }
    files:
    - app/assets/stylesheets/refresh/pages/_routing.scss

rules:

  # Offense count: 24
  'alpha-value-notation': null

  # Offense count: 26
  'color-function-notation': null

  # Offense count: 76
  'declaration-empty-line-before': null

  # Offense count: 79
  'no-descending-specificity': null

  # Offense count: 88
  'number-leading-zero': null

  # Offense count: 159
  'scss/double-slash-comment-empty-line-before': null

  # Offense count: 277
  'scss/operator-no-unspaced': null

  # Offense count: 214
  'selector-class-pattern': null

  # Offense count: 275
  'string-quotes': null

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.