Fix noShadowRestrictedNames lint rule
MODIFY
packages/@romejs/compiler/lint/rules/js/noShadowRestrictedNames.test.ts
packages/@romejs/compiler/lint/rules/js/noShadowRestrictedNames.test.ts
@@ -18,9 +18,8 @@ test(
"function NaN() {}",
"let Set;",
"try { } catch(Object) {}",
- // These are false negatives
- // "!function Array() {}",
- // "function test(JSON) {console.log(JSON)}",
+ "!function Array() {}",
+ "function test(JSON) {console.log(JSON)}",
],
},
{category: "lint/js/noShadowRestrictedNames"},

MODIFY
packages/@romejs/compiler/lint/rules/js/noShadowRestrictedNames.ts
packages/@romejs/compiler/lint/rules/js/noShadowRestrictedNames.ts
@@ -17,7 +17,7 @@ export default {
enter(path: Path): TransformExitResult {
const {node, context, scope} = path;
- if (scope.node === node) {
+ if (scope.node === node || node.type === "JSFunctionHead") {
for (const [name, binding] of scope.getOwnBindings()) {
if (restrictedNames.has(name)) {
context.addNodeDiagnostic(

Fix noShadowRestrictedNames lint rule (#554)