Skip to content

Commit

Permalink
Increase linting strictness
Browse files Browse the repository at this point in the history
  • Loading branch information
jb3 committed Aug 17, 2024
1 parent 46879b0 commit 6ab7698
Show file tree
Hide file tree
Showing 10 changed files with 60 additions and 58 deletions.
36 changes: 19 additions & 17 deletions thallium-frontend/eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import js from '@eslint/js'
import globals from 'globals'
import reactHooks from 'eslint-plugin-react-hooks'
import reactRefresh from 'eslint-plugin-react-refresh'
import tseslint from 'typescript-eslint'
import react from 'eslint-plugin-react'
import js from "@eslint/js"
import globals from "globals"
import reactHooks from "eslint-plugin-react-hooks"
import reactRefresh from "eslint-plugin-react-refresh"
import tseslint from "typescript-eslint"
import react from "eslint-plugin-react"

export default tseslint.config(
{ ignores: ['dist'] },
{ ignores: ["dist"] },
{
extends: [js.configs.recommended, ...tseslint.configs.strictTypeChecked, ...tseslint.configs.stylisticTypeChecked],
files: ['**/*.{ts,tsx}'],
files: ["**/*.{ts,tsx}"],
languageOptions: {
ecmaVersion: 2020,
globals: globals.browser,
parserOptions: {
project: ['./tsconfig.node.json', './tsconfig.app.json'],
project: ["./tsconfig.node.json", "./tsconfig.app.json"],
tsconfigRootDir: import.meta.dirname,
},
},
Expand All @@ -24,21 +24,23 @@ export default tseslint.config(
}
},
plugins: {
'react-hooks': reactHooks,
'react-refresh': reactRefresh,
"react-hooks": reactHooks,
"react-refresh": reactRefresh,
react,
},
rules: {
...reactHooks.configs.recommended.rules,
'react-refresh/only-export-components': [
'warn',
"react-refresh/only-export-components": [
"warn",
{ allowConstantExport: true },
],
...react.configs.recommended.rules,
...react.configs['jsx-runtime'].rules,
'@typescript-eslint/no-empty-object-type': ["error", {
allowInterfaces: 'with-single-extends',
}]
...react.configs["jsx-runtime"].rules,
"@typescript-eslint/no-empty-object-type": ["error", {
allowInterfaces: "with-single-extends",
}],
"semi": ["error", "always"],
"quotes": ["error", "double"],
},
},
)
18 changes: 9 additions & 9 deletions thallium-frontend/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import styled, { createGlobalStyle, ThemeProvider } from 'styled-components';
import { useEffect, useState } from 'react';
import styled, { createGlobalStyle, ThemeProvider } from "styled-components";
import { useEffect, useState } from "react";
import {
createBrowserRouter,
RouterProvider,
} from "react-router-dom";

import themes from './themes';
import themes from "./themes";

import Header from "./components/Header";

import LandingPage from "./pages/LandingPage"
import ErrorPage from "./pages/ErrorPage"
import LandingPage from "./pages/LandingPage";
import ErrorPage from "./pages/ErrorPage";


const GlobalStyle = createGlobalStyle`
Expand Down Expand Up @@ -47,7 +47,7 @@ const AppContainer = styled.div`

const BodySeparator = styled.div`
flex-grow: 1;
`
`;

const ContentContainer = styled.div`
padding: 1rem;
Expand All @@ -68,7 +68,7 @@ function App() {
const theme = isDarkMode ? themes.dark : themes.light;

useEffect(() => {
const prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
const prefersDark = window.matchMedia("(prefers-color-scheme: dark)").matches;

setIsDarkMode(prefersDark);
}, []);
Expand All @@ -92,7 +92,7 @@ function App() {
</div>
</AppContainer>
</ThemeProvider>
)
);
}

export default App
export default App;
2 changes: 1 addition & 1 deletion thallium-frontend/src/components/Card.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import styled from 'styled-components';
import styled from "styled-components";

const CardContainer = styled.div`
border: 3px solid ${({ theme }) => theme.borderColor};
Expand Down
2 changes: 1 addition & 1 deletion thallium-frontend/src/components/Header.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import styled from 'styled-components';
import styled from "styled-components";

const HeaderContainer = styled.header`
display: flex;
Expand Down
12 changes: 6 additions & 6 deletions thallium-frontend/src/main.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { StrictMode } from 'react'
import { createRoot } from 'react-dom/client'
import App from './App.tsx'
import '@fontsource-variable/fira-code';
import { StrictMode } from "react";
import { createRoot } from "react-dom/client";
import App from "./App.tsx";
import "@fontsource-variable/fira-code";

// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
createRoot(document.getElementById('root')!).render(
createRoot(document.getElementById("root")!).render(
<StrictMode>
<App />
</StrictMode>,
)
);
14 changes: 7 additions & 7 deletions thallium-frontend/src/pages/ErrorPage.tsx
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
import { useRouteError, isRouteErrorResponse } from 'react-router-dom';
import { useRouteError, isRouteErrorResponse } from "react-router-dom";

import Card from '../components/Card';
import Card from "../components/Card";

const ErrorPage = () => {
const error = useRouteError();

let title = 'Unexpected Error', message, isUnexpected = false;
let title = "Unexpected Error", message, isUnexpected = false;

if (isRouteErrorResponse(error)) {
if (error.status === 404) {
title = 'Not Found';
message = 'The requested page could not be found.';
title = "Not Found";
message = "The requested page could not be found.";
} else {
message = error.statusText;
}
} else if (error instanceof Error) {
message = error.message;
isUnexpected = true;
} else if (typeof error === 'string') {
} else if (typeof error === "string") {
message = error;
isUnexpected = true;
} else {
console.error(error);
message = 'Unknown error';
message = "Unknown error";
isUnexpected = true;
}

Expand Down
2 changes: 1 addition & 1 deletion thallium-frontend/src/pages/LandingPage.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Card from '../components/Card';
import Card from "../components/Card";

const LandingPage = () => {
return (
Expand Down
2 changes: 1 addition & 1 deletion thallium-frontend/src/styled-components.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Theme } from './themes';
import type { Theme } from "./themes";

declare module "styled-components" {
export interface DefaultTheme extends Theme { }
Expand Down
24 changes: 12 additions & 12 deletions thallium-frontend/src/themes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,20 @@ interface ThemesStore {

const themes: ThemesStore = {
light: {
backgroundColor: '#f0f0f0',
textColor: '#000',
borderColor: '#ccc',
linkColor: '#7272ff',
cardBackgroundColor: '#ebebeb',
cardShadow: '#d0d0d0',
backgroundColor: "#f0f0f0",
textColor: "#000",
borderColor: "#ccc",
linkColor: "#7272ff",
cardBackgroundColor: "#ebebeb",
cardShadow: "#d0d0d0",
},
dark: {
backgroundColor: '#333',
textColor: '#fff',
borderColor: '#949494',
linkColor: '#8f8fff',
cardBackgroundColor: '#2c2c2c',
cardShadow: '#242323',
backgroundColor: "#333",
textColor: "#fff",
borderColor: "#949494",
linkColor: "#8f8fff",
cardBackgroundColor: "#2c2c2c",
cardShadow: "#242323",
},
};

Expand Down
6 changes: 3 additions & 3 deletions thallium-frontend/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";

// https://vitejs.dev/config/
export default defineConfig({
plugins: [react()],
})
});

0 comments on commit 6ab7698

Please sign in to comment.