Skip to content

Commit 66de41a

Browse files
authoredMar 3, 2025··
no-unnecessary-polyfills: Fix crash on checking es6-error module (#2582)
1 parent e48a620 commit 66de41a

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed
 

‎rules/no-unnecessary-polyfills.js

+3-4
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,9 @@ function create(context) {
127127
const polyfill = polyfills.find(({pattern}) => pattern.test(importedModule));
128128
if (polyfill) {
129129
const [, namespace, method = ''] = polyfill.feature.split('.');
130-
const [, features] = Object.entries(coreJsEntries).find(
131-
entry => entry[0] === `core-js/full/${namespace}${method && '/'}${method}`,
132-
);
133-
if (checkFeatures(features)) {
130+
const features = coreJsEntries[`core-js/full/${namespace}${method && '/'}${method}`];
131+
132+
if (features && checkFeatures(features)) {
134133
return {node, messageId: MESSAGE_ID_POLYFILL};
135134
}
136135
}

‎test/no-unnecessary-polyfills.js

+1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ test({
4848
code: 'require("" )',
4949
options: [{targets: 'node >3'}],
5050
},
51+
'import ExtendableError from "es6-error"',
5152
],
5253
invalid: [
5354
{

0 commit comments

Comments
 (0)
Please sign in to comment.