Skip to content

Commit

Permalink
fix: fix working sort-map-elements with empty map
Browse files Browse the repository at this point in the history
  • Loading branch information
azat-io committed Jun 4, 2023
1 parent a10370c commit de061ff
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions rules/sort-map-elements.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ export default createEslintRule<Options, MESSAGE_ID>({
if (
node.callee.type === AST_NODE_TYPES.Identifier &&
node.callee.name === 'Map' &&
node.arguments.length &&
node.arguments[0].type === AST_NODE_TYPES.ArrayExpression
) {
let [{ elements }] = node.arguments
Expand Down
2 changes: 1 addition & 1 deletion test/sort-map-elements.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -976,7 +976,7 @@ describe(RULE_NAME, () => {

it(`${RULE_NAME}: works with empty map`, () => {
ruleTester.run(RULE_NAME, rule, {
valid: ['new Map([[], []])'],
valid: ['new Map([[], []])', 'new Map()'],
invalid: [],
})
})
Expand Down

0 comments on commit de061ff

Please sign in to comment.