mirror of
https://github.com/denoland/deno.git
synced 2025-09-28 05:04:48 +00:00
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
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:
parent
ca06312ac7
commit
a8cde960ce
2 changed files with 22 additions and 1 deletions
|
@ -607,6 +607,9 @@ function setNodeGetters(ctx) {
|
||||||
const name = getString(ctx.strTable, id);
|
const name = getString(ctx.strTable, id);
|
||||||
|
|
||||||
Object.defineProperty(FacadeNode.prototype, name, {
|
Object.defineProperty(FacadeNode.prototype, name, {
|
||||||
|
// The `parent` key is expected to be non-enumerable.
|
||||||
|
// See the npm `zimmerframe` library.
|
||||||
|
enumerable: name !== "parent",
|
||||||
get() {
|
get() {
|
||||||
return readValue(
|
return readValue(
|
||||||
this[INTERNAL_CTX],
|
this[INTERNAL_CTX],
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
// Copyright 2018-2025 the Deno authors. MIT license.
|
// 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";
|
import { assertSnapshot } from "@std/testing/snapshot";
|
||||||
|
|
||||||
// TODO(@marvinhagemeister) Remove once we land "official" types
|
// 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 = unknown", "TSUnknownKeyword");
|
||||||
await testSnapshot(t, "type A = void", "TSVoidKeyword");
|
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);
|
||||||
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue