Skip to content

Commit

Permalink
refactor: use optional chaining when validating config rules (eslint#…
Browse files Browse the repository at this point in the history
…18893)

* refactor: use optional chaining when validating config rules

This change reduces the number of "&&" while still keeping the same behavior

* refactor: use optional chaining when validating config rules

* refactor: use optional chaining when validating config rules
  • Loading branch information
lucasrmendonca authored Sep 13, 2024
1 parent 2c2805f commit 71f37c5
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions lib/config/flat-config-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,9 @@ function parseRuleId(ruleId) {
* or undefined if not.
*/
function getRuleFromConfig(ruleId, config) {

const { pluginName, ruleName } = parseRuleId(ruleId);

const plugin = config.plugins && config.plugins[pluginName];
const rule = plugin && plugin.rules && plugin.rules[ruleName];

return rule;
return config.plugins?.[pluginName]?.rules?.[ruleName];
}

/**
Expand Down

0 comments on commit 71f37c5

Please sign in to comment.