make it so underscore ignores unused vars

This commit is contained in:
Triston Armstrong 2024-10-23 13:27:28 +07:00
parent a506da11ad
commit 441269d435
Signed by: tristonarmstrong
GPG Key ID: A23B48AE45EB6EFE
3 changed files with 28 additions and 22 deletions

View File

@ -23,6 +23,18 @@ export default [
rules: { rules: {
"react/react-in-jsx-scope": "off", "react/react-in-jsx-scope": "off",
"react/no-unknown-property": "off", "react/no-unknown-property": "off",
"@typescript-eslint/no-unused-vars": [
"error",
{
args: "all",
argsIgnorePattern: "^_",
caughtErrors: "all",
caughtErrorsIgnorePattern: "^_",
destructuredArrayIgnorePattern: "^_",
varsIgnorePattern: "^_",
ignoreRestSiblings: true,
},
],
}, },
}, },
] ]

View File

@ -7,11 +7,13 @@ import { updateLocalStorage } from "../../utils/localStorage"
import { Tooltip } from "./Tooltip" import { Tooltip } from "./Tooltip"
import { defaultClassName } from "./utils" import { defaultClassName } from "./utils"
type legacySupportTypes = { type: CardTypes | string }
export function ImportButton() { export function ImportButton() {
function _handleImport() { function _handleImport() {
// guard clause to prevent overwriting existing cards // guard clause to prevent overwriting existing cards
if (images.images.value || notes.notes.value) { if (Object.keys(images.images.value).length || Object.keys(notes.notes.value).length) {
const isConfirmed = confirm("Are you sure you want to overwrite your existing cards?") const isConfirmed = confirm("Are you sure you want to overwrite your existing cards?")
if (!isConfirmed) return if (!isConfirmed) return
} }
@ -32,30 +34,22 @@ export function ImportButton() {
let content = readerEvent.target?.result; let content = readerEvent.target?.result;
// get only the base64 parts and not any identifiers // get only the base64 parts and not any identifiers
content = (content as string).split(',')[1] content = (content as string).split(',')[1]
const data: Record<string, Card<CardTypes>> = convertBase64ToJson(content) const data: Record<string, Omit<Card<CardTypes>, 'type'> & legacySupportTypes> = convertBase64ToJson(content)
console.log(data)
for (const key in data) { for (const key in data) {
const item = data[key] const item = data[key]
const { id, ...rest } = item const { id: _, ...rest } = item
console.log(id, rest) if (item.type === CardTypes.IMAGES || item.type == 'image') {
switch (item.type) { images.addImage(rest as ImageCardType)
case CardTypes.IMAGES: continue
console.log("adding image: ", rest) } else if (item.type === CardTypes.NOTES || item.type === 'note') {
images.addImage(rest as ImageCardType) notes.addNote(rest as NoteCardType)
break; continue
case CardTypes.NOTES: } else if (item.type === CardTypes.TEXTS || item.type === 'text') {
notes.addNote(rest as NoteCardType) texts.addText(rest as TextCardType)
break; continue
case CardTypes.TEXTS:
texts.addText(rest as TextCardType)
break;
default:
break;
} }
} }
console.log("images: ", images.images.value)
updateLocalStorage(CardTypes.NOTES, notes.notes).notify() updateLocalStorage(CardTypes.NOTES, notes.notes).notify()
updateLocalStorage(CardTypes.IMAGES, images.images).notify() updateLocalStorage(CardTypes.IMAGES, images.images).notify()
updateLocalStorage(CardTypes.TEXTS, texts.texts).notify() updateLocalStorage(CardTypes.TEXTS, texts.texts).notify()

View File

@ -1,5 +1,7 @@
{ {
"compilerOptions": { "compilerOptions": {
"noUnusedLocals": false,
"noUnusedParameters": false,
"target": "ES2020", "target": "ES2020",
"useDefineForClassFields": true, "useDefineForClassFields": true,
"module": "ESNext", "module": "ESNext",
@ -15,8 +17,6 @@
/* Linting */ /* Linting */
"strict": true, "strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true, "noFallthroughCasesInSwitch": true,
"jsx": "preserve" "jsx": "preserve"
}, },