Skip to content

Commit 4c41fb1

Browse files
committed
chore(lint): add stricter ESlint rules (in packages/extensions)
1 parent 1e479ee commit 4c41fb1

File tree

6 files changed

+61
-44
lines changed

6 files changed

+61
-44
lines changed

package-lock.json

Lines changed: 24 additions & 24 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/extensions/eslint.config.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import { fixupConfigRules, fixupPluginRules } from "@eslint/compat";
44
import _import from "eslint-plugin-import";
55
import js from "@eslint/js";
66
import { FlatCompat } from "@eslint/eslintrc";
7+
import tsPlugin from "@typescript-eslint/eslint-plugin";
8+
import eslintPluginUnusedImports from "eslint-plugin-unused-imports";
79

810
const __filename = fileURLToPath(import.meta.url);
911
const __dirname = path.dirname(__filename);
@@ -25,6 +27,8 @@ export default [
2527
{
2628
plugins: {
2729
import: fixupPluginRules(_import),
30+
"@typescript-eslint": tsPlugin,
31+
"unused-imports": eslintPluginUnusedImports,
2832
},
2933

3034
languageOptions: {
@@ -34,10 +38,34 @@ export default [
3438
},
3539

3640
rules: {
41+
// Import rules
3742
"import/order": ["error"],
3843
"import/no-unused-modules": ["error"],
44+
"import/no-namespace": ["error"],
45+
"unused-imports/no-unused-imports": ["error"],
46+
3947
"import/no-useless-path-segments": ["error"],
4048
"react/destructuring-assignment": ["error", "always"],
49+
50+
// Coding style rules
51+
"comma-dangle": ["error", "always-multiline"],
52+
"no-unreachable": ["error"],
53+
"prefer-const": ["error"],
54+
"no-unused-vars": [
55+
"error",
56+
{
57+
vars: "all",
58+
varsIgnorePattern: "^_",
59+
args: "after-used",
60+
argsIgnorePattern: "^_",
61+
},
62+
],
63+
"@typescript-eslint/no-explicit-any": ["error"],
64+
semi: ["error", "always"],
65+
66+
// Identation rules
67+
indent: ["error", 2],
68+
4169
"no-restricted-properties": [
4270
"error",
4371
{

packages/extensions/src/app/(dashboard)/error.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
//Error fallback component
44
export default function Error({
5-
error,
5+
_error,
66
reset,
77
}: {
8-
error: Error;
8+
_error: Error;
99
reset: () => void;
1010
}) {
1111
return (

packages/extensions/src/app/(dashboard)/layout.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"use client";
2-
import * as React from "react";
2+
import React from "react";
33
import { Box } from "@mui/material";
44
import {
55
OIDCSecure,

packages/extensions/src/app/global-error.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
// Error fallback
44
export default function GlobalError({
5-
error,
5+
_error,
66
reset,
77
}: {
8-
error: Error;
8+
_error: Error;
99
reset: () => void;
1010
}) {
1111
return (

packages/extensions/src/gubbins/components/OwnerMonitor/OwnerMonitor.tsx

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,11 @@
11
"use client";
2-
import React, { useEffect, useMemo, useState } from "react";
2+
import React, { useMemo, useState } from "react";
33
import { useOidcAccessToken } from "@axa-fr/react-oidc";
44
import {
55
fetcher,
66
useOIDCContext,
77
} from "@dirac-grid/diracx-web-components/hooks";
8-
import {
9-
Alert,
10-
Box,
11-
Button,
12-
Snackbar,
13-
TextField,
14-
Typography,
15-
} from "@mui/material";
8+
import { Alert, Box, Button, Snackbar, TextField } from "@mui/material";
169
import {
1710
createColumnHelper,
1811
getCoreRowModel,
@@ -55,17 +48,13 @@ export default function OwnerMonitor() {
5548
name, // Set the name
5649
}));
5750
setOwners(transformedData);
58-
} catch (err) {
51+
} catch {
5952
setError("Failed to fetch owners");
6053
} finally {
6154
setIsLoading(false);
6255
}
6356
};
6457

65-
useEffect(() => {
66-
fetchOwners();
67-
}, [accessToken]);
68-
6958
// Handle adding a new owner
7059
const handleAddOwner = async () => {
7160
if (!ownerName) return setError("Owner name cannot be empty.");
@@ -78,7 +67,7 @@ export default function OwnerMonitor() {
7867
setSuccess(`Owner "${ownerName}" added successfully.`);
7968
setOwnerName("");
8069
fetchOwners(); // Refresh the owners list
81-
} catch (err) {
70+
} catch {
8271
setError("Failed to add owner.");
8372
}
8473
};

0 commit comments

Comments
 (0)