javascriptcsslintstylelint

How to add ignorefiles for specific rules in stylelint config js


Hi want to ignore certain files for a specific rule in style lint config js like below

'color-named': [
        'never', {
            'ignore': [ 'library/styles/**/*.css', 'components/**/styles/variable.css' ]
        }
    ],

However this is not working, Any suggetions how to do that ?


Solution

  • There is no ignore configuration option which accepts globs in stylelint.

    I believe you have two choices:

    1. Add /* stylelint-disable color-named */ to the beginning of the appropriate files (ref).
    2. Create two separate configurations: one with the color-named rule turned on and one with it turned off. Then run stylelint twice with different globs, using the --config option to select the appropriate config. You can make use of extendable configs to remove duplication within the configs e.g. have a base config and a strict config that extends the base config and turns on the color-named rule (ref).