Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
jsterner30 committed Sep 21, 2024
1 parent aa9c8f6 commit 6780104
Show file tree
Hide file tree
Showing 11 changed files with 818 additions and 424 deletions.
6 changes: 6 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
parserOptions: {
project: ['./tsconfig.eslint.json', './server/tsconfig.json']
},
ignorePatterns: ['vite.config.ts', 'dist'],
};
1,136 changes: 743 additions & 393 deletions package-lock.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"vite-plugin-dts": "^3.3.1"
},
"devDependencies": {
"@babel/plugin-proposal-private-property-in-object": "^7.21.11",
"eslint": "^8.57.0",
"standard": "^17.0.0",
"ts-standard": "^12.0.1"
Expand Down
4 changes: 4 additions & 0 deletions tsconfig.eslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extends": "./tsconfig.json",
"include": ["server/src/**/*.ts"]
}
26 changes: 26 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"compilerOptions": {
"target": "ESNext",
"useDefineForClassFields": true,
"module": "CommonJS",
"lib": ["esnext"],
"skipLibCheck": true,
"outDir": "./dist",
"declaration": true,
"esModuleInterop": true,

"resolveJsonModule": true,
"isolatedModules": true,

/* Linting */
"strict": true,
"noUnusedLocals": false,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true
},
"include": [
"server/src/**/*.ts",
"shared/**/*.ts",
"web/src/**/*.tsx"
]
}
11 changes: 0 additions & 11 deletions web/eslintrc.js

This file was deleted.

26 changes: 23 additions & 3 deletions web/package-lock.json

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

1 change: 1 addition & 0 deletions web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
},
"devDependencies": {
"@babel/core": "^7.23.9",
"@babel/plugin-proposal-private-property-in-object": "^7.21.11",
"@babel/preset-env": "^7.23.9",
"@babel/preset-typescript": "^7.23.3",
"@testing-library/jest-dom": "^6.4.2",
Expand Down
9 changes: 6 additions & 3 deletions web/src/components/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,11 @@ export const Main = memo(() => {
const client = useContext(ClientContext);

const quoteLoad = useLoad(async (abort) => {
console.log('hehehehe')
const response = await fetch('https://bible-api.com/john 3:16', { signal: abort }).then((res) => res.json());
return response.text
}, []);

const [_addLoadState, doAdd] = useTriggerLoad(async (abort) => {
const [addLoadState, doAdd] = useTriggerLoad(async (abort) => {
if (!client) {
return
}
Expand All @@ -32,7 +31,11 @@ export const Main = memo(() => {
return (
<div>
<blockquote>{quoteLoad.value}</blockquote>
<button onClick={() => { doAdd() }}>Add</button>
{addLoadState.pending ? (
<div>Adding...</div>
) : (
<button onClick={() => { doAdd() }}>Add</button>
)}
</div>
);
});
15 changes: 8 additions & 7 deletions web/src/util/hook.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
import { useCallback, useRef } from "react";

/* eslint-disable react-hooks/exhaustive-deps */

/**
* Returns function with stable reference for the passed callback.
*/
export function useHandler<F extends Function>(fn: F): F {
const ref = useRef<F>();
const ref = useRef<F>(fn);

ref.current = fn;

return useCallback(
// Cannot define args using Parameters<F> when F extends Function
// https://github.com/microsoft/TypeScript/issues/31881
(function (this: ThisType<F>, ...args: unknown[]) {
return Reflect.apply(ref.current!, this, args);
} as Function) as F,
[],
);
}
// eslint-disable-next-line react-hooks/exhaustive-deps
[]
);
}
7 changes: 0 additions & 7 deletions web/tsconfig.eslint.json

This file was deleted.

0 comments on commit 6780104

Please sign in to comment.