Skip to content

Commit

Permalink
Actually run eslint ;) (#1530)
Browse files Browse the repository at this point in the history
* Bump eslint version slightly so typescript linting works again.
* Run eslint for copilot and react-client, in addition to frontend.
* Ensure we're only linting ./src for react-client.
* Switch on TypeScript linting for react-client, disable it for copilot (for now).
* Fix newly emerged eslint errors (now that linting is working again).
  • Loading branch information
dokterbob authored Nov 19, 2024
1 parent 45866b2 commit 2bd47f5
Show file tree
Hide file tree
Showing 10 changed files with 271 additions and 268 deletions.
2 changes: 1 addition & 1 deletion frontend/src/components/atoms/buttons/githubButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import GithubIcon from 'assets/github';

import { useConfig } from 'client-types/*';

interface Props extends ButtonProps {}
type Props = ButtonProps;

export default function GithubButton({ ...props }: Props) {
const { config } = useConfig();
Expand Down
10 changes: 7 additions & 3 deletions frontend/src/components/atoms/inputs/SliderInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,13 @@ const SliderInput = ({
const parsedValue = parseFloat(event.target.value);
const { min, max, onChange } = sliderProps;

if (max && parsedValue > max) setField && setField(id, max);
else if (min && parsedValue < min) setField && setField(id, min);
else onChange && onChange(event, parsedValue, 0);
if (max && parsedValue > max) {
setField?.(id, max);
} else if (min && parsedValue < min) {
setField?.(id, min);
} else {
onChange?.(event, parsedValue, 0);
}
};

return (
Expand Down
8 changes: 5 additions & 3 deletions frontend/src/components/molecules/auth/AuthLogin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,11 @@ const AuthLogin = ({
}

try {
showSignIn
? await onPasswordSignIn(email, password, callbackUrl)
: onSignUp && (await onSignUp(email, password, callbackUrl));
if (showSignIn) {
await onPasswordSignIn(email, password, callbackUrl);
} else {
await onSignUp?.(email, password, callbackUrl);
}
} catch (err: unknown) {
if (err instanceof Error) {
setErrorState(err.message);
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/hooks/useUpload.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ const useUpload = ({ onError, onResolved, options, spec }: useUploadProps) => {
(acceptedFiles: FileWithPath[], fileRejections: FileRejection[]) => {
if (fileRejections.length > 0) {
if (fileRejections[0].errors[0].code === 'file-too-large') {
onError && onError(`File is larger than ${spec.max_size_mb} MB`);
onError?.(`File is larger than ${spec.max_size_mb} MB`);
} else {
onError && onError(fileRejections[0].errors[0].message);
onError?.(fileRejections[0].errors[0].message);
}
}

Expand Down
2 changes: 1 addition & 1 deletion libs/copilot/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"dev": "vite",
"build": "vite build",
"preview": "vite preview",
"lint": "eslint ./src --ext .ts,.tsx && tsc --noemit",
"lint": "eslint ./src --ext .ts,.tsx",
"format": "prettier src/**/*.{ts,tsx} --write --loglevel error",
"storybook": "storybook dev -p 6006",
"build-storybook": "storybook build"
Expand Down
2 changes: 1 addition & 1 deletion libs/react-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"scripts": {
"build": "tsup src/index.ts --clean --format esm,cjs --dts --external react --external recoil --minify --sourcemap --treeshake",
"dev": "tsup src/index.ts --clean --format esm,cjs --dts --external react --external recoil --minify --sourcemap --treeshake",
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"lint": "eslint ./src --ext ts,tsx --report-unused-disable-directives --max-warnings 0 && tsc --noemit",
"format": "prettier **/*.{ts,tsx} --write --loglevel error",
"test": "echo no tests yet",
"prepublishOnly": "pnpm run build"
Expand Down
6 changes: 3 additions & 3 deletions libs/react-client/src/types/element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ export interface IFileElement extends TMessageElement<'file'> {
type: 'file';
}

export interface IPlotlyElement extends TMessageElement<'plotly'> {}
export type IPlotlyElement = TMessageElement<'plotly'>;

export interface ITasklistElement extends TElement<'tasklist'> {}
export type ITasklistElement = TElement<'tasklist'>;

export interface IDataframeElement extends TMessageElement<'dataframe'> {}
export type IDataframeElement = TMessageElement<'dataframe'>;
6 changes: 3 additions & 3 deletions libs/react-client/src/utils/token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,23 @@ const tokenKey = 'token';
export function getToken() {
try {
return localStorage.getItem(tokenKey);
} catch (e) {
} catch (_) {
return;
}
}

export function setToken(token: string) {
try {
return localStorage.setItem(tokenKey, token);
} catch (e) {
} catch (_) {
return;
}
}

export function removeToken() {
try {
return localStorage.removeItem(tokenKey);
} catch (e) {
} catch (_) {
return;
}
}
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
"@trivago/prettier-plugin-sort-imports": "^4.3.0",
"@types/react": "^18.2.15",
"@types/react-dom": "^18.2.7",
"@typescript-eslint/eslint-plugin": "^6.0.0",
"@typescript-eslint/parser": "^6.0.0",
"@typescript-eslint/eslint-plugin": "^8.15.0",
"@typescript-eslint/parser": "^8.15.0",
"cypress": "12.9.0",
"dotenv": "^16.3.1",
"eslint": "^8.48.0",
"eslint": "^8.57.1",
"husky": "^9.1.6",
"kill-port": "^2.0.1",
"lint-staged": "^13.3.0",
Expand All @@ -21,7 +21,7 @@
"test": "pnpm exec ts-node ./cypress/support/e2e.ts",
"test:ui": "cd frontend && pnpm test",
"prepare": "husky",
"lintUi": "cd frontend && pnpm run lint",
"lintUi": "pnpm run --parallel lint",
"formatUi": "cd frontend && pnpm run format",
"lintPython": "cd backend && poetry run dmypy run --timeout 600 -- chainlit/ tests/",
"formatPython": "black `git ls-files | grep '.py$'` && isort --profile=black .",
Expand Down
Loading

0 comments on commit 2bd47f5

Please sign in to comment.