fix(unstable): lint node properties should be enumerable (#30391)
Some checks are pending
ci / test debug linux-aarch64 (push) Blocked by required conditions
ci / test release linux-aarch64 (push) Blocked by required conditions
ci / test debug macos-aarch64 (push) Blocked by required conditions
ci / test release macos-aarch64 (push) Blocked by required conditions
ci / bench release linux-x86_64 (push) Blocked by required conditions
ci / lint debug linux-x86_64 (push) Blocked by required conditions
ci / lint debug macos-x86_64 (push) Blocked by required conditions
ci / lint debug windows-x86_64 (push) Blocked by required conditions
ci / test debug linux-x86_64 (push) Blocked by required conditions
ci / test release linux-x86_64 (push) Blocked by required conditions
ci / test debug macos-x86_64 (push) Blocked by required conditions
ci / test release macos-x86_64 (push) Blocked by required conditions
ci / test debug windows-x86_64 (push) Blocked by required conditions
ci / test release windows-x86_64 (push) Blocked by required conditions
ci / pre-build (push) Waiting to run
ci / build libs (push) Blocked by required conditions
ci / publish canary (push) Blocked by required conditions

This makes npm libraries that traverse the ESTree format like `zimmerframe` or `periscopic` work with our lint ast.
This commit is contained in:
Marvin Hagemeister 2025-08-13 15:46:51 +02:00 committed by GitHub
parent ca06312ac7
commit a8cde960ce
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 22 additions and 1 deletions

View file

@ -607,6 +607,9 @@ function setNodeGetters(ctx) {
const name = getString(ctx.strTable, id);
Object.defineProperty(FacadeNode.prototype, name, {
// The `parent` key is expected to be non-enumerable.
// See the npm `zimmerframe` library.
enumerable: name !== "parent",
get() {
return readValue(
this[INTERNAL_CTX],

View file

@ -1,6 +1,6 @@
// Copyright 2018-2025 the Deno authors. MIT license.
import { assertEquals } from "./test_util.ts";
import { assert, assertEquals } from "./test_util.ts";
import { assertSnapshot } from "@std/testing/snapshot";
// TODO(@marvinhagemeister) Remove once we land "official" types
@ -1228,3 +1228,21 @@ Deno.test("Plugin - TS keywords", async (t) => {
await testSnapshot(t, "type A = unknown", "TSUnknownKeyword");
await testSnapshot(t, "type A = void", "TSVoidKeyword");
});
Deno.test("Plugin - enumerable properties", () => {
const keys: string[] = [];
testPlugin(`const a = 42`, {
create() {
return {
Program(node) {
// deno-lint-ignore guard-for-in
for (const k in node) {
keys.push(k);
}
},
};
},
});
assert(keys.length > 0);
});