Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to list files being linted by ESLint

How can I get a list of the files ESLint is checking?

The only talk about it I can find is this eslint issue where a member of the repo suggested running DEBUG=eslint:* eslint. However, the output from that is impossibly large.

like image 597
Matthew Herbst Avatar asked Aug 31 '25 10:08

Matthew Herbst


2 Answers

A close look at the output shows a single line with eslint:flat-eslint Lint before the filename. Knowing that we can narrow the debug statement based on the output (eslintv8).

DEBUG=eslint:flat-eslint eslint when using flat config

or DEBUG=eslint:cli-engine eslint when using deprecated config

or DEBUG=eslint:flat-eslint,eslint:cli-engine if unsure.

As the OP in the linked issue suggested, a --list-files option seems like a no brainer for eslint to add.

like image 168
Matthew Herbst Avatar answered Sep 03 '25 01:09

Matthew Herbst


ESLint v9.13.0:

DEBUG=eslint:eslint npx eslint .

https://github.com/eslint/eslint/blob/v9.13.0/lib/eslint/eslint.js#L101

I can't find these details in the eslint@v9 docs, but it does work (see example).


ESLint v8.57.1:

DEBUG=eslint:cli-engine npx eslint .

https://github.com/eslint/eslint/blob/v8.57.0/lib/cli-engine/cli-engine.js#L43

The answer from Maxim should be working according to the source listed in https://github.com/eslint/eslint/blob/v8.57.0/lib/eslint/flat-eslint.js#L99, but I'm not seeing eslint:flat-config work locally. However eslint:cli-engine does appear work for this version, at least on my machine.


Example & Explanation for v9:

Run npx eslint . --debug and look for the prefix of the line you want to filter by.

This is a simplified output of npx eslint . --debug

  eslint:cli CLI args: [ '.', '--debug' ] +0ms
  eslint:cli Using flat config? true +2ms
  eslint:cli Running on files +5ms
  eslint:eslint Using config loader LegacyConfigLoader +0ms
  eslint:eslint Using file patterns: . +0ms
  eslint:eslint Deleting cache file at /redacted/path/.eslintcache +0ms
  eslint:rules Loading rule 'no-empty-function' (remaining=284) +4ms
  eslint:eslint 3 files found in: 1332ms +1s
  eslint:rules Loading rule 'no-var' (remaining=206) +132ms
  eslint:linter Generating fixed text for /redacted/path/1 (pass 1) +40ms
  eslint:source-code-fixer Applying fixes +40ms
  eslint:source-code-fixer shouldFix parameter was false, not attempting fixes +0ms
  eslint:eslint Lint /redacted/path/2 +6ms
  eslint:source-code-fixer Applying fixes +72ms
  eslint:source-code-fixer shouldFix parameter was false, not attempting fixes +0ms
  eslint:eslint Lint /redacted/path/3 +72ms
  • DEBUG=eslint:rules npx eslint .
    • This will print only the output matching the prefix eslint:rules.
  eslint:rules Loading rule 'no-empty-function' (remaining=284) +4ms
  eslint:rules Loading rule 'no-var' (remaining=206) +132ms
  • DEBUG=eslint:eslint npx eslint .
    • This will print only the output matching the prefix eslint:eslint, which will list file names (Plus some other stuff as mentioned by Alejandro).
  eslint:eslint Using config loader LegacyConfigLoader +0ms
  eslint:eslint Using file patterns: . +2ms
  eslint:eslint Deleting cache file at /redacted/path/.eslintcache +0ms
  eslint:eslint 3 files found in: 1944ms +2s
  eslint:eslint Lint /redacted/path/1 +3ms
  eslint:eslint Lint /redacted/path/2 +258ms
  eslint:eslint Lint /redacted/path/3 +19ms
like image 33
kevbost Avatar answered Sep 03 '25 03:09

kevbost