Skip to content

Commit

Permalink
Merge pull request #4688 from opensafely-core/replace-eslint
Browse files Browse the repository at this point in the history
Replace ESLint and Prettier with Biome
  • Loading branch information
tomodwyer authored Oct 18, 2024
2 parents e479abb + 3d624bc commit bce32b3
Show file tree
Hide file tree
Showing 37 changed files with 608 additions and 3,756 deletions.
61 changes: 0 additions & 61 deletions .eslintrc.cjs

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
__pycache__
/assets/dist
/assets/stats.html
/assets/src/scripts/outputs-viewer/coverage
/coverage
/docker/staticfiles/*
/htmlcov
Expand Down
2 changes: 2 additions & 0 deletions assets/src/scripts/_event-log.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ if (document.getElementById("eventLog")) {
});
});

// biome-ignore lint/correctness/noUndeclaredVariables: ESLint to Biome legacy ignore
$(() => {
// biome-ignore lint/correctness/noUndeclaredVariables: ESLint to Biome legacy ignore
$('[data-toggle="tooltip"]').tooltip();
});
}
2 changes: 0 additions & 2 deletions assets/src/scripts/analysis-request-detail.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,7 @@ function generatePDF() {
function formatNumbers() {
const numbers = document.querySelectorAll(`[data-format-number="true"]`);
numbers?.forEach(
// eslint-disable-next-line no-return-assign
(number) =>
// eslint-disable-next-line no-param-reassign
(number.textContent = parseFloat(number.textContent).toLocaleString(
"en-GB",
)),
Expand Down
1 change: 0 additions & 1 deletion assets/src/scripts/application-form.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable array-callback-return, no-param-reassign */
const content = document?.getElementById("applicationForm");
const links = content?.getElementsByTagName("a");

