You can use stylelint on the command line. For example:
npx stylelint "**/*.css"
Use npx stylelint --help to print the CLI documentation.
In addition to the standard options, the CLI accepts:
--allow-empty-input, --aeiThe process exits without throwing an error when glob pattern matches no files.
--cache-locationPath to a file or directory for the cache location. More info about this option in standard options.
--cacheStore 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(). More info about this option in standard options.
--color, --no-colorForce enabling/disabling of color.
--config-basedirAbsolute path to the directory that relative paths defining “extends” and “plugins” are relative to. Only necessary if these values are relative paths. More info about this option in standard options.
--configPath to a JSON, YAML, or JS file that contains your configuration object. More info about this option in standard options.
--custom-syntaxSpecify 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. More info about this option in standard options.
--disable-default-ignores, --diDisable the default ignores. stylelint will not automatically ignore the contents of node_modules. More info about this option in standard options.
--fixAutomatically fix, where possible, violations reported by rules. More info about this option in standard options.
--formatter, -f | --custom-formatterSpecify the formatter to format your results. More info about this option in standard options.
--ignore-disables, --idIgnore styleline-disable (e.g. /* stylelint-disable block-no-empty */) comments. More info about this option in standard options.
--ignore-path, -iA 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(). More info about this option in standard options.
--ignore-pattern, --ipPattern of files to ignore (in addition to those in .stylelintignore).
--max-warnings, --mwSet a limit to the number of warnings accepted. More info about this option in standard options.
--output-file, -oPath of file to write a report. stylelint outputs the report to the specified filename in addition to the standard output.
--print-configPrint the configuration for the given path. stylelint outputs the configuration used for the file passed.
--quiet, -qOnly register violations for rules with an “error”-level severity (ignore “warning”-level).
--report-descriptionless-disables, --rddProduce a report of the stylelint-disable comments without a description. More info about this option in standard options.
--report-invalid-scope-disables, --risdProduce a report of the stylelint-disable comments that used for rules that don't exist within the configuration object. More info about this option in standard options.
--report-needless-disables, --rdProduce a report to clean up your codebase, keeping only the stylelint-disable comments that serve a purpose. More info about this option in standard options.
--stdin-filenameA filename to assign the input. More info about this option in standard options.
--stdinAccept stdin input even if it is empty.
--syntax, -sSpecify a syntax. More info about this option in standard options.
--version, -vShow the currently installed version of stylelint.
The CLI expects input as either a file glob or process.stdin. It outputs formatted results into process.stdout.
Be sure to include quotation marks around file globs.
Recursively linting all .css files in the foo directory:
stylelint "foo/**/*.css"
Linting all .css, .scss, and .sass files:
stylelint "**/*.{css,scss,sass}"
Linting stdin:
echo "a { color: pink; }" | stylelint
Linting all .css files except those within docker subfolders, using negation in the input glob:
stylelint "**/*.css" "!**/docker/**"
Caching processed .scss files foo directory:
stylelint "foo/**/*.scss" --cache --cache-location "/Users/user/.stylelintcache/"
Linting all .css files in the foo directory, then writing the output to myTestReport.txt:
stylelint "foo/*.css" --output-file myTestReport.txt
Using bar/mySpecialConfig.json as config to lint all .css files in the foo directory and any of its subdirectories:
stylelint "foo/**/*.css" --config bar/mySpecialConfig.json
Recursively linting all .css files in the foo directory using a custom syntax:
stylelint "foo/**/*.css" --customSyntax path/to/my-custom-syntax.js
Ensure output on successful runs:
stylelint -f verbose "foo/**/*.css"
The CLI can exit the process with the following exit codes:
1 - something unknown went wrong2 - there was at least one rule violation or CLI flag error78 - there was some problem with the configuration file