Skip to content

Commit

Permalink
chore: update no-window lint rule message for Deno 2.0 (#1320)
Browse files Browse the repository at this point in the history
  • Loading branch information
MujahedSafaa authored Sep 4, 2024
1 parent da91684 commit 487aa1e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
6 changes: 3 additions & 3 deletions docs/rules/no_window_global.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Disallows the use of the `window` object.

Using the `window` global is deprecated and scheduled for removal in Deno 2.0.
Deno does not have a window and `typeof window === "undefined"` is often used to
tell if the code is running in the browser.
The `window` global is no longer available in Deno. Deno does not have a window
and `typeof window === "undefined"` is often used to tell if the code is running
in the browser.

### Invalid:

Expand Down
3 changes: 1 addition & 2 deletions src/rules/no_window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ use if_chain::if_chain;
pub struct NoWindow;

const CODE: &str = "no-window";
const MESSAGE: &str =
"window is deprecated and scheduled for removal in Deno 2.0";
const MESSAGE: &str = "Window is no longer available in Deno";
const HINT: &str = "Instead, use `globalThis`";
const FIX_DESC: &str = "Rename window to globalThis";

Expand Down
2 changes: 1 addition & 1 deletion www/static/docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,7 @@
},
{
"code": "no-window",
"docs": "Disallows the use of the `window` object.\n\nUsing the `window` global is deprecated and scheduled for removal in Deno 2.0.\nDeno does not have a window and `typeof window === \"undefined\"` is often used to\ntell if the code is running in the browser.\n\n### Invalid:\n\n```typescript\nconst a = await window.fetch(\"https://deno.land\");\n\nconst b = window.Deno.metrics();\nconsole.log(window);\n\nwindow.addEventListener(\"load\", () => {\n console.log(\"Loaded.\");\n});\n```\n\n### Valid:\n\n```typescript\nconst a1 = await fetch(\"https://deno.land\");\nconst a2 = await globalThis.fetch(\"https://deno.land\");\nconst a3 = await self.fetch(\"https://deno.land\");\n\nconst b1 = Deno.metrics();\nconst b2 = globalThis.Deno.metrics();\nconst b3 = self.Deno.metrics();\nconsole.log(globalThis);\n\naddEventListener(\"load\", () => {\n console.log(\"Loaded.\");\n});\n```\n",
"docs": "Disallows the use of the `window` object.\n\nThe `window` global is no longer available in Deno. Deno does not have a window\nand `typeof window === \"undefined\"` is often used to tell if the code is running\nin the browser.\n\n### Invalid:\n\n```typescript\nconst a = await window.fetch(\"https://deno.land\");\n\nconst b = window.Deno.metrics();\nconsole.log(window);\n\nwindow.addEventListener(\"load\", () => {\n console.log(\"Loaded.\");\n});\n```\n\n### Valid:\n\n```typescript\nconst a1 = await fetch(\"https://deno.land\");\nconst a2 = await globalThis.fetch(\"https://deno.land\");\nconst a3 = await self.fetch(\"https://deno.land\");\n\nconst b1 = Deno.metrics();\nconst b2 = globalThis.Deno.metrics();\nconst b3 = self.Deno.metrics();\nconsole.log(globalThis);\n\naddEventListener(\"load\", () => {\n console.log(\"Loaded.\");\n});\n```\n",
"tags": [
"recommended"
]
Expand Down

0 comments on commit 487aa1e

Please sign in to comment.