rizowski / eslint-watch

ESLint with simple watching capabilities
https://www.npmjs.com/package/eslint-watch
MIT License
193 stars 29 forks source link

"The --print-config option must be used with exactly one file name." #180

Open mattalxndr opened 2 years ago

mattalxndr commented 2 years ago

Environment

Basic Description of the problem

How to reproduce it

  1. Command: esw --print-config src/index.ts
  2. I expect to get a listing of the configuration data, but I get this error.

Debug output:

// to grab debug output set DEBUG=esw:*
freshbrowser % esw --print-config src/index.ts
esw:eslint-help Loaded +0ms
esw:main [ '--print-config', 'src/index.ts' ] +0ms
esw:main ESW: v8.0.0 +2ms
esw:eslint Executing [ '--help' ] +0ms
esw:eslint {
esw:eslint   command: 'eslint --help',
esw:eslint   escapedCommand: 'eslint --help',
esw:eslint   exitCode: 0,
esw:eslint   stdout: 'eslint [options] file.js [file.js] [dir]\n' +
esw:eslint     '\n' +
esw:eslint     'Basic configuration:\n' +
esw:eslint     '  --no-eslintrc                   Disable use of configuration from .eslintrc.*\n' +
esw:eslint     '  -c, --config path::String       Use this configuration, overriding .eslintrc.* config options if present\n' +
esw:eslint     '  --env [String]                  Specify environments\n' +
esw:eslint     '  --ext [String]                  Specify JavaScript file extensions\n' +
esw:eslint     '  --global [String]               Define global variables\n' +
esw:eslint     '  --parser String                 Specify the parser to be used\n' +
esw:eslint     '  --parser-options Object         Specify parser options\n' +
esw:eslint     '  --resolve-plugins-relative-to path::String  A folder where plugins should be resolved from, CWD by default\n' +
esw:eslint     '\n' +
esw:eslint     'Specifying rules and plugins:\n' +
esw:eslint     '  --plugin [String]               Specify plugins\n' +
esw:eslint     '  --rule Object                   Specify rules\n' +
esw:eslint     '  --rulesdir [path::String]       Load additional rules from this directory. Deprecated: Use rules from plugins\n' +
esw:eslint     '\n' +
esw:eslint     'Fixing problems:\n' +
esw:eslint     '  --fix                           Automatically fix problems\n' +
esw:eslint     '  --fix-dry-run                   Automatically fix problems without saving the changes to the file system\n' +
esw:eslint     '  --fix-type Array                Specify the types of fixes to apply (directive, problem, suggestion, layout)\n' +
esw:eslint     '\n' +
esw:eslint     'Ignoring files:\n' +
esw:eslint     '  --ignore-path path::String      Specify path of ignore file\n' +
esw:eslint     '  --no-ignore                     Disable use of ignore files and patterns\n' +
esw:eslint     '  --ignore-pattern [String]       Pattern of files to ignore (in addition to those in .eslintignore)\n' +
esw:eslint     '\n' +
esw:eslint     'Using stdin:\n' +
esw:eslint     '  --stdin                         Lint code provided on <STDIN> - default: false\n' +
esw:eslint     '  --stdin-filename String         Specify filename to process STDIN as\n' +
esw:eslint     '\n' +
esw:eslint     'Handling warnings:\n' +
esw:eslint     '  --quiet                         Report errors only - default: false\n' +
esw:eslint     '  --max-warnings Int              Number of warnings to trigger nonzero exit code - default: -1\n' +
esw:eslint     '\n' +
esw:eslint     'Output:\n' +
esw:eslint     '  -o, --output-file path::String  Specify file to write report to\n' +
esw:eslint     '  -f, --format String             Use a specific output format - default: stylish\n' +
esw:eslint     '  --color, --no-color             Force enabling/disabling of color\n' +
esw:eslint     '\n' +
esw:eslint     'Inline configuration comments:\n' +
esw:eslint     '  --no-inline-config              Prevent comments from changing config or rules\n' +
esw:eslint     '  --report-unused-disable-directives  Adds reported errors for unused eslint-disable directives\n' +
esw:eslint     '\n' +
esw:eslint     'Caching:\n' +
esw:eslint     '  --cache                         Only check changed files - default: false\n' +
esw:eslint     '  --cache-file path::String       Path to the cache file. Deprecated: use --cache-location - default: .eslintcache\n' +
esw:eslint     '  --cache-location path::String   Path to the cache file or directory\n' +
esw:eslint     '  --cache-strategy String         Strategy to use for detecting changed files in the cache - either: metadata or content - default: metadata\n' +
esw:eslint     '\n' +
esw:eslint     'Miscellaneous:\n' +
esw:eslint     '  --init                          Run config initialization wizard - default: false\n' +
esw:eslint     '  --env-info                      Output execution environment information - default: false\n' +
esw:eslint     '  --no-error-on-unmatched-pattern  Prevent errors when pattern is unmatched\n' +
esw:eslint     '  --exit-on-fatal-error           Exit with exit code 2 in case of fatal error - default: false\n' +
esw:eslint     '  --debug                         Output debugging information\n' +
esw:eslint     '  -h, --help                      Show help\n' +
esw:eslint     '  -v, --version                   Output the version number\n' +
esw:eslint     '  --print-config path::String     Print the configuration for the given file',
esw:eslint   stderr: '',
esw:eslint   all: undefined,
esw:eslint   failed: false,
esw:eslint   timedOut: false,
esw:eslint   isCanceled: false,
esw:eslint   killed: false
esw:eslint } +132ms
esw:eslint-help Parsing --no-eslintrc +172ms
esw:eslint-help Parsing no option --no-eslintrc +0ms
esw:eslint-help Alias found: -c +0ms
esw:eslint-help Parsing --config +0ms
esw:eslint-help Parsing --env +0ms
esw:eslint-help Parsing --ext +0ms
esw:eslint-help Parsing --global +0ms
esw:eslint-help Parsing --parser +0ms
esw:eslint-help Parsing --parser-options +0ms
esw:eslint-help Parsing --resolve-plugins-relative-to +0ms
esw:eslint-help Parsing --plugin +1ms
esw:eslint-help Parsing --rule +0ms
esw:eslint-help Parsing --rulesdir +0ms
esw:eslint-help Parsing --fix +0ms
esw:eslint-help Parsing --fix-dry-run +0ms
esw:eslint-help Parsing --fix-type +0ms
esw:eslint-help Parsing --ignore-path +0ms
esw:eslint-help Parsing --no-ignore +0ms
esw:eslint-help Parsing no option --no-ignore +0ms
esw:eslint-help Parsing --ignore-pattern +0ms
esw:eslint-help Parsing --stdin +0ms
esw:eslint-help Parsing --stdin-filename +0ms
esw:eslint-help Parsing --quiet +0ms
esw:eslint-help Parsing --max-warnings +0ms
esw:eslint-help Alias found: -o +0ms
esw:eslint-help Parsing --output-file +0ms
esw:eslint-help Alias found: -f +0ms
esw:eslint-help Parsing --format +0ms
esw:eslint-help Parsing --no-inline-config +0ms
esw:eslint-help Parsing no option --no-inline-config +0ms
esw:eslint-help Parsing --report-unused-disable-directives +0ms
esw:eslint-help Parsing --cache +0ms
esw:eslint-help Parsing --cache-file +0ms
esw:eslint-help Parsing --cache-location +0ms
esw:eslint-help Parsing --cache-strategy +0ms
esw:eslint-help Parsing --init +0ms
esw:eslint-help Parsing --env-info +0ms
esw:eslint-help Parsing --no-error-on-unmatched-pattern +0ms
esw:eslint-help Parsing no option --no-error-on-unmatched-pattern +0ms
esw:eslint-help Parsing --exit-on-fatal-error +0ms
esw:eslint-help Parsing --debug +0ms
esw:eslint-help Alias found: -h +0ms
esw:eslint-help Parsing --help +0ms
esw:eslint-help Alias found: -v +1ms
esw:eslint-help Parsing --version +0ms
esw:eslint-help Parsing --print-config +0ms
esw:options [
esw:options   { heading: 'ESW Options' },
esw:options   {
esw:options     option: 'help',
esw:options     alias: 'h',
esw:options     type: 'Boolean',
esw:options     description: 'Show help'
esw:options   },
esw:options   {
esw:options     option: 'watch',
esw:options     alias: 'w',
esw:options     type: 'Boolean',
esw:options     description: 'Enable file watch'
esw:options   },
esw:options   {
esw:options     option: 'changed',
esw:options     type: 'Boolean',
esw:options     description: 'Enables single file linting while watch is enabled'
esw:options   },
esw:options   {
esw:options     option: 'clear',
esw:options     type: 'Boolean',
esw:options     description: 'Clear terminal when running lint'
esw:options   },
esw:options   {
esw:options     option: 'version',
esw:options     type: 'Boolean',
esw:options     alias: 'v',
esw:options     description: 'Prints Eslint-Watch Version'
esw:options   },
esw:options   {
esw:options     option: 'versions',
esw:options     type: 'Boolean',
esw:options     description: 'Prints Eslint-Watch and Eslint Versions'
esw:options   },
esw:options   {
esw:options     option: 'watch-ignore',
esw:options     type: 'RegExp',
esw:options     description: 'Regex string of folders to ignore when watching - default: /.git|node_modules|bower_components|.eslintcache/'
esw:options   },
esw:options   {
esw:options     option: 'watch-delay',
esw:options     type: 'Int',
esw:options     description: 'Delay(ms) for watcher to wait to trigger re-lint',
esw:options     default: '300'
esw:options   },
esw:options   { heading: 'Basic configuration' },
esw:options   {
esw:options     option: 'ext',
esw:options     type: '[String]',
esw:options     description: 'Specify JavaScript file extensions',
esw:options     default: '.js'
esw:options   },
esw:options   {
esw:options     default: 'true',
esw:options     option: 'eslintrc',
esw:options     type: 'Boolean',
esw:options     description: 'Disable use of configuration from .eslintrc.*'
esw:options   },
esw:options   {
esw:options     option: 'config',
esw:options     type: 'path::String',
esw:options     description: 'Use this configuration, overriding .eslintrc.* config options if present',
esw:options     alias: 'c'
esw:options   },
esw:options   {
esw:options     option: 'env',
esw:options     type: '[String]',
esw:options     description: 'Specify environments'
esw:options   },
esw:options   {
esw:options     option: 'global',
esw:options     type: '[String]',
esw:options     description: 'Define global variables'
esw:options   },
esw:options   {
esw:options     option: 'parser',
esw:options     type: 'String',
esw:options     description: 'Specify the parser to be used'
esw:options   },
esw:options   {
esw:options     option: 'parser-options',
esw:options     type: 'Object',
esw:options     description: 'Specify parser options'
esw:options   },
esw:options   {
esw:options     option: 'resolve-plugins-relative-to',
esw:options     type: 'path::String',
esw:options     description: 'A folder where plugins should be resolved from CWD by default'
esw:options   },
esw:options   { heading: 'Specifying rules and plugins' },
esw:options   {
esw:options     option: 'plugin',
esw:options     type: '[String]',
esw:options     description: 'Specify plugins'
esw:options   },
esw:options   { option: 'rule', type: 'Object', description: 'Specify rules' },
esw:options   {
esw:options     option: 'rulesdir',
esw:options     type: '[path::String]',
esw:options     description: 'Load additional rules from this directory. Deprecated: Use rules from plugins'
esw:options   },
esw:options   { heading: 'Fixing problems' },
esw:options   {
esw:options     option: 'fix',
esw:options     type: 'Boolean',
esw:options     description: 'Automatically fix problems'
esw:options   },
esw:options   {
esw:options     option: 'fix-dry-run',
esw:options     type: 'Boolean',
esw:options     description: 'Automatically fix problems without saving the changes to the file system'
esw:options   },
esw:options   {
esw:options     option: 'fix-type',
esw:options     type: 'Array',
esw:options     description: 'Specify the types of fixes to apply (directive problem, suggestion, layout)'
esw:options   },
esw:options   { heading: 'Ignoring files' },
esw:options   {
esw:options     option: 'ignore-path',
esw:options     type: 'path::String',
esw:options     description: 'Specify path of ignore file'
esw:options   },
esw:options   {
esw:options     default: 'true',
esw:options     option: 'ignore',
esw:options     type: 'Boolean',
esw:options     description: 'Disable use of ignore files and patterns'
esw:options   },
esw:options   {
esw:options     option: 'ignore-pattern',
esw:options     type: '[String]',
esw:options     description: 'Pattern of files to ignore (in addition to those in .eslintignore)'
esw:options   },
esw:options   { heading: 'Using stdin' },
esw:options   {
esw:options     option: 'stdin',
esw:options     type: 'Boolean',
esw:options     description: 'Lint code provided on <STDIN> - default: false'
esw:options   },
esw:options   {
esw:options     option: 'stdin-filename',
esw:options     type: 'String',
esw:options     description: 'Specify filename to process STDIN as'
esw:options   },
esw:options   { heading: 'Handling warnings' },
esw:options   {
esw:options     option: 'quiet',
esw:options     type: 'Boolean',
esw:options     description: 'Report errors only - default: false'
esw:options   },
esw:options   {
esw:options     option: 'max-warnings',
esw:options     type: 'Int',
esw:options     description: 'Number of warnings to trigger nonzero exit code - default: -1'
esw:options   },
esw:options   { heading: 'Output' },
esw:options   {
esw:options     option: 'output-file',
esw:options     type: 'path::String',
esw:options     description: 'Specify file to write report to',
esw:options     alias: 'o'
esw:options   },
esw:options   {
esw:options     option: 'format',
esw:options     type: 'String',
esw:options     description: 'Use a specific output format - default: stylish',
esw:options     alias: 'f'
esw:options   },
esw:options   {
esw:options     option: 'color',
esw:options     type: 'Boolean',
esw:options     alias: 'no-color',
esw:options     description: 'Force enabling/disabling of color'
esw:options   },
esw:options   { heading: 'Inline configuration comments' },
esw:options   {
esw:options     default: 'true',
esw:options     option: 'inline-config',
esw:options     type: 'Boolean',
esw:options     description: 'Prevent comments from changing config or rules'
esw:options   },
esw:options   {
esw:options     option: 'report-unused-disable-directives',
esw:options     type: 'Boolean',
esw:options     description: 'Adds reported errors for unused eslint-disable directives'
esw:options   },
esw:options   { heading: 'Caching' },
esw:options   {
esw:options     option: 'cache',
esw:options     type: 'Boolean',
esw:options     description: 'Only check changed files - default: false'
esw:options   },
esw:options   {
esw:options     option: 'cache-file',
esw:options     type: 'path::String',
esw:options     description: 'Path to the cache file. Deprecated: use --cache-location - default: .eslintcache'
esw:options   },
esw:options   {
esw:options     option: 'cache-location',
esw:options     type: 'path::String',
esw:options     description: 'Path to the cache file or directory'
esw:options   },
esw:options   {
esw:options     option: 'cache-strategy',
esw:options     type: 'String',
esw:options     description: 'Strategy to use for detecting changed files in the cache - either: metadata or content - default: metadata'
esw:options   },
esw:options   { heading: 'Miscellaneous' },
esw:options   {
esw:options     option: 'init',
esw:options     type: 'Boolean',
esw:options     description: 'Run config initialization wizard - default: false'
esw:options   },
esw:options   {
esw:options     option: 'env-info',
esw:options     type: 'Boolean',
esw:options     description: 'Output execution environment information - default: false'
esw:options   },
esw:options   {
esw:options     default: 'true',
esw:options     option: 'error-on-unmatched-pattern',
esw:options     type: 'Boolean',
esw:options     description: 'Prevent errors when pattern is unmatched'
esw:options   },
esw:options   {
esw:options     option: 'exit-on-fatal-error',
esw:options     type: 'Boolean',
esw:options     description: 'Exit with exit code 2 in case of fatal error - default: false'
esw:options   },
esw:options   {
esw:options     option: 'debug',
esw:options     type: 'Boolean',
esw:options     description: 'Output debugging information'
esw:options   },
esw:options   {
esw:options     option: 'print-config',
esw:options     type: 'path::String',
esw:options     description: 'Print the configuration for the given file'
esw:options   }
esw:options ] +0ms
esw:main {
esw:main   printConfig: 'src/index.ts',
esw:main   watchDelay: 300,
esw:main   ext: [ '.js' ],
esw:main   eslintrc: true,
esw:main   ignore: true,
esw:main   inlineConfig: true,
esw:main   errorOnUnmatchedPattern: true,
esw:main   _: [ '/home/matt/Projects/freshbrowser-ws/freshbrowser' ]
esw:main } +141ms
esw:commands Running 0 esw commands +0ms
esw:commands Success:  +0ms
esw:eslint Executing [ '--print-config', 'src/index.ts', '--ext', [ '.js' ], '--eslintrc', '--ignore', '--inline-config', '--error-on-unmatched-pattern', '/home/matt/Projects/freshbrowser-ws/freshbrowser' ] +0ms
esw:eslint Error: Command failed with exit code 2: eslint --print-config src/index.ts --ext .js --eslintrc --ignore --inline-config --error-on-unmatched-pattern /home/matt/Projects/freshbrowser-ws/freshbrowser
esw:eslint The --print-config option must be used with exactly one file name.
esw:eslint     at makeError (/home/matt/Projects/freshbrowser-ws/freshbrowser/node_modules/execa/lib/error.js:60:11)
esw:eslint     at handlePromise (/home/matt/Projects/freshbrowser-ws/freshbrowser/node_modules/execa/index.js:118:26)
esw:eslint     at processTicksAndRejections (node:internal/process/task_queues:96:5)
esw:eslint     at async Object.execute (/home/matt/Projects/freshbrowser-ws/freshbrowser/node_modules/eslint-watch/src/eslint/index.js:19:22)
esw:eslint     at async Object.run (/home/matt/Projects/freshbrowser-ws/freshbrowser/node_modules/eslint-watch/src/index.js:40:24) +128ms
The --print-config option must be used with exactly one file name.
rizowski commented 2 years ago

Can you try adding --ext ts to your command and let me know the output?