Skip to content

Latest commit

 

History

History
196 lines (123 loc) · 6.41 KB

stylelint.md

File metadata and controls

196 lines (123 loc) · 6.41 KB

Stylelint fixer

Stylelint is a modern linter that helps you avoid errors and enforce conventions in your styles.

NPM

If you'd like to install it globally:

npm install -g stylelint

If you'd like install it as a dev dependency of your project:

npm install --save-dev stylelint

Done. See the Stylelint Getting Started guide for more info.

Config

It lives under the stylelint namespace and has the following configurable parameters:

# grumphp.yml
grumphp:
    tasks:
        stylelint:
            bin: node_modules/.bin/stylelint
            triggered_by: [css, scss, sass, less, sss]
            whitelist_patterns:
                - /^resources\/css\/(.*)/
            config: ~
            config_basedir: ~
            ignore_path: ~
            ignore_pattern: ~
            syntax: ~
            custom_syntax: ~
            ignore_disables: ~
            disable_default_ignores: ~
            cache: ~
            cache_location: ~
            formatter: ~
            custom_formatter: ~
            quiet: ~
            color: ~
            report_needless_disables: ~
            report_invalid_scope_disables: ~
            report_descriptionless_disables: ~
            max_warnings: ~
            output_file: ~

bin

Default: null

The path to your stylelint bin executable. Not necessary if stylelint is in your $PATH. Can be used to specify path to project's stylelint over globally installed stylelint.

Note: It is possible to add node_modules/.bin to the grumphp paths in order for it to be automatically discovered as well:

# grumphp.yml
grumphp:
    environment:
        paths:
            - node_modules/.bin

triggered_by

Default: [css, scss, sass, less, sss]

This is a list of extensions which will trigger the Sylelint task.

whitelist_patterns

Default: []

This is a list of regex patterns that will filter files to validate. With this option you can specify the folders containing javascript files and thus skip folders like /tests/ or the /vendor/ directory. This option is used in conjunction with the parameter triggered_by. For example: to whitelist files in resources/css/ (Laravel's CSS directory) and assets/css/ (Symfony's CSS directory) you can use:

whitelist_patterns:
    - /^resources\/css\/(.*)/
    - /^assets\/css\/(.*)/

config

Default: null

Path to a JSON, YAML, or JS file that contains your configuration object. (stylelint.io).

config_basedir

Default: null

Absolute path to the directory that relative paths defining "extends" and "plugins" are relative to. Only necessary if these values are relative paths. (stylelint.io).

ignore_path

Default: null

A path to a file containing patterns describing files to ignore. The path can be absolute or relative to process.cwd(). By default, stylelint looks for .stylelintignore in process.cwd(). (stylelint.io).

ignore_pattern

Default: null

Pattern of files to ignore (in addition to those in .stylelintignore). (stylelint.io).

syntax

Default: null

Specify a syntax. (stylelint.io).

custom_syntax

Default: null

Specify a custom syntax to use on your code. Use this option if you want to force a specific syntax that's not already built into stylelint. (stylelint.io).

ignore_disables

Default: null

Ignore styleline-disable (e.g. /* stylelint-disable block-no-empty */) comments. (stylelint.io).

disable_default_ignores

Default: null

Disable the default ignores. stylelint will not automatically ignore the contents of node_modules. (stylelint.io).

cache

Default: null

Store the results of processed files so that stylelint only operates on the changed ones. By default, the cache is stored in ./.stylelintcache in process.cwd(). (stylelint.io).

cache_location

Default: null

Path to a file or directory for the cache location. (stylelint.io).

formatter / custom_formatter

Default: null

Specify the formatter to format your results. (stylelint.io).

quiet

Default: null

Only register violations for rules with an "error"-level severity (ignore "warning"-level). (stylelint.io).

color

Default: null

Force enabling/disabling of color. (stylelint.io).

report_needless_disables

Default: null

Produce a report to clean up your codebase, keeping only the stylelint-disable comments that serve a purpose. (stylelint.io).

report_invalid_scope_disables

Default: null

Produce a report of the stylelint-disable comments that used for rules that don't exist within the configuration object. (stylelint.io).

report_descriptionless_disables

Default: null

Produce a report of the stylelint-disable comments without a description (stylelint.io).

max_warnings

Default: null

Set a limit to the number of warnings accepted. (stylelint.io).

output_file

Default: null

Path of file to write a report. stylelint outputs the report to the specified filename in addition to the standard output. (stylelint.io).

other settings

Any other stylelint settings should be able to be set through a stylelint config file.