Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve CLI help #6783

Merged
merged 2 commits into from
Apr 15, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/ten-bees-accept.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"stylelint": patch
---

Fixed: CLI help improvements
134 changes: 70 additions & 64 deletions lib/__tests__/__snapshots__/cli.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -9,103 +9,105 @@ exports[`CLI --help 1`] = `
Input: Files(s), glob(s), or nothing to use stdin.

If an input argument is wrapped in quotation marks, it will be passed to
globby for cross-platform glob support. node_modules are always ignored.
globby for cross-platform glob support. "node_modules" are always ignored.
You can also pass no input and use stdin, instead.

Options:

--config, -c
--config, -c <path_or_module>

A path to a specific configuration file (JSON, YAML, or CommonJS), or a
module name in "node_modules" that points to one. If no 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", ".js", and ".cjs" are available)
- a "stylelint.config.js" file exporting a JS object

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
--config-basedir <path>

An absolute path to the directory that relative paths defining "extends",
"plugins", and "customSyntax" are *relative to*. Only necessary if these
values are relative paths.

--print-config
--print-config <path>

Print the configuration for the given path.

--ignore-path, -i
--ignore-path, -i <path>

Path to a file containing patterns that describe files to ignore. The
path can be absolute or relative to process.cwd(). You can repeat the
A path to a file containing patterns that describe files to ignore. The
path can be absolute or relative to "process.cwd()". You can repeat the
option to provide multiple paths. By default, Stylelint looks for
.stylelintignore in process.cwd().
".stylelintignore" in "process.cwd()". Multiple can be set.

--ignore-pattern, --ip
--ignore-pattern, --ip <pattern>

Pattern of files to ignore (in addition to those in .stylelintignore)
A pattern of files to ignore (in addition to those in ".stylelintignore").
Multiple can be set.

--fix

Automatically fix problems of certain rules.

--custom-syntax
--custom-syntax <name_or_path>

Module name or path to a JS file exporting a PostCSS-compatible syntax.
A module name or path to a JS file exporting a PostCSS-compatible syntax.

--stdin

Accept stdin input even if it is empty.

--stdin-filename
--stdin-filename <name>

A filename to assign stdin input.

--ignore-disables, --id

Ignore stylelint-disable comments.
Ignore "stylelint-disable" comments.

--disable-default-ignores, --di

Allow linting of node_modules.
Allow linting of "node_modules".

--cache [default: false]
--[no-]cache

Store the info about processed files in order to only operate on the
changed ones the next time you run stylelint. By default, the cache
is stored in "./.stylelintcache". To adjust this, use --cache-location.
changed ones the next time you run Stylelint. By default, the cache is
stored in "./.stylelintcache". To adjust this, use "--cache-location".
Cache is disabled by default.

--cache-location [default: '.stylelintcache']
--cache-location <path>

Path to a file or directory to be used for the cache location.
Default is "./.stylelintcache". If a directory is specified, a cache
file will be created inside the specified folder, with a name derived
from a hash of the current working directory.
A path to a file or directory to be used for the cache location. If a
directory is specified, a cache file will be created inside the specified
folder, with a name derived from a hash of the current working directory.

If the directory for the cache does not exist, make sure you add a trailing "/"
on *nix systems or "\\" on Windows. Otherwise the path will be assumed to be a file.
on *nix systems or "\\" on Windows. Otherwise the path will be assumed to
be a file.

--cache-strategy [default: "metadata"]
--cache-strategy <metadata|content>

Strategy for the cache to use for detecting changed files. Can be either
"metadata" or "content".
A strategy for the cache to use for detecting changed files. Defaults to "metadata".

The "content" strategy can be useful in cases where the modification time of
your files changes even if their contents have not. For example, this can happen
during git operations like "git clone" because git does not track file modification
time.
The "content" strategy can be useful in cases where the modification time
of your files changes even if their contents have not. For example, this can
happen during git operations like "git clone" because git does not track file
modification time.

--formatter, -f [default: "string"]
--formatter, -f <compact|github|json|string|tap|unix|verbose>
ybiquitous marked this conversation as resolved.
Show resolved Hide resolved

The output formatter: "compact", "github", "json", "string", "tap", "unix" or "verbose".
The output formatter. Defaults to "string".

--custom-formatter
--custom-formatter <path_or_module>

Path to a JS file exporting a custom formatting function.
The file can either be a filesystem path, a module name, or a file to load from a dependency.
A path to a JS file or module name exporting a custom formatting function.

--quiet, -q

Expand All @@ -116,46 +118,50 @@ exports[`CLI --help 1`] = `

Ignore deprecations warnings.

--color
--no-color
--[no-]color

Force enabling/disabling of color.

--report-needless-disables, --rd

Also report errors for stylelint-disable comments that are not blocking a lint warning.
The process will exit with code 2 if needless disables are found.
Also report errors for "stylelint-disable" comments that are not blocking
a lint warning. The process will exit with code 2 if needless disables are found.

--report-invalid-scope-disables, --risd

Report stylelint-disable comments that used for rules that don't exist within the configuration object.
The process will exit with code 2 if invalid scope disables are found.
Report "stylelint-disable" comments that used for rules that don't exist
within the configuration object. The process will exit with code 2 if invalid
scope disables are found.

--report-descriptionless-disables, --rdd

Report stylelint-disable comments without a description.
The process will exit with code 2 if descriptionless disables are found.

--max-warnings, --mw
Report "stylelint-disable" comments without a description. The process will
exit with code 2 if descriptionless disables are found.

Number of warnings above which the process will exit with code 2.
Useful when setting "defaultSeverity" to "warning" and expecting the
process to fail on warnings (e.g. CI build).
--max-warnings, --mw <number>

--output-file, -o
The number of warnings above which the process will exit with code 2.
Useful when setting "defaultSeverity" to "warning" and expecting the process
to fail on warnings (e.g. CI build).

Path of file to write report.

--version, -v
--output-file, -o <path>

Show the currently installed version of stylelint.
A file path to write a report.

--allow-empty-input, --aei

When glob pattern matches no files, the process will exit without throwing an error.
When a glob pattern matches no files, the process will exit without throwing an error.

--globby-options, --go
--globby-options, --go <json>

Options in JSON format passed to globby.

--version, -v

Show the version.

--help, -h

Show the help.
"
`;