fix: correct code after adding linting config
This commit is contained in:
3
. prettierignore
Normal file
3
. prettierignore
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
node_modules
|
||||||
|
.yarn
|
||||||
|
.next
|
||||||
@@ -1,3 +1,24 @@
|
|||||||
{
|
{
|
||||||
"extends": "next/core-web-vitals"
|
"env": {
|
||||||
|
"browser": true,
|
||||||
|
"es2021": true
|
||||||
|
},
|
||||||
|
"extends": [
|
||||||
|
"next/core-web-vitals",
|
||||||
|
"eslint:recommended",
|
||||||
|
"plugin:@typescript-eslint/recommended",
|
||||||
|
"prettier"
|
||||||
|
],
|
||||||
|
"parser": "@typescript-eslint/parser",
|
||||||
|
"parserOptions": {
|
||||||
|
"ecmaVersion": "latest",
|
||||||
|
"sourceType": "module"
|
||||||
|
},
|
||||||
|
"plugins": ["@typescript-eslint"],
|
||||||
|
"rules": {
|
||||||
|
"@typescript-eslint/no-unused-vars": "error",
|
||||||
|
"@typescript-eslint/consistent-type-definitions": "error",
|
||||||
|
"react-hooks/rules-of-hooks": "error",
|
||||||
|
"react-hooks/exhaustive-deps": "error"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,9 +28,10 @@ export function Form({ setLoading, setError, setParsedText }: FormProps) {
|
|||||||
setClearing(false);
|
setClearing(false);
|
||||||
setFile(undefined);
|
setFile(undefined);
|
||||||
setParsedText('');
|
setParsedText('');
|
||||||
}, []);
|
}, [setParsedText]);
|
||||||
|
|
||||||
const validateFile = useCallback((file: File) => {
|
const validateFile = useCallback(
|
||||||
|
(file: File) => {
|
||||||
if (file.type !== 'application/pdf') {
|
if (file.type !== 'application/pdf') {
|
||||||
setError(
|
setError(
|
||||||
"The file you've selected is not a PDF file. Please select a PDF file."
|
"The file you've selected is not a PDF file. Please select a PDF file."
|
||||||
@@ -49,7 +50,9 @@ export function Form({ setLoading, setError, setParsedText }: FormProps) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}, []);
|
},
|
||||||
|
[setError, setLoading]
|
||||||
|
);
|
||||||
|
|
||||||
const uploadFile = useCallback(async () => {
|
const uploadFile = useCallback(async () => {
|
||||||
if (!file) return;
|
if (!file) return;
|
||||||
@@ -76,7 +79,7 @@ export function Form({ setLoading, setError, setParsedText }: FormProps) {
|
|||||||
setClearing(true);
|
setClearing(true);
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
}, [file, validateFile]);
|
}, [file, validateFile, setError, setParsedText, setClearing, setLoading]);
|
||||||
|
|
||||||
const handleUpload = useCallback(() => {
|
const handleUpload = useCallback(() => {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
@@ -84,7 +87,7 @@ export function Form({ setLoading, setError, setParsedText }: FormProps) {
|
|||||||
setParsedText('');
|
setParsedText('');
|
||||||
|
|
||||||
uploadFile();
|
uploadFile();
|
||||||
}, [uploadFile]);
|
}, [uploadFile, setLoading, setError, setParsedText]);
|
||||||
|
|
||||||
function renderForm() {
|
function renderForm() {
|
||||||
if (clearing) {
|
if (clearing) {
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
"build": "next build",
|
"build": "next build",
|
||||||
"start": "next start",
|
"start": "next start",
|
||||||
"lint": "next lint",
|
"lint": "next lint",
|
||||||
"format": "prettier --config .prettierrc 'app/' --write",
|
"format": "prettier --config .prettierrc '**/*.{ts,tsx,json}' --write",
|
||||||
"typecheck": "tsc --noEmit",
|
"typecheck": "tsc --noEmit",
|
||||||
"prepare": "husky install"
|
"prepare": "husky install"
|
||||||
},
|
},
|
||||||
@@ -40,10 +40,10 @@
|
|||||||
"typescript": "^5"
|
"typescript": "^5"
|
||||||
},
|
},
|
||||||
"lint-staged": {
|
"lint-staged": {
|
||||||
"*.ts": [
|
"*.{ts,tsx}": [
|
||||||
"eslint --quiet --fix"
|
"eslint"
|
||||||
],
|
],
|
||||||
"*.{json,ts}": [
|
"*.{json,ts,tsx}": [
|
||||||
"prettier --write --ignore-unknown"
|
"prettier --write --ignore-unknown"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,20 +1,20 @@
|
|||||||
import type { Config } from "tailwindcss";
|
import type { Config } from 'tailwindcss';
|
||||||
|
|
||||||
const config: Config = {
|
const config: Config = {
|
||||||
content: [
|
content: [
|
||||||
"./pages/**/*.{js,ts,jsx,tsx,mdx}",
|
'./pages/**/*.{js,ts,jsx,tsx,mdx}',
|
||||||
"./components/**/*.{js,ts,jsx,tsx,mdx}",
|
'./components/**/*.{js,ts,jsx,tsx,mdx}',
|
||||||
"./app/**/*.{js,ts,jsx,tsx,mdx}",
|
'./app/**/*.{js,ts,jsx,tsx,mdx}'
|
||||||
],
|
],
|
||||||
theme: {
|
theme: {
|
||||||
extend: {
|
extend: {
|
||||||
backgroundImage: {
|
backgroundImage: {
|
||||||
"gradient-radial": "radial-gradient(var(--tw-gradient-stops))",
|
'gradient-radial': 'radial-gradient(var(--tw-gradient-stops))',
|
||||||
"gradient-conic":
|
'gradient-conic':
|
||||||
"conic-gradient(from 180deg at 50% 50%, var(--tw-gradient-stops))",
|
'conic-gradient(from 180deg at 50% 50%, var(--tw-gradient-stops))'
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
},
|
plugins: []
|
||||||
},
|
|
||||||
plugins: [],
|
|
||||||
};
|
};
|
||||||
export default config;
|
export default config;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import PdfParse from 'pdf-parse';
|
|||||||
|
|
||||||
export async function parser(file: File) {
|
export async function parser(file: File) {
|
||||||
const chunks = [];
|
const chunks = [];
|
||||||
for await (const chunk of file.stream() as any) {
|
for await (const chunk of file.stream() as unknown as AsyncIterable<Buffer>) {
|
||||||
chunks.push(chunk);
|
chunks.push(chunk);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user