diff --git a/rules/sort-map-elements.ts b/rules/sort-map-elements.ts index 61cc7acc..d98d4e41 100644 --- a/rules/sort-map-elements.ts +++ b/rules/sort-map-elements.ts @@ -74,6 +74,7 @@ export default createEslintRule({ 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 diff --git a/test/sort-map-elements.test.ts b/test/sort-map-elements.test.ts index 9c9d1175..5040fc6c 100644 --- a/test/sort-map-elements.test.ts +++ b/test/sort-map-elements.test.ts @@ -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: [], }) })