CLIEngine#getRules() returns the map that contains built-in rules and plugin rules of ConfigArray instances the last CLIEngine#executeOnFiles() or CLIEngine#executeOnText() call used.

It changes the processing order to "config-then-files" from "files-then-config".

lib/cli-engine/file-enumerator.js finds target files by processing glob patterns. While iterating files, it loads the config file of each directory before iterate files on the directory, so we can use the config files to determine target files. (But, it doesn't use the config files to determine target files yet.)

I describe file mapping of before/after the refactoring. There are details for each new file on the top of the source code.

Tests for resolveFileGlobPattern() in tests/lib/util/glob-utils.js moved to tests/lib/cli-engine.js#L3412. The new FileEnumerator no longer uses this logic, but it's a public API of CLIEngine. So we have to keep it.

And I added some @typedef comments for VSCode IntelliSense.

Is there anything you'd like reviewers to focus on?

Are there unintentional breaking changes?

I found an additional breaking change (as a bug fix) about plugin loading. Currently, even if a configuration has no plugins field, CLIEngine#executeOnFiles() and CLIEngine#executeOnText() can use plugin rules that the previous calls loaded. After this PR, CLIEngine#executeOnFiles() and CLIEngine#executeOnText() will report error messages consistently if plugins were not found in configuration.

Related to that, Linter#getRules() and CLIEngine#getRules() will change:

Linter#getRules() will return the rules, including built-in rules, user-defined rules, and only the plugin rules that the last Linter#verify() loaded.

CLIEngine#getRules() will return the rules, including built-in rules and only the plugin rules that the last CLIEngine#executeOnFiles() or CLIEngine#executeOnText() loaded.

I think that this change is good because formatters can access to unrelated rules (via RFC 10) before this PR and we already have a getter to get information of the last Linter#verify() call; Linter#getSourceCode().

Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.