Skip to content

Commit

Permalink
enable Biome rule noUnusedVariables (#5239)
Browse files Browse the repository at this point in the history
* update biome to 1.9.4
* enable noUnusedVariables rule
  • Loading branch information
bilalabbad authored Dec 18, 2024
1 parent 567a815 commit dad6de9
Show file tree
Hide file tree
Showing 25 changed files with 79 additions and 65 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ jobs:
- name: Setup Biome
uses: biomejs/setup-biome@v2
with:
version: 1.9.3
version: 1.9.4
- name: Run Biome
working-directory: ./frontend/app
run: biome ci .
Expand Down
10 changes: 7 additions & 3 deletions frontend/app/biome.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
{
"$schema": "https://biomejs.dev/schemas/1.9.3/schema.json",
"vcs": { "enabled": false, "clientKind": "git", "useIgnoreFile": false },
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
"vcs": {
"clientKind": "git",
"enabled": true,
"useIgnoreFile": true
},
"files": {
"ignoreUnknown": false,
"ignore": [
Expand Down Expand Up @@ -54,7 +58,7 @@
"noUndeclaredVariables": "off",
"noUnusedFunctionParameters": "off",
"noUnusedImports": "error",
"noUnusedVariables": "off",
"noUnusedVariables": "error",
"useExhaustiveDependencies": "off",
"useHookAtTopLevel": "off",
"useImportExtensions": "off"
Expand Down
72 changes: 36 additions & 36 deletions frontend/app/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion frontend/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
"vite-tsconfig-paths": "^4.3.2"
},
"devDependencies": {
"@biomejs/biome": "1.9.3",
"@biomejs/biome": "1.9.4",
"@graphql-codegen/cli": "^5.0.2",
"@graphql-codegen/typescript": "^4.0.9",
"@playwright/test": "^1.47.2",
Expand Down
3 changes: 2 additions & 1 deletion frontend/app/src/api/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ const authMiddleware: Middleware = {

request.headers.set("Authorization", `Bearer ${newToken.access_token}`);
return fetch(request);
} catch (e) {
} catch (error) {
console.error(error);
return response;
}
}
Expand Down
2 changes: 1 addition & 1 deletion frontend/app/src/components/display/password-display.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const PasswordDisplay = (props: tPasswordDisplayProps) => {

const passwordCircles = Array.from(
Array(value.length < MAX_PASSWORD_DOTS_DISPLAY ? value.length : MAX_PASSWORD_DOTS_DISPLAY)
).map((value: null, index: number) => (
).map((_, index: number) => (
<Icon key={index} icon={"mdi:circle-medium"} className="text-gray-900" />
));

Expand Down
3 changes: 2 additions & 1 deletion frontend/app/src/components/form/fields/json.field.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ const JsonField = ({
// Store the value as JSON
const newValue = JSON.parse(value);
field.onChange(updateFormFieldValue(newValue, defaultValue));
} catch (e) {
} catch (error) {
console.error(error);
field.onChange(updateFormFieldValue(value, defaultValue));
}
}}
Expand Down
1 change: 1 addition & 0 deletions frontend/app/src/components/inputs/input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export const Input = forwardRef((props: any, ref: any) => {
props.type === "password" ? "pr-14" : ""
)}
type={type === "password" && display ? "text" : type}
ref={ref}
{...propsToPass}
/>

Expand Down
2 changes: 2 additions & 0 deletions frontend/app/src/components/inputs/multiple-input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export const MultipleInput = React.forwardRef((props: MultipleInputProps, ref: a
error && error?.message ? "ring-red-500 focus:ring-red-600" : ""
)}
data-testid="multi-select-input"
ref={ref}
>
Empty list
</div>
Expand Down Expand Up @@ -75,6 +76,7 @@ export const MultipleInput = React.forwardRef((props: MultipleInputProps, ref: a
disabled ? "cursor-not-allowed bg-gray-100" : ""
)}
data-testid="multi-select-input"
ref={ref}
>
{value?.map((item: string | SelectOption, index: number) => (
<Badge
Expand Down
8 changes: 6 additions & 2 deletions frontend/app/src/components/inputs/select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,8 @@ export const Select = forwardRef<HTMLDivElement, SelectProps>((props, ref) => {
setIsLoading(false);

checkSchemaUpdate();
} catch (e) {
} catch (error) {
console.error(error);
setIsLoading(false);
}
};
Expand Down Expand Up @@ -500,7 +501,8 @@ export const Select = forwardRef<HTMLDivElement, SelectProps>((props, ref) => {
setOpen(false);

setIsLoading(false);
} catch (e) {
} catch (error) {
console.error(error);
setIsLoading(false);
}
};
Expand Down Expand Up @@ -563,6 +565,7 @@ export const Select = forwardRef<HTMLDivElement, SelectProps>((props, ref) => {

setIsLoading(false);
} catch (error) {
console.error(error);
setIsLoading(false);
}
};
Expand Down Expand Up @@ -602,6 +605,7 @@ export const Select = forwardRef<HTMLDivElement, SelectProps>((props, ref) => {

setIsLoading(false);
} catch (error) {
console.error(error);
setIsLoading(false);
}
};
Expand Down
1 change: 1 addition & 0 deletions frontend/app/src/components/notifications.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export const Notifications = (props: any) => {
${queryString}
`;

// biome-ignore lint/correctness/noUnusedVariables: to have an example component using subscriptions
const { data } = useSubscription(query);

return <div className="absolute">OK</div>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { toast } from "react-toastify";
import { StringParam, useQueryParam } from "use-query-params";
import { ArtifactRepoDiff } from "./artifact-repo-diff";

export const ArtifactsDiff = forwardRef((props, ref) => {
export const ArtifactsDiff = forwardRef((_, ref) => {
const [artifactsDiff, setArtifactsDiff] = useState({});
const { "*": branchName } = useParams();
const [branchOnly] = useQueryParam(QSP.BRANCH_FILTER_BRANCH_ONLY, StringParam);
Expand Down
2 changes: 1 addition & 1 deletion frontend/app/src/screens/diff/checks/checks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { useParams } from "react-router-dom";
import { ChecksSummary } from "./checks-summary";
import { Validator } from "./validator";

export const Checks = forwardRef((props, ref) => {
export const Checks = forwardRef((_, ref) => {
const { proposedChangeId } = useParams();

const { loading, error, data, refetch } = useQuery(GET_VALIDATORS, {
Expand Down
5 changes: 3 additions & 2 deletions frontend/app/src/screens/diff/file-diff/files-diff.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { useParams } from "react-router-dom";
import { StringParam, useQueryParam } from "use-query-params";
import { FileRepoDiff } from "./file-repo-diff";

export const FilesDiff = forwardRef((props, ref) => {
export const FilesDiff = forwardRef((_, ref) => {
const [filesDiff, setFilesDiff] = useState({});
const { "*": branchName } = useParams();
const [branchOnly] = useQueryParam(QSP.BRANCH_FILTER_BRANCH_ONLY, StringParam);
Expand Down Expand Up @@ -45,7 +45,8 @@ export const FilesDiff = forwardRef((props, ref) => {
if (filesResult[branch]) {
setFilesDiff(filesResult[branch]);
}
} catch (err) {
} catch (error) {
console.error(error);
setError(true);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import { useParams } from "react-router-dom";
import { toast } from "react-toastify";
import { StringParam, useQueryParam } from "use-query-params";

const IpamIPAddressesList = forwardRef((props, ref) => {
const IpamIPAddressesList = forwardRef((_, ref) => {
const { prefix } = useParams();
const [namespace] = useQueryParam(IPAM_QSP.NAMESPACE, StringParam);
const [isLoading, setIsLoading] = useState(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useParams } from "react-router-dom";
import IpAddressSummary from "./ip-address-summary";
import IpamIPAddressesList from "./ipam-ip-address-list";

const IpamIPAddresses = forwardRef((props, ref) => {
const IpamIPAddresses = forwardRef((_, ref) => {
const { ip_address } = useParams();

if (ip_address) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import { useParams } from "react-router-dom";
import { toast } from "react-toastify";
import { StringParam, useQueryParam } from "use-query-params";

const IpamIPPrefixDetails = forwardRef((props, ref) => {
const IpamIPPrefixDetails = forwardRef((_, ref) => {
const { prefix } = useParams();
const branch = useAtomValue(currentBranchAtom);
const date = useAtomValue(datetimeAtom);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import { useParams } from "react-router-dom";
import { toast } from "react-toastify";
import { StringParam, useQueryParam } from "use-query-params";

const IpamIPPrefixesSummaryList = forwardRef((props, ref) => {
const IpamIPPrefixesSummaryList = forwardRef((_, ref) => {
const { prefix } = useParams();
const branch = useAtomValue(currentBranchAtom);
const date = useAtomValue(datetimeAtom);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useParams } from "react-router-dom";
import IpamIPPrefixesSummaryDetails from "./ipam-prefixes-summary-details";
import IpamIPPrefixesSummaryList from "./ipam-prefixes-summary-list";

const IpamIPPrefixesSummary = forwardRef((props, ref) => {
const IpamIPPrefixesSummary = forwardRef((_, ref) => {
const { prefix } = useParams();

if (prefix) {
Expand Down
2 changes: 1 addition & 1 deletion frontend/app/src/screens/ipam/prefixes/ipam-prefixes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { StringParam, useQueryParam } from "use-query-params";
import IpamIPPrefixDetails from "./ipam-prefix-details";
import IpamIPPrefixesSummary from "./ipam-prefixes-summary";

const IpamIPPrefixes = forwardRef((props, ref) => {
const IpamIPPrefixes = forwardRef((_, ref) => {
const [qspTab] = useQueryParam(IPAM_QSP.TAB, StringParam);

switch (qspTab) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ export const PcMergeButton = ({

await graphqlClient.reFetchObservableQueries();
toast(<Alert type={ALERT_TYPES.SUCCESS} message={"Proposed changes merged successfully!"} />);
} catch (error: any) {
} catch (error) {
console.error(error);

toast(
<Alert
type={ALERT_TYPES.SUCCESS}
Expand Down
Loading

0 comments on commit dad6de9

Please sign in to comment.