stylelint

A mighty, modern CSS linter and fixer that helps you avoid errors and enforce consistent conventions in your stylesheets.

Version

9.10.1

Runtime

Node.js Versions

Supported Languages

CSS HTML Markdown

Official Documentation

https://stylelint.io/

YAML Configuration

stylelint:

  • input:

    Patterns to include in execution and reports.

  • ignore:

    Patterns to exclude from execution and reports.

  • auto-fix:

    true/false

  • config-file:

    Alias of --config option.

  • machine:

    • cpu:

      Amount of CPU. The default machine has 0.75 CPU with 2880 MiB RAM.

  • options:

    Below is the list of options that are supported:

    --config
    
      Path to a specific configuration file (JSON, YAML, or CommonJS), or the
      name of a module in node_modules that points to one. If no --config
      argument is provided, stylelint will search for configuration files in
      the following places, in this order:
        - a stylelint property in package.json
        - a .stylelintrc file (with or without filename extension:
          .json, .yaml, .yml, and .js are available)
        - a stylelint.config.js file exporting a JS object
      The search will begin in the working directory and move up the directory
      tree until a configuration file is found.
    
    --config-basedir
    
      An absolute path to the directory that relative paths defining "extends"
      and "plugins" are *relative to*. Only necessary if these values are
      relative paths.
    
    --ignore-path, -i
    
      Path to a file containing patterns that describe files to ignore. The
      path can be absolute or relative to process.cwd(). By default, stylelint
      looks for .stylelintignore in process.cwd().
    
    --ignore-pattern, --ip
    
      Pattern of files to ignore (in addition to those in .stylelintignore)
    
    --syntax, -s
    
      Specify a non-standard syntax. Options: "scss", "sass", "less", "sugarss".
      If you do not specify a syntax, non-standard syntaxes will be
      automatically inferred by the file extensions .scss, .sass, .less, and .sss.
    
    --custom-syntax
    
      Module name or path to a JS file exporting a PostCSS-compatible syntax.
    
    --ignore-disables, --id
    
      Ignore styleline-disable comments.
    
    --disable-default-ignores, --di
    
      Allow linting of node_modules and bower_components.
    
    --quiet, -q
    
      Only register warnings for rules with an "error"-level severity (ignore
      "warning"-level).
    
  • thresholds:

    • num-issues:

      No tool specific severity levels are available.

  • experimental:

    • incremental:

      true/false

      Note: The incremental analysis is disabled if any kinds of configuration files are changed. The files recognized as configuration files are as follows:

      • Configuration files:
        • Files specified in config-file field
        • Files specified to --config option
        • If none of the above configuration files are found:
          • **/package.json, **/.stylelintrc, **/.stylelintrc.json, **/.stylelintrc.yaml, **/.stylelintrc.yml, **/.stylelintrc.js, **/stylelint.config.js
      • Ignore files:
        • Files specified to --ignore-path option
        • If none of the above ignore files are found:
          • **/.stylelintignore
      • Syntax files:
        • Files specified to --custom-syntax option

      Note: The incremental analysis is disabled if external dependencies are required. See Resolving Dependencies about how the dependencies are resolved.

YAML Examples

  • With default options:

    inspecode:
      stylelint: default
    
  • With custom machine:

    inspecode:
      stylelint:
        machine:
          cpu: 1.5 # 1.5 CPU, 5760 MiB RAM
    
  • With custom options:

    inspecode:
      stylelint:
        options:
          --ignore-pattern:
            - scss/external/**
          --syntax: sass
    
  • With a configuration file:

    inspecode:
      stylelint:
        config-file: ./.stylelintrc
    

    The above configuration is equivalent to:

    inspecode:
      stylelint:
        options:
          --config: ./.stylelintrc
    

Configuration File Detection

If no configuration files are specified via config-file or options field, Inspecode first let stylelint find configuration files in your repository. See https://stylelint.io/user-guide/configuration/#loading-the-configuration-object about how stylelint looks for configuration files.

In addition, if stylelint cannot find any configuration files, Inspecode also walks the file tree in lexical order in your repository to find one of the following configuration files and specifies the file first found to stylelint automatically via --config option.

  • a package.json with stylelint property
  • a .stylelintrc file
    • .stylelintrc.json
    • .stylelintrc.yaml
    • .stylelintrc.yml
    • .stylelintrc.js
  • stylelint.config.js

Note: Inspecode ignores specific configuration files while searching. See Configuration > Tool Configuration > Field: config-file for detail.

If the configuration file detected by Inspecode is not the one you want to use or you do not want to use any configuration files, you can disable Inspecode from detecting configuration files by explicitly setting an empty string to config-file field like below:

inspecode:
  stylelint:
    config-file: ""

Resolving Dependencies

Although stylelint can work with various plugins, Inspecode does not have any stylelint plugins installed by default. But Inspecode searches your repository for package.json files enabling stylelint and runs npm install at each directory where package.json is placed in order to install its plugins at runtime, so you can use any stylelint plugins.

As of now, Inspecode can install:

  • packages available to the public on npm
  • packages provided from your private repositories which:
    • belong to the same GitHub organization or Bitbucket team as the repository on which stylelint runs
    • have been already registered to Inspecode
    • can be accessed via http://<hostname>/<path>, https://<hostname>/<path>, ssh://git@<hostname>/<path> or git@<hostname>:<path>

results matching ""

    No results matching ""