Expand Down
1 change: 0 additions & 1 deletion assets/src/scripts/components.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ document.addEventListener("DOMContentLoaded", () => {
const ul = document.getElementById("table-of-contents");

anchors.forEach((heading) => {
// eslint-disable-next-line no-param-reassign
heading.id = `${slugify(heading.textContent, {
lower: true,
strict: true,
Expand Down
1 change: 0 additions & 1 deletion assets/src/scripts/interactive/components/Alert.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ const beforeUnloadListener = (event) => {
event.preventDefault();
// https://developer.mozilla.org/en-US/docs/Web/API/Window/beforeunload_event#examples
// @ts-ignore
// eslint-disable-next-line no-return-assign, no-param-reassign
return (event.returnValue = "");
};

Expand Down
1 change: 0 additions & 1 deletion assets/src/scripts/interactive/components/Button.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable react/button-has-type */
import { bool, func, node, oneOf, string } from "prop-types";
import React from "react";
import { classNames } from "../utils";
Expand Down
2 changes: 1 addition & 1 deletion assets/src/scripts/interactive/components/Tabs/TabList.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { TabList, Tab } from "@headlessui/react";
import { Tab, TabList } from "@headlessui/react";
import { useAppData } from "../../context";
import { classNames } from "../../utils";

Expand Down
3 changes: 2 additions & 1 deletion assets/src/scripts/interactive/components/Textarea.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ function Textarea({
}) {
const { setFieldValue, values } = useFormikContext();

// biome-ignore lint/correctness/useExhaustiveDependencies: ESLint to Biome legacy ignore
useEffect(() => {
setFieldValue(id, values[id] || value);
}, []); // eslint-disable-line react-hooks/exhaustive-deps
}, []);

return (
<div className={`flex flex-col gap-y-3 text-lg leading-tight ${className}`}>
Expand Down
1 change: 0 additions & 1 deletion assets/src/scripts/interactive/data/schema.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable import/prefer-default-export */
import * as Yup from "yup";

export const codelistSchema = (pageData) =>
Expand Down
2 changes: 0 additions & 2 deletions assets/src/scripts/interactive/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ export function classNames(...classes) {
}

export function delay(ms) {
// eslint-disable-next-line no-promise-executor-return
return new Promise((res) => setTimeout(res, ms));
}

Expand Down Expand Up @@ -68,7 +67,6 @@ export function getAppData({
}

export const removeUndefinedValuesFromObject = (obj) => {
// eslint-disable-next-line no-param-reassign
Object.keys(obj).forEach((key) => obj[key] === undefined && delete obj[key]);
return obj;
};
2 changes: 0 additions & 2 deletions assets/src/scripts/interactive/utils/query-text.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable import/prefer-default-export */

export const queryText = [
"The number of people who had",
"added to their health record each month from",
Expand Down
1 change: 1 addition & 0 deletions assets/src/scripts/interactive/utils/scrollToTop.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { useLocation } from "wouter";
export default function ScrollToTop() {
const [pathname] = useLocation();

// biome-ignore lint/correctness/useExhaustiveDependencies: ESLint to Biome legacy ignore
useEffect(() => {
window.scrollTo(0, 0);
}, [pathname]);
Expand Down
2 changes: 0 additions & 2 deletions assets/src/scripts/outputs-viewer/.gitignore

This file was deleted.

3 changes: 2 additions & 1 deletion assets/src/scripts/outputs-viewer/App.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {
QueryCache,
QueryClient,
QueryClientProvider,
QueryCache,
} from "@tanstack/react-query";
import { ReactQueryDevtools } from "@tanstack/react-query-devtools";
import React, { useState } from "react";
Expand All @@ -23,6 +23,7 @@ const queryClient = new QueryClient({
},
},
queryCache: new QueryCache({
// biome-ignore lint/correctness/noUnusedVariables: ESLint to Biome legacy ignore
onError: (error, query) => {
if (query.meta.errorMessage) {
toastError({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable no-console */
import userEvent from "@testing-library/user-event";
import React from "react";
import { ToastContainer } from "react-toastify";
Expand Down Expand Up @@ -79,7 +78,6 @@ describe("<PrepareButton />", () => {
expect(jsonBody.file_ids).toEqual(fileIds);

return new Promise((resolve) =>
// eslint-disable-next-line no-promise-executor-return
setTimeout(() => {
const res = { url: urls.redirect };
return resolve(JSON.stringify(res));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable no-console */
import userEvent from "@testing-library/user-event";
import React from "react";
import { ToastContainer } from "react-toastify";
Expand All @@ -23,7 +22,6 @@ describe("<PublishButton />", () => {
fetch.mockResponseOnce(
() =>
new Promise((resolve) =>
// eslint-disable-next-line no-promise-executor-return
setTimeout(() => resolve({ body: "ok" }), 100),
),
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable no-console, no-unused-vars, react/prop-types */
import userEvent from "@testing-library/user-event";
import React, { useState } from "react";
import { describe, expect, it, vi } from "vitest";
Expand All @@ -11,9 +10,10 @@ import {
txtFile,
} from "../../helpers/files";
import props from "../../helpers/props";
import { render, screen, waitFor, history } from "../../test-utils";
import { history, render, screen, waitFor } from "../../test-utils";

function FileListWrapper() {
// biome-ignore lint/correctness/noUnusedVariables: ESLint to Biome legacy ignore
const [listVisible, setListVisible] = useState(true);
const [_, setSelectedFile] = useState(false);
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ describe("<Metadata />", () => {
});

it("shows unknown for file size if file size not provided", () => {
// eslint-disable-next-line no-console
console.error = vi.fn();

render(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { csvExample, csvFile } from "../../helpers/files";
import { render, screen } from "../../test-utils";

describe("<Table />", () => {
// biome-ignore lint/style/useConsistentBuiltinInstantiation: ESLint to Biome legacy ignore
const twoThousandRows = `${Array(2000).fill(`b
`)}`.trimEnd();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable no-console */
import React from "react";
import { describe, expect, it, vi } from "vitest";
import Viewer from "../../../components/Viewer/Viewer";
Expand Down
1 change: 0 additions & 1 deletion assets/src/scripts/outputs-viewer/__tests__/test-setup.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable import/no-extraneous-dependencies */
import "@testing-library/jest-dom/vitest";
import { beforeEach, vi } from "vitest";
import createFetchMock from "vitest-fetch-mock";
Expand Down
1 change: 0 additions & 1 deletion assets/src/scripts/outputs-viewer/__tests__/test-utils.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable no-console, import/no-extraneous-dependencies, react/prop-types */
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { render } from "@testing-library/react";
import { createMemoryHistory } from "history";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ function Button({
`}
disabled={disabled}
onClick={onClick}
// eslint-disable-next-line react/button-has-type
type={type}
>
{children}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ function FileList({ authToken, filesUrl, listVisible, setSelectedFile }) {

const listRef = createRef();

// biome-ignore lint/correctness/useExhaustiveDependencies: ESLint to Biome legacy ignore
useEffect(() => {
const selectedItem = data?.find(
(file) => `/${file.name}` === location.pathname,
Expand All @@ -30,8 +31,6 @@ function FileList({ authToken, filesUrl, listVisible, setSelectedFile }) {
if (data) {
setFiles(data);
}

// eslint-disable-next-line react-hooks/exhaustive-deps
}, [isSuccess]);

if (isLoading) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import FormInput from "../Form/Input";
function Filter({ files, listRef, setFiles }) {
const [filter, setFilter] = useState("");

// biome-ignore lint/correctness/useExhaustiveDependencies: ESLint to Biome legacy ignore
useEffect(() => {
const filteredFiles = [...files].map((file) => ({
...file,
visible: file.shortName.toLowerCase().includes(filter.toLowerCase()),
}));

setFiles(filteredFiles);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [filter]);

function filterOnChange(e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ function Iframe({ data, fileName, fileUrl }) {
const [frameHeight, setFrameHeight] = useState(0);
const id = encodeURIComponent(fileUrl).replace(/\W/g, "");

// biome-ignore lint/correctness/useExhaustiveDependencies: ESLint to Biome legacy ignore
useLayoutEffect(() => {
const minHeight = 1000;
if (document.getElementById(id) && window.innerWidth > 991) {
Expand Down
4 changes: 3 additions & 1 deletion assets/src/scripts/outputs-viewer/components/Table/Table.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable react/no-array-index-key */
import PropTypes from "prop-types";
import React from "react";
import { usePapaParse } from "react-papaparse";
Expand All @@ -11,6 +10,7 @@ function TableRow({ row }) {
return (
<tr className="divide-x divide-gray-200 even:bg-gray-50">
{row.map((cell, i) => (
// biome-ignore lint/suspicious/noArrayIndexKey: ESLint to Biome legacy ignore
<TableCell key={i} cell={cell} />
))}
</tr>
Expand All @@ -37,6 +37,7 @@ function Table({ data }) {
<table className="min-w-full divide-y divide-gray-300">
<tbody className="divide-y divide-gray-200 bg-white">
{jsonData.slice(0, 1000).map((row, i) => (
// biome-ignore lint/suspicious/noArrayIndexKey: ESLint to Biome legacy ignore
<TableRow key={i} row={row} />
))}
</tbody>
Expand All @@ -55,6 +56,7 @@ function Table({ data }) {
<table className="min-w-full divide-y divide-gray-300">
<tbody className="divide-y divide-gray-200 bg-white">
{jsonData.map((row, i) => (
// biome-ignore lint/suspicious/noArrayIndexKey: ESLint to Biome legacy ignore
<TableRow key={i} row={row} />
))}
</tbody>
Expand Down
1 change: 0 additions & 1 deletion assets/src/scripts/outputs-viewer/hooks/use-file-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ function longestSubStr(files) {
const splitFileName = file.name.split("/");
if (i === 0) {
initialStr = [];
// eslint-disable-next-line no-return-assign
return (initialStr = splitFileName);
}

Expand Down
2 changes: 1 addition & 1 deletion assets/src/scripts/outputs-viewer/hooks/use-window-size.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import debounce from "just-debounce-it";
import { useState, useEffect } from "react";
import { useEffect, useState } from "react";

// Hook
function useWindowSize(delay = 100) {
Expand Down
2 changes: 1 addition & 1 deletion assets/src/scripts/outputs-viewer/utils/toast.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export function toastDismiss({ toastId }) {
}

export function toastError({ toastId, message, ...args }) {
// eslint-disable-next-line no-console
// biome-ignore lint/suspicious/noConsole: ESLint to Biome legacy ignore
console.error(message, { ...args });

toast.error(message, {
Expand Down
6 changes: 2 additions & 4 deletions assets/src/styles/_datatable.css
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,8 @@
border-radius: 0.375rem;
border-color: var(--color-slate-300);
font-weight: 400;
box-shadow:
0 0 rgba(0, 0, 0, 0),
0 0 rgba(0, 0, 0, 0),
0 1px 2px 0 rgba(0, 0, 0, 0.05);
box-shadow: 0 0 rgba(0, 0, 0, 0), 0 0 rgba(0, 0, 0, 0), 0 1px 2px 0
rgba(0, 0, 0, 0.05);

@media (min-width: 640px) {
font-size: 0.875rem;
Expand Down
Loading

0 comments on commit bce32b3

Please sign in to comment.