diff --git a/.changeset/ten-bees-accept.md b/.changeset/ten-bees-accept.md new file mode 100644 index 0000000000..e2dbef6049 --- /dev/null +++ b/.changeset/ten-bees-accept.md @@ -0,0 +1,5 @@ +--- +"stylelint": patch +--- + +Fixed: CLI help improvements diff --git a/lib/__tests__/__snapshots__/cli.test.js.snap b/lib/__tests__/__snapshots__/cli.test.js.snap index 93c407e812..20f0226ade 100644 --- a/lib/__tests__/__snapshots__/cli.test.js.snap +++ b/lib/__tests__/__snapshots__/cli.test.js.snap @@ -9,103 +9,116 @@ 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 + + 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 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 Print the configuration for the given path. - --ignore-path, -i + --ignore-path, -i - 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 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 - 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 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 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 - --cache-strategy [default: "metadata"] + A strategy for the cache to use for detecting changed files. Either one of: - Strategy for the cache to use for detecting changed files. Can be either - "metadata" or "content". + metadata by metadata of a file (default) + content by content of a file - 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 - The output formatter: "compact", "github", "json", "string", "tap", "unix" or "verbose". + An output formatter. The variants are as follows: - --custom-formatter + string human-readable strings (default) + compact similar to ESLint's compact formatter + github workflow commands for GitHub Actions + json JSON format + tap TAP format + unix C compiler-like format + verbose extend "string" to include a file list and a tally - 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. + --custom-formatter + + A path to a JS file or module name exporting a custom formatting function. --quiet, -q @@ -116,46 +129,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 - - 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). + Report "stylelint-disable" comments without a description. The process will + exit with code 2 if descriptionless disables are found. - --output-file, -o + --max-warnings, --mw - Path of file to write report. + 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). - --version, -v + --output-file, -o - 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 Options in JSON format passed to globby. + + --version, -v + + Show the version. + + --help, -h + + Show the help. " `; diff --git a/lib/cli.js b/lib/cli.js index 577567c836..8845d1b6db 100644 --- a/lib/cli.js +++ b/lib/cli.js @@ -4,89 +4,91 @@ const { EOL } = require('os'); const meow = require('meow'); const path = require('path'); const { red, dim } = require('picocolors'); -const { isPlainObject } = require('./utils/validateTypes'); +const resolveFrom = require('resolve-from'); +const { isPlainObject } = require('./utils/validateTypes'); const checkInvalidCLIOptions = require('./utils/checkInvalidCLIOptions'); -const getFormatterOptionsText = require('./utils/getFormatterOptionsText'); const getStdin = require('./utils/getStdin'); const printConfig = require('./printConfig'); -const resolveFrom = require('resolve-from'); const standalone = require('./standalone'); const writeOutputFile = require('./writeOutputFile'); const resolveCustomFormatter = require('./resolveCustomFormatter'); - -const EXIT_CODE_ERROR = 2; +const { + DEFAULT_CACHE_LOCATION, + DEFAULT_IGNORE_FILENAME, + DEFAULT_FORMATTER, + EXIT_CODE_ERROR, +} = require('./constants'); /** - * @typedef {object} CLIFlags - * @property {boolean} [cache] - * @property {string} [cacheLocation] - * @property {string} [cacheStrategy] - * @property {string | false} config - * @property {string} [configBasedir] - * @property {string} [customSyntax] - * @property {string} [printConfig] - * @property {string} [color] - * @property {string} [customFormatter] - * @property {boolean} [disableDefaultIgnores] - * @property {boolean} [fix] - * @property {string} [formatter="string"] - * @property {string} [help] - * @property {boolean} [ignoreDisables] - * @property {string[]} [ignorePath] - * @property {string[]} [ignorePattern] - * @property {string} [noColor] - * @property {string} [outputFile] - * @property {boolean} [stdin] - * @property {string} [stdinFilename] - * @property {boolean} [reportNeedlessDisables] - * @property {boolean} [reportInvalidScopeDisables] - * @property {boolean} [reportDescriptionlessDisables] - * @property {number} [maxWarnings] - * @property {boolean} quiet - * @property {boolean} quietDeprecationWarnings - * @property {string} [version] - * @property {boolean} [allowEmptyInput] - * @property {string} [globbyOptions] + * @typedef {{ + * allowEmptyInput: boolean; + * cache: boolean; + * cacheLocation?: string; + * cacheStrategy?: string; + * color: boolean; + * config?: string; + * configBasedir?: string; + * customFormatter?: string; + * customSyntax?: string; + * disableDefaultIgnores: boolean; + * fix: boolean; + * formatter: string; + * globbyOptions?: string; + * help: boolean; + * ignoreDisables: boolean; + * ignorePath: string[]; + * ignorePattern: string[]; + * maxWarnings?: number; + * outputFile?: string; + * printConfig: boolean; + * quiet: boolean; + * quietDeprecationWarnings: boolean; + * reportDescriptionlessDisables: boolean; + * reportInvalidScopeDisables: boolean; + * reportNeedlessDisables: boolean; + * stdin: boolean; + * stdinFilename?: string; + * version: boolean; + * }} CLIFlags */ /** - * @typedef {object} CLIOptions - * @property {any} input - * @property {any} help - * @property {any} pkg - * @property {Function} showHelp - * @property {Function} showVersion - * @property {CLIFlags} flags + * @typedef {{ + * input: string[]; + * showHelp: (code: number) => void; + * showVersion: () => void; + * flags: CLIFlags; + * }} CLIOptions */ /** - * @typedef {object} OptionBaseType - * @property {any} formatter - * @property {boolean} [cache] - * @property {string} [configFile] - * @property {string} [cacheLocation] - * @property {string} [cacheStrategy] - * @property {string} [customSyntax] - * @property {string} [codeFilename] - * @property {string} [configBasedir] - * @property {boolean} [quiet] - * @property {boolean} [quietDeprecationWarnings] - * @property {any} [printConfig] - * @property {boolean} [fix] - * @property {Record} [globbyOptions] - * @property {boolean} [ignoreDisables] - * @property {any} [ignorePath] - * @property {string} [outputFile] - * @property {boolean} [reportNeedlessDisables] - * @property {boolean} [reportInvalidScopeDisables] - * @property {boolean} [reportDescriptionlessDisables] - * @property {boolean} [disableDefaultIgnores] - * @property {number} [maxWarnings] - * @property {string[]} [ignorePattern] - * @property {boolean} [allowEmptyInput] - * @property {string} [files] - * @property {string} [code] + * @typedef {{ + * allowEmptyInput?: boolean; + * cache?: boolean; + * cacheLocation?: string; + * cacheStrategy?: string; + * code?: string; + * codeFilename?: string; + * configFile?: string; + * configBasedir?: string; + * customSyntax?: string; + * disableDefaultIgnores?: boolean; + * files?: string[]; + * fix?: boolean; + * formatter: any; + * globbyOptions?: Record; + * ignoreDisables?: boolean; + * ignorePath?: string[]; + * ignorePattern?: string[]; + * maxWarnings?: number; + * outputFile?: string; + * quiet?: boolean; + * quietDeprecationWarnings?: boolean; + * reportDescriptionlessDisables?: boolean; + * reportInvalidScopeDisables?: boolean; + * reportNeedlessDisables?: boolean; + * }} OptionBaseType */ const meowOptions = { @@ -98,103 +100,116 @@ const meowOptions = { 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 + + 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 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 Print the configuration for the given path. - --ignore-path, -i + --ignore-path, -i - 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(). + "${DEFAULT_IGNORE_FILENAME}" in "process.cwd()". Multiple can be set. - --ignore-pattern, --ip + --ignore-pattern, --ip - Pattern of files to ignore (in addition to those in .stylelintignore) + A pattern of files to ignore (in addition to those in "${DEFAULT_IGNORE_FILENAME}"). + Multiple can be set. --fix Automatically fix problems of certain rules. - --custom-syntax + --custom-syntax - 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 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 "${DEFAULT_CACHE_LOCATION}". To adjust this, use "--cache-location". + Cache is disabled by default. - --cache-location [default: '.stylelintcache'] + --cache-location - 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 - 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. Either one of: - 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. + metadata by metadata of a file (default) + content by content of a file - --formatter, -f [default: "string"] + 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 output formatter: ${getFormatterOptionsText({ useOr: true })}. + --formatter, -f - --custom-formatter + An output formatter. The variants are as follows: - 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. + string human-readable strings (default) + compact similar to ESLint's compact formatter + github workflow commands for GitHub Actions + json JSON format + tap TAP format + unix C compiler-like format + verbose extend "string" to include a file list and a tally + + --custom-formatter + + A path to a JS file or module name exporting a custom formatting function. --quiet, -q @@ -205,47 +220,51 @@ const meowOptions = { 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 ${EXIT_CODE_ERROR} 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 ${EXIT_CODE_ERROR} 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 ${EXIT_CODE_ERROR} 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 ${EXIT_CODE_ERROR} if invalid + scope disables are found. --report-descriptionless-disables, --rdd - Report stylelint-disable comments without a description. - The process will exit with code ${EXIT_CODE_ERROR} if descriptionless disables are found. - - --max-warnings, --mw + Report "stylelint-disable" comments without a description. The process will + exit with code ${EXIT_CODE_ERROR} if descriptionless disables are found. - Number of warnings above which the process will exit with code ${EXIT_CODE_ERROR}. - Useful when setting "defaultSeverity" to "warning" and expecting the - process to fail on warnings (e.g. CI build). + --max-warnings, --mw - --output-file, -o + The number of warnings above which the process will exit with code ${EXIT_CODE_ERROR}. + Useful when setting "defaultSeverity" to "warning" and expecting the process + to fail on warnings (e.g. CI build). - Path of file to write report. + --output-file, -o - --version, -v - - 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 Options in JSON format passed to globby. + + --version, -v + + Show the version. + + --help, -h + + Show the help. `, flags: { allowEmptyInput: { @@ -286,7 +305,11 @@ const meowOptions = { }, formatter: { alias: 'f', - default: 'string', + type: 'string', + default: DEFAULT_FORMATTER, + }, + globbyOptions: { + alias: 'go', type: 'string', }, help: { @@ -347,10 +370,6 @@ const meowOptions = { alias: 'v', type: 'boolean', }, - globbyOptions: { - alias: 'go', - type: 'string', - }, }, }; @@ -358,7 +377,7 @@ const meowOptions = { * @param {string[]} argv * @returns {Promise} */ -module.exports = async (argv) => { +module.exports = async function main(argv) { const cli = buildCLI(argv); const invalidOptionsMessage = checkInvalidCLIOptions(meowOptions.flags, cli.flags); @@ -509,14 +528,12 @@ module.exports = async (argv) => { const options = cli.input.length ? { ...optionsBase, - files: /** @type {string} */ (cli.input), + files: cli.input, } - : await getStdin().then((stdin) => { - return { - ...optionsBase, - code: stdin, - }; - }); + : await getStdin().then((stdin) => ({ + ...optionsBase, + code: stdin, + })); if (cli.flags.printConfig) { return printConfig(options) diff --git a/lib/constants.js b/lib/constants.js new file mode 100644 index 0000000000..94d816b26a --- /dev/null +++ b/lib/constants.js @@ -0,0 +1,25 @@ +'use strict'; + +const DEFAULT_CACHE_LOCATION = './.stylelintcache'; +const CACHE_STRATEGY_METADATA = 'metadata'; +const CACHE_STRATEGY_CONTENT = 'content'; +const DEFAULT_CACHE_STRATEGY = CACHE_STRATEGY_METADATA; + +const DEFAULT_IGNORE_FILENAME = '.stylelintignore'; + +const DEFAULT_FORMATTER = 'string'; + +const EXIT_CODE_ERROR = 2; + +module.exports = { + DEFAULT_CACHE_LOCATION, + CACHE_STRATEGY_METADATA, + CACHE_STRATEGY_CONTENT, + DEFAULT_CACHE_STRATEGY, + + DEFAULT_IGNORE_FILENAME, + + DEFAULT_FORMATTER, + + EXIT_CODE_ERROR, +}; diff --git a/lib/standalone.js b/lib/standalone.js index 739abf9d0b..84abce2786 100644 --- a/lib/standalone.js +++ b/lib/standalone.js @@ -275,9 +275,9 @@ function getFormatterFunction(selected) { const formatterFunction = formatters[selected]; if (formatterFunction === undefined) { - throw new Error( - `You must use a valid formatter option: ${getFormatterOptionsText()} or a function`, - ); + const formattersText = getFormatterOptionsText(', ', '"'); + + throw new Error(`You must use a valid formatter option: ${formattersText} or a function`); } return formatterFunction; diff --git a/lib/utils/FileCache.js b/lib/utils/FileCache.js index c599e6b82a..e59503912e 100644 --- a/lib/utils/FileCache.js +++ b/lib/utils/FileCache.js @@ -2,16 +2,17 @@ const debug = require('debug')('stylelint:file-cache'); const fileEntryCache = require('file-entry-cache'); -const getCacheFile = require('./getCacheFile'); -const hash = require('./hash'); -const pkg = require('../../package.json'); const path = require('path'); -const CACHE_STRATEGY_METADATA = 'metadata'; -const CACHE_STRATEGY_CONTENT = 'content'; - -const DEFAULT_CACHE_LOCATION = './.stylelintcache'; -const DEFAULT_CACHE_STRATEGY = CACHE_STRATEGY_METADATA; +const pkg = require('../../package.json'); +const getCacheFile = require('./getCacheFile'); +const hash = require('./hash'); +const { + DEFAULT_CACHE_LOCATION, + CACHE_STRATEGY_METADATA, + CACHE_STRATEGY_CONTENT, + DEFAULT_CACHE_STRATEGY, +} = require('../constants'); /** @typedef {import('file-entry-cache').FileDescriptor["meta"] & { hashOfConfig?: string }} CacheMetadata */ diff --git a/lib/utils/__tests__/getFormatterOptionsText.test.js b/lib/utils/__tests__/getFormatterOptionsText.test.js index 93e003648b..2b1604f53a 100644 --- a/lib/utils/__tests__/getFormatterOptionsText.test.js +++ b/lib/utils/__tests__/getFormatterOptionsText.test.js @@ -3,10 +3,8 @@ const getFormatterOptionsText = require('../getFormatterOptionsText'); it('getFormatterOptionsText', () => { - expect(getFormatterOptionsText()).toBe( + expect(getFormatterOptionsText(', ')).toBe('compact, github, json, string, tap, unix, verbose'); + expect(getFormatterOptionsText(', ', '"')).toBe( '"compact", "github", "json", "string", "tap", "unix", "verbose"', ); - expect(getFormatterOptionsText({ useOr: true })).toBe( - '"compact", "github", "json", "string", "tap", "unix" or "verbose"', - ); }); diff --git a/lib/utils/getFileIgnorer.js b/lib/utils/getFileIgnorer.js index 2408e054ce..6c22ab48f8 100644 --- a/lib/utils/getFileIgnorer.js +++ b/lib/utils/getFileIgnorer.js @@ -1,14 +1,12 @@ 'use strict'; -// Try to get file ignorer from '.stylelintignore' const fs = require('fs'); const path = require('path'); const { default: ignore } = require('ignore'); +const { DEFAULT_IGNORE_FILENAME } = require('../constants'); const isPathNotFoundError = require('./isPathNotFoundError'); -const DEFAULT_IGNORE_FILENAME = '.stylelintignore'; - /** * @typedef {import('stylelint').LinterOptions} LinterOptions * diff --git a/lib/utils/getFormatterOptionsText.js b/lib/utils/getFormatterOptionsText.js index 9d5f27aff4..c2f0a13741 100644 --- a/lib/utils/getFormatterOptionsText.js +++ b/lib/utils/getFormatterOptionsText.js @@ -3,17 +3,12 @@ const formatters = require('../formatters'); /** - * @param {{ useOr?: boolean }} [options={}] + * @param {string} separator + * @param {string} [quote] * @returns {string} */ -module.exports = function getFormatterOptionsText(options = {}) { - let output = Object.keys(formatters) - .map((name) => `"${name}"`) - .join(', '); - - if (options.useOr) { - output = output.replace(/, ([a-z"]+)$/u, ' or $1'); - } - - return output; +module.exports = function getFormatterOptionsText(separator, quote = '') { + return Object.keys(formatters) + .map((name) => `${quote}${name}${quote}`) + .join(separator); };