Skip to content

Commit

Permalink
fix: make getRulesMetaForResults return a plain object in trivial c…
Browse files Browse the repository at this point in the history
…ase (#16438)
  • Loading branch information
fasttime committed Oct 18, 2022
1 parent a2810bc commit 325ad37
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
5 changes: 2 additions & 3 deletions lib/eslint/flat-eslint.js
Expand Up @@ -665,13 +665,12 @@ class FlatESLint {
*/
getRulesMetaForResults(results) {

const resultRules = new Map();

// short-circuit simple case
if (results.length === 0) {
return resultRules;
return {};
}

const resultRules = new Map();
const { configs } = privateMembers.get(this);

/*
Expand Down
2 changes: 1 addition & 1 deletion tests/lib/eslint/eslint.js
Expand Up @@ -4971,7 +4971,7 @@ describe("ESLint", () => {

const rulesMeta = engine.getRulesMetaForResults([]);

assert.strictEqual(Object.keys(rulesMeta).length, 0);
assert.deepStrictEqual(rulesMeta, {});
});

it("should return one rule meta when there is a linting error", async () => {
Expand Down
2 changes: 1 addition & 1 deletion tests/lib/eslint/flat-eslint.js
Expand Up @@ -3754,7 +3754,7 @@ describe("FlatESLint", () => {

const rulesMeta = engine.getRulesMetaForResults([]);

assert.strictEqual(Object.keys(rulesMeta).length, 0);
assert.deepStrictEqual(rulesMeta, {});
});

it("should return one rule meta when there is a linting error", async () => {
Expand Down

0 comments on commit 325ad37

Please sign in to comment.