Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix: don't generate invalid options in config-rule (#8326)
Previously, the `config-rule` logic for generating rule options had a bug where it could generate invalid options. For example, it could generate these options for the `id-match` rule: ```json [2, { "properties": true }] ``` This is invalid because the first option in `id-match` must be a string, and the second option must be an object. The config generator doesn't handle strings, but it was incorrectly skipping the string option and trying to fill in the config with an object after realizing that it couldn't generate a string. As a result, it placed the object where the string was supposed to go, so an invalid set of options was created. A similar issue can appear when generating configs for the `max-statements` rule. Luckily, the `id-match` and `max-statements` rule are still able to run when passed an invalid config, and the invalid config never results in fewer errors being reported than the default, so the invalid options wouldn't ever get output to a config file. However, this is only the case due to implementation details in the two rules, and a new rule could be introduced in the future that crashes when given an invalid schema, so this is still worth fixing. This commit fixes the issue by stopping early when the option generator reaches an option that it doesn't know how to fill in.
- Loading branch information
1 parent
6eda3b5
commit d52173f
Showing
3 changed files
with
55 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters