generated from Klectr/KTemplate
make it so underscore ignores unused vars
This commit is contained in:
parent
a506da11ad
commit
441269d435
@ -23,6 +23,18 @@ export default [
|
||||
rules: {
|
||||
"react/react-in-jsx-scope": "off",
|
||||
"react/no-unknown-property": "off",
|
||||
"@typescript-eslint/no-unused-vars": [
|
||||
"error",
|
||||
{
|
||||
args: "all",
|
||||
argsIgnorePattern: "^_",
|
||||
caughtErrors: "all",
|
||||
caughtErrorsIgnorePattern: "^_",
|
||||
destructuredArrayIgnorePattern: "^_",
|
||||
varsIgnorePattern: "^_",
|
||||
ignoreRestSiblings: true,
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
]
|
||||
|
@ -7,11 +7,13 @@ import { updateLocalStorage } from "../../utils/localStorage"
|
||||
import { Tooltip } from "./Tooltip"
|
||||
import { defaultClassName } from "./utils"
|
||||
|
||||
type legacySupportTypes = { type: CardTypes | string }
|
||||
|
||||
export function ImportButton() {
|
||||
|
||||
function _handleImport() {
|
||||
// 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?")
|
||||
if (!isConfirmed) return
|
||||
}
|
||||
@ -32,30 +34,22 @@ export function ImportButton() {
|
||||
let content = readerEvent.target?.result;
|
||||
// get only the base64 parts and not any identifiers
|
||||
content = (content as string).split(',')[1]
|
||||
const data: Record<string, Card<CardTypes>> = convertBase64ToJson(content)
|
||||
console.log(data)
|
||||
const data: Record<string, Omit<Card<CardTypes>, 'type'> & legacySupportTypes> = convertBase64ToJson(content)
|
||||
for (const key in data) {
|
||||
const item = data[key]
|
||||
const { id, ...rest } = item
|
||||
console.log(id, rest)
|
||||
switch (item.type) {
|
||||
case CardTypes.IMAGES:
|
||||
console.log("adding image: ", rest)
|
||||
images.addImage(rest as ImageCardType)
|
||||
break;
|
||||
case CardTypes.NOTES:
|
||||
notes.addNote(rest as NoteCardType)
|
||||
break;
|
||||
case CardTypes.TEXTS:
|
||||
texts.addText(rest as TextCardType)
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
const { id: _, ...rest } = item
|
||||
if (item.type === CardTypes.IMAGES || item.type == 'image') {
|
||||
images.addImage(rest as ImageCardType)
|
||||
continue
|
||||
} else if (item.type === CardTypes.NOTES || item.type === 'note') {
|
||||
notes.addNote(rest as NoteCardType)
|
||||
continue
|
||||
} else if (item.type === CardTypes.TEXTS || item.type === 'text') {
|
||||
texts.addText(rest as TextCardType)
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
console.log("images: ", images.images.value)
|
||||
|
||||
updateLocalStorage(CardTypes.NOTES, notes.notes).notify()
|
||||
updateLocalStorage(CardTypes.IMAGES, images.images).notify()
|
||||
updateLocalStorage(CardTypes.TEXTS, texts.texts).notify()
|
||||
|
@ -1,5 +1,7 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"noUnusedLocals": false,
|
||||
"noUnusedParameters": false,
|
||||
"target": "ES2020",
|
||||
"useDefineForClassFields": true,
|
||||
"module": "ESNext",
|
||||
@ -15,8 +17,6 @@
|
||||
|
||||
/* Linting */
|
||||
"strict": true,
|
||||
"noUnusedLocals": true,
|
||||
"noUnusedParameters": true,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"jsx": "preserve"
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user