Skip to content

Commit 50d4e1c

Browse files
authored
More robust ESlint config (#292)
1 parent 0ca0f1d commit 50d4e1c

File tree

5 files changed

+22
-25
lines changed

5 files changed

+22
-25
lines changed

src/js/bun.lockb

-51.1 KB
Binary file not shown.

src/js/eslint.config.mjs

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,25 @@
1-
import path from "node:path";
1+
import { default as eslint } from "@eslint/js";
22
import globals from "globals";
3-
import { fileURLToPath } from "node:url";
4-
import js from "@eslint/js";
5-
import { FlatCompat } from "@eslint/eslintrc";
6-
7-
const __filename = fileURLToPath(import.meta.url);
8-
const __dirname = path.dirname(__filename);
9-
const compat = new FlatCompat({
10-
baseDirectory: __dirname,
11-
recommendedConfig: js.configs.recommended,
12-
allConfig: js.configs.all,
13-
});
3+
import tseslint from "typescript-eslint";
144

155
// ESLint config for Preact project
166
export default [
17-
...compat.extends("eslint:recommended"),
7+
eslint.configs.recommended,
8+
...tseslint.configs.recommended,
9+
{ ignores: ["**/node_modules/", "**/dist/"] },
1810
{
1911
languageOptions: {
2012
globals: {
2113
...globals.browser,
2214
...globals.node,
2315
},
24-
2516
ecmaVersion: "latest",
2617
sourceType: "module",
2718
},
19+
rules: {
20+
"@typescript-eslint/ban-ts-comment": "off",
21+
"@typescript-eslint/no-explicit-any": "off",
22+
"@typescript-eslint/no-non-null-assertion": "off",
23+
},
2824
},
2925
];

src/js/package.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,15 @@
99
"react-dom": "npm:@preact/[email protected]"
1010
},
1111
"devDependencies": {
12+
"@eslint/js": "^9.29.0",
1213
"bun-types": "^0.5.0",
1314
"eslint": "^9.13.0",
14-
"eslint-config-preact": "^1.5.0",
15-
"prettier": "^3.3.3"
16-
},
17-
"eslintConfig": {
18-
"extends": "preact"
15+
"globals": "^16.2.0",
16+
"prettier": "^3.3.3",
17+
"typescript": "^5.8.3",
18+
"typescript-eslint": "^8.34.0"
1919
},
20+
"license": "MIT",
2021
"scripts": {
2122
"check": "prettier --check . && eslint",
2223
"format": "prettier --write . && eslint --fix"

src/js/src/mount.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ export function mountComponent(
1414
reconnectBackoffMultiplier: number,
1515
) {
1616
// Protocols
17-
let httpProtocol = window.location.protocol;
18-
let wsProtocol = `ws${httpProtocol === "https:" ? "s" : ""}:`;
17+
const httpProtocol = window.location.protocol;
18+
const wsProtocol = `ws${httpProtocol === "https:" ? "s" : ""}:`;
1919

2020
// WebSocket route (for Python components)
2121
let wsOrigin: string;
@@ -41,7 +41,7 @@ export function mountComponent(
4141
}
4242

4343
// Embed the initial HTTP path into the WebSocket URL
44-
let componentUrl = new URL(`${wsOrigin}/${urlPrefix}/${componentPath}`);
44+
const componentUrl = new URL(`${wsOrigin}/${urlPrefix}/${componentPath}`);
4545
componentUrl.searchParams.append("http_pathname", window.location.pathname);
4646
if (window.location.search) {
4747
componentUrl.searchParams.append("http_search", window.location.search);
@@ -66,7 +66,7 @@ export function mountComponent(
6666

6767
// Replace the prerender element with the real element on the first layout update
6868
if (client.prerenderElement) {
69-
client.onMessage("layout-update", ({ path, model }) => {
69+
client.onMessage("layout-update", () => {
7070
if (client.prerenderElement && client.mountElement) {
7171
client.prerenderElement.replaceWith(client.mountElement);
7272
client.prerenderElement = null;

src/js/src/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ export type ReactPyDjangoClientProps = {
1919
};
2020

2121
export interface DjangoFormProps {
22-
onSubmitCallback: (data: Object) => void;
22+
onSubmitCallback: (data: object) => void;
2323
formId: string;
2424
}
2525

2626
export interface HttpRequestProps {
2727
method: string;
2828
url: string;
2929
body: string;
30-
callback: (status: Number, response: string) => void;
30+
callback: (status: number, response: string) => void;
3131
}

0 commit comments

Comments
 (0)