chore: fix eslint crashing issues (#1951)
This commit is contained in:
@@ -1,7 +0,0 @@
|
||||
dist
|
||||
node_modules
|
||||
web.webpack-defaults.js
|
||||
coverage
|
||||
src/components
|
||||
src/favicon
|
||||
src/vendor
|
||||
@@ -1,47 +0,0 @@
|
||||
{
|
||||
"root": true,
|
||||
"parser": "@typescript-eslint/parser",
|
||||
"extends": [
|
||||
"eslint:recommended",
|
||||
"plugin:@typescript-eslint/recommended",
|
||||
"prettier",
|
||||
"plugin:react-hooks/recommended",
|
||||
"../../node_modules/@standardnotes/config/src/.eslintrc"
|
||||
],
|
||||
"plugins": ["@typescript-eslint", "react", "react-hooks"],
|
||||
"ignorePatterns": [
|
||||
"node_modules",
|
||||
"dist",
|
||||
".eslintrc.js",
|
||||
"*.webpack.*.js",
|
||||
"webpack-defaults.js",
|
||||
"jest.config.js",
|
||||
"__mocks__",
|
||||
"src/components",
|
||||
"src/favicon",
|
||||
"src/vendor",
|
||||
"coverage",
|
||||
"*.config.js"
|
||||
],
|
||||
"rules": {
|
||||
"standard/no-callback-literal": 0, // Disable this as we have too many callbacks relying on literals
|
||||
"no-throw-literal": 0,
|
||||
"no-console": ["warn", { "allow": ["warn", "error"] }],
|
||||
"semi": 1,
|
||||
"camelcase": "warn",
|
||||
"sort-imports": "off",
|
||||
"react-hooks/rules-of-hooks": "error",
|
||||
"react-hooks/exhaustive-deps": "error",
|
||||
"eol-last": "error",
|
||||
"no-multiple-empty-lines": ["error", { "max": 1, "maxEOF": 0 }],
|
||||
"no-trailing-spaces": "error",
|
||||
"@typescript-eslint/no-explicit-any": "warn",
|
||||
"no-invalid-this": "warn"
|
||||
},
|
||||
"env": {
|
||||
"browser": true
|
||||
},
|
||||
"globals": {
|
||||
"__WEB_VERSION__": true
|
||||
}
|
||||
}
|
||||
16
packages/web/.eslintrc.js
Normal file
16
packages/web/.eslintrc.js
Normal file
@@ -0,0 +1,16 @@
|
||||
module.exports = {
|
||||
root: true,
|
||||
extends: ['../../common.eslintrc.js', 'plugin:react-hooks/recommended'],
|
||||
parserOptions: {
|
||||
project: './tsconfig.json',
|
||||
tsconfigRootDir: __dirname,
|
||||
},
|
||||
ignorePatterns: ['**/*.spec.ts', "__mocks__"],
|
||||
plugins: ['@typescript-eslint', 'react', 'react-hooks', 'prettier'],
|
||||
env: {
|
||||
browser: true,
|
||||
},
|
||||
globals: {
|
||||
__WEB_VERSION__: true,
|
||||
},
|
||||
}
|
||||
@@ -48,7 +48,7 @@ const ComponentView: FunctionComponent<IProps> = ({ application, onLoad, compone
|
||||
const component: SNComponent = componentViewer.component
|
||||
|
||||
const manageSubscription = useCallback(() => {
|
||||
openSubscriptionDashboard(application)
|
||||
void openSubscriptionDashboard(application)
|
||||
}, [application])
|
||||
|
||||
const reloadValidityStatus = useCallback(() => {
|
||||
|
||||
@@ -214,9 +214,9 @@ const ContentListView: FunctionComponent<Props> = ({
|
||||
const panelResizeFinishCallback: ResizeFinishCallback = useCallback(
|
||||
(width, _lastLeft, _isMaxWidth, isCollapsed) => {
|
||||
if (selectedAsTag) {
|
||||
navigationController.setPanelWidthForTag(selectedAsTag, width)
|
||||
void navigationController.setPanelWidthForTag(selectedAsTag, width)
|
||||
} else {
|
||||
application.setPreference(PrefKey.NotesPanelWidth, width).catch(console.error)
|
||||
void application.setPreference(PrefKey.NotesPanelWidth, width).catch(console.error)
|
||||
}
|
||||
application.publishPanelDidResizeEvent(PANEL_NAME_NOTES, isCollapsed)
|
||||
},
|
||||
|
||||
@@ -113,7 +113,7 @@ const DailyContentList: FunctionComponent<Props> = ({
|
||||
const onClickTemplate = useCallback(
|
||||
(date: Date) => {
|
||||
setSelectedDay(date)
|
||||
itemListController.createNewNote(undefined, date, 'editor')
|
||||
void itemListController.createNewNote(undefined, date, 'editor')
|
||||
toggleAppPane(AppPaneId.Editor)
|
||||
},
|
||||
[setSelectedDay, itemListController, toggleAppPane],
|
||||
|
||||
@@ -101,7 +101,7 @@ const DisplayOptionsMenu: FunctionComponent<DisplayOptionsMenuProps> = ({
|
||||
)
|
||||
|
||||
const resetTagPreferences = useCallback(() => {
|
||||
application.mutator.changeAndSaveItem<TagMutator>(selectedTag, (mutator) => {
|
||||
void application.mutator.changeAndSaveItem<TagMutator>(selectedTag, (mutator) => {
|
||||
mutator.preferences = undefined
|
||||
})
|
||||
}, [application, selectedTag])
|
||||
|
||||
@@ -101,7 +101,7 @@ const NewNotePreferences: FunctionComponent<Props> = ({
|
||||
const setNewNoteTitleFormatChange = (value: string) => {
|
||||
setNewNoteTitleFormat(value as NewNoteTitleFormat)
|
||||
if (mode === 'global') {
|
||||
application.setPreference(PrefKey.NewNoteTitleFormat, value as NewNoteTitleFormat)
|
||||
void application.setPreference(PrefKey.NewNoteTitleFormat, value as NewNoteTitleFormat)
|
||||
} else {
|
||||
void changePreferencesCallback({ newNoteTitleFormat: value as NewNoteTitleFormat })
|
||||
}
|
||||
@@ -168,7 +168,7 @@ const NewNotePreferences: FunctionComponent<Props> = ({
|
||||
if (mode === 'tag') {
|
||||
void changePreferencesCallback({ customNoteTitleFormat: newFormat })
|
||||
} else {
|
||||
application.setPreference(PrefKey.CustomNoteTitleFormat, newFormat)
|
||||
void application.setPreference(PrefKey.CustomNoteTitleFormat, newFormat)
|
||||
}
|
||||
}, PrefChangeDebounceTimeInMs)
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ const PreviewComponent: FunctionComponent<Props> = ({ application, file, bytes }
|
||||
}),
|
||||
)
|
||||
|
||||
application.mobileDevice().previewFile(fileBase64, file.name)
|
||||
void application.mobileDevice().previewFile(fileBase64, file.name)
|
||||
}, [application, bytes, file.mimeType, file.name, isNativeMobileWeb])
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
@@ -61,14 +61,14 @@ const LinkedItemBubble = ({
|
||||
|
||||
const onUnlinkClick: MouseEventHandler = (event) => {
|
||||
event.stopPropagation()
|
||||
unlinkItem(link)
|
||||
void unlinkItem(link)
|
||||
}
|
||||
|
||||
const onKeyDown: KeyboardEventHandler = (event) => {
|
||||
switch (event.key) {
|
||||
case KeyboardKey.Backspace: {
|
||||
focusPreviousItem()
|
||||
unlinkItem(link)
|
||||
void unlinkItem(link)
|
||||
break
|
||||
}
|
||||
case KeyboardKey.Left:
|
||||
|
||||
@@ -43,7 +43,7 @@ const LinkedItemSearchResults = ({
|
||||
if (cannotLinkItem) {
|
||||
premiumModal.activate('Note linking')
|
||||
} else {
|
||||
linkItemToSelectedItem(result)
|
||||
void linkItemToSelectedItem(result)
|
||||
onClickCallback?.()
|
||||
}
|
||||
}}
|
||||
@@ -62,7 +62,7 @@ const LinkedItemSearchResults = ({
|
||||
<button
|
||||
className="group flex w-full items-center gap-2 overflow-hidden py-2 px-3 hover:bg-contrast hover:text-foreground focus:bg-info-backdrop"
|
||||
onClick={() => {
|
||||
createAndAddNewTag(searchQuery)
|
||||
void createAndAddNewTag(searchQuery)
|
||||
onClickCallback?.()
|
||||
}}
|
||||
>
|
||||
|
||||
@@ -206,7 +206,7 @@ const LinkedItemsPanel = ({
|
||||
}
|
||||
|
||||
for (let i = 0; i < files.length; i++) {
|
||||
filesController.uploadNewFile(files[i]).then((uploadedFiles) => {
|
||||
void filesController.uploadNewFile(files[i]).then((uploadedFiles) => {
|
||||
if (uploadedFiles) {
|
||||
void linkItemToSelectedItem(uploadedFiles[0])
|
||||
}
|
||||
|
||||
@@ -392,7 +392,7 @@ const NotesOptions = ({
|
||||
<button
|
||||
className={defaultClassNames}
|
||||
onClick={() => {
|
||||
application.isNativeMobileWeb() ? shareSelectedNotes(application, notes) : downloadSelectedItems()
|
||||
application.isNativeMobileWeb() ? void shareSelectedNotes(application, notes) : void downloadSelectedItems()
|
||||
}}
|
||||
>
|
||||
<Icon type={application.platform === Platform.Android ? 'share' : 'download'} className={iconClass} />
|
||||
|
||||
@@ -12,7 +12,7 @@ type Props = {
|
||||
|
||||
const SubscriptionInformation = ({ subscriptionState, application }: Props) => {
|
||||
const manageSubscription = async () => {
|
||||
openSubscriptionDashboard(application)
|
||||
void openSubscriptionDashboard(application)
|
||||
}
|
||||
|
||||
return (
|
||||
|
||||
@@ -78,12 +78,12 @@ const DataBackups = ({ application, viewControllerManager }: Props) => {
|
||||
.getArchiveService()
|
||||
.formattedDateForExports()}`
|
||||
const sanitizedFilename = sanitizeFileName(filename) + '.txt'
|
||||
downloadOrShareBlobBasedOnPlatform(application, blobData, sanitizedFilename)
|
||||
void downloadOrShareBlobBasedOnPlatform(application, blobData, sanitizedFilename)
|
||||
} else {
|
||||
const zippedDecryptedItemsBlob = await application.getArchiveService().getZippedDecryptedItemsBlob(data)
|
||||
const filename = `Standard Notes Backup - ${application.getArchiveService().formattedDateForExports()}`
|
||||
const sanitizedFilename = sanitizeFileName(filename) + '.zip'
|
||||
downloadOrShareBlobBasedOnPlatform(application, zippedDecryptedItemsBlob, sanitizedFilename)
|
||||
void downloadOrShareBlobBasedOnPlatform(application, zippedDecryptedItemsBlob, sanitizedFilename)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ const PlaintextDefaults = ({ application }: Props) => {
|
||||
|
||||
const handleLineHeightChange = (value: string) => {
|
||||
setLineHeight(value as EditorLineHeight)
|
||||
application.setPreference(PrefKey.EditorLineHeight, value as EditorLineHeight)
|
||||
void application.setPreference(PrefKey.EditorLineHeight, value as EditorLineHeight)
|
||||
}
|
||||
|
||||
const lineHeightDropdownOptions = useMemo(
|
||||
@@ -47,7 +47,7 @@ const PlaintextDefaults = ({ application }: Props) => {
|
||||
|
||||
const handleFontSizeChange = (value: string) => {
|
||||
setFontSize(value as EditorFontSize)
|
||||
application.setPreference(PrefKey.EditorFontSize, value as EditorFontSize)
|
||||
void application.setPreference(PrefKey.EditorFontSize, value as EditorFontSize)
|
||||
}
|
||||
|
||||
const fontSizeDropdownOptions = useMemo(
|
||||
|
||||
@@ -27,7 +27,7 @@ const PremiumFeaturesModal: FunctionComponent<Props> = ({
|
||||
|
||||
const handleClick = useCallback(() => {
|
||||
if (hasSubscription) {
|
||||
openSubscriptionDashboard(application)
|
||||
void openSubscriptionDashboard(application)
|
||||
} else if (hasAccount) {
|
||||
void loadPurchaseFlowUrl(application)
|
||||
} else if (window.plansUrl) {
|
||||
|
||||
@@ -164,7 +164,7 @@ const QuickSettingsMenu: FunctionComponent<MenuProps> = ({ application, quickSet
|
||||
|
||||
const toggleDefaultTheme = useCallback(() => {
|
||||
deactivateAnyNonLayerableTheme()
|
||||
application.setPreference(PrefKey.DarkMode, false)
|
||||
void application.setPreference(PrefKey.DarkMode, false)
|
||||
}, [application, deactivateAnyNonLayerableTheme])
|
||||
|
||||
return (
|
||||
|
||||
@@ -18,7 +18,7 @@ const HistoryModalFooter = ({ dismissModal, noteHistoryController }: Props) => {
|
||||
|
||||
const restoreSelectedRevision = useCallback(() => {
|
||||
if (selectedRevision) {
|
||||
restoreRevision(selectedRevision)
|
||||
void restoreRevision(selectedRevision)
|
||||
dismissModal()
|
||||
}
|
||||
}, [dismissModal, restoreRevision, selectedRevision])
|
||||
|
||||
@@ -33,7 +33,7 @@ const LegacyHistoryList: FunctionComponent<Props> = ({ legacyHistory, noteHistor
|
||||
key={url}
|
||||
isSelected={selectedEntryUrl === url}
|
||||
onClick={() => {
|
||||
selectLegacyRevision(entry)
|
||||
void selectLegacyRevision(entry)
|
||||
onSelectRevision()
|
||||
}}
|
||||
>
|
||||
|
||||
@@ -48,7 +48,7 @@ const RemoteHistoryList: FunctionComponent<RemoteHistoryListProps> = ({
|
||||
key={entry.uuid}
|
||||
isSelected={(selectedEntry as RevisionListEntry)?.uuid === entry.uuid}
|
||||
onClick={() => {
|
||||
selectRemoteRevision(entry)
|
||||
void selectRemoteRevision(entry)
|
||||
onSelectRevision()
|
||||
}}
|
||||
>
|
||||
|
||||
@@ -62,7 +62,7 @@ export class PersistenceService {
|
||||
return
|
||||
}
|
||||
|
||||
this.application.removeValue(StorageKey.MasterStatePersistenceKey)
|
||||
void this.application.removeValue(StorageKey.MasterStatePersistenceKey)
|
||||
}
|
||||
|
||||
getPersistedValues(): PersistedStateValue {
|
||||
|
||||
@@ -39,6 +39,7 @@ export class MobileWebReceiver {
|
||||
this.handleNativeEvent(nativeEvent, messageData)
|
||||
}
|
||||
} catch (error) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log('[MobileWebReceiver] Error parsing message from React Native', error)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,5 +6,5 @@ export const shareBlobOnMobile = async (application: WebApplication, blob: Blob,
|
||||
throw new Error('Share function being used outside mobile webview')
|
||||
}
|
||||
const base64 = await getBase64FromBlob(blob)
|
||||
application.mobileDevice().shareBase64AsFile(base64, filename)
|
||||
void application.mobileDevice().shareBase64AsFile(base64, filename)
|
||||
}
|
||||
|
||||
@@ -15,12 +15,12 @@ export const downloadOrShareBlobBasedOnPlatform = async (
|
||||
}
|
||||
|
||||
if (application.platform === Platform.Ios) {
|
||||
shareBlobOnMobile(application, blob, filename)
|
||||
void shareBlobOnMobile(application, blob, filename)
|
||||
return
|
||||
}
|
||||
|
||||
if (application.platform === Platform.Android) {
|
||||
downloadBlobOnAndroid(application, blob, filename, showToastOnAndroid)
|
||||
void downloadBlobOnAndroid(application, blob, filename, showToastOnAndroid)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ export function isSameDay(dateA: Date, dateB: Date): boolean {
|
||||
export function debounce(this: any, func: any, wait: number, immediate = false) {
|
||||
let timeout: NodeJS.Timeout | null
|
||||
return () => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
||||
// eslint-disable-next-line @typescript-eslint/no-this-alias, no-invalid-this
|
||||
const context = this
|
||||
// eslint-disable-next-line prefer-rest-params
|
||||
const args = arguments
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
{
|
||||
"extends": "../../node_modules/@standardnotes/config/src/tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"skipLibCheck": true,
|
||||
"lib": ["ES2022"],
|
||||
@@ -23,5 +22,5 @@
|
||||
"@Controllers/*": ["src/javascripts/Controllers/*"]
|
||||
}
|
||||
},
|
||||
"exclude": ["node_modules", "dist", "coverage", "src/components", "src/vendor"]
|
||||
"include": ["src/javascripts"]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user