Skip to content

Commit 9194000

Browse files
committed
chore(consistent-selector-style): shorter array equality function
1 parent b1253f7 commit 9194000

File tree

1 file changed

+1
-14
lines changed

1 file changed

+1
-14
lines changed

packages/eslint-plugin-svelte/src/rules/consistent-selector-style.ts

+1-14
Original file line numberDiff line numberDiff line change
@@ -275,18 +275,5 @@ function couldBeType(
275275
* Compares two arrays for item equality
276276
*/
277277
function arrayEquals(array1: AST.SvelteHTMLElement[], array2: AST.SvelteHTMLElement[]): boolean {
278-
function comparator(a: AST.SvelteHTMLElement, b: AST.SvelteHTMLElement): number {
279-
return a.range[0] - b.range[0];
280-
}
281-
282-
const array2Sorted = array2.slice().sort(comparator);
283-
return (
284-
array1.length === array2.length &&
285-
array1
286-
.slice()
287-
.sort(comparator)
288-
.every(function (value, index) {
289-
return value === array2Sorted[index];
290-
})
291-
);
278+
return array1.length === array2.length && array1.every((e) => array2.includes(e));
292279
}

0 commit comments

Comments
 (0)