Skip to content

More robust ESlint config #292

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified src/js/bun.lockb
Binary file not shown.
24 changes: 10 additions & 14 deletions src/js/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -1,29 +1,25 @@
import path from "node:path";
import { default as eslint } from "@eslint/js";
import globals from "globals";
import { fileURLToPath } from "node:url";
import js from "@eslint/js";
import { FlatCompat } from "@eslint/eslintrc";

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all,
});
import tseslint from "typescript-eslint";

// ESLint config for Preact project
export default [
...compat.extends("eslint:recommended"),
eslint.configs.recommended,
...tseslint.configs.recommended,
{ ignores: ["**/node_modules/", "**/dist/"] },
{
languageOptions: {
globals: {
...globals.browser,
...globals.node,
},

ecmaVersion: "latest",
sourceType: "module",
},
rules: {
"@typescript-eslint/ban-ts-comment": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-non-null-assertion": "off",
},
},
];
11 changes: 6 additions & 5 deletions src/js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@
"react-dom": "npm:@preact/[email protected]"
},
"devDependencies": {
"@eslint/js": "^9.29.0",
"bun-types": "^0.5.0",
"eslint": "^9.13.0",
"eslint-config-preact": "^1.5.0",
"prettier": "^3.3.3"
},
"eslintConfig": {
"extends": "preact"
"globals": "^16.2.0",
"prettier": "^3.3.3",
"typescript": "^5.8.3",
"typescript-eslint": "^8.34.0"
},
"license": "MIT",
"scripts": {
"check": "prettier --check . && eslint",
"format": "prettier --write . && eslint --fix"
Expand Down
8 changes: 4 additions & 4 deletions src/js/src/mount.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ export function mountComponent(
reconnectBackoffMultiplier: number,
) {
// Protocols
let httpProtocol = window.location.protocol;
let wsProtocol = `ws${httpProtocol === "https:" ? "s" : ""}:`;
const httpProtocol = window.location.protocol;
const wsProtocol = `ws${httpProtocol === "https:" ? "s" : ""}:`;

// WebSocket route (for Python components)
let wsOrigin: string;
Expand All @@ -41,7 +41,7 @@ export function mountComponent(
}

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

// Replace the prerender element with the real element on the first layout update
if (client.prerenderElement) {
client.onMessage("layout-update", ({ path, model }) => {
client.onMessage("layout-update", () => {
if (client.prerenderElement && client.mountElement) {
client.prerenderElement.replaceWith(client.mountElement);
client.prerenderElement = null;
Expand Down
4 changes: 2 additions & 2 deletions src/js/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ export type ReactPyDjangoClientProps = {
};

export interface DjangoFormProps {
onSubmitCallback: (data: Object) => void;
onSubmitCallback: (data: object) => void;
formId: string;
}

export interface HttpRequestProps {
method: string;
url: string;
body: string;
callback: (status: Number, response: string) => void;
callback: (status: number, response: string) => void;
}