chore: upgrade eslint and prettier (#2376)

* chore: upgrade eslint and prettier

* chore: add restrict-template-expressions
This commit is contained in:
Mo
2023-07-27 14:36:05 -05:00
committed by GitHub
parent acc41edb02
commit 4a29e2a24c
1283 changed files with 4416 additions and 5131 deletions

View File

@@ -38,7 +38,7 @@ export function FillItemContent<C extends ItemContent = ItemContent>(content: Pa
}
if (!content.appData[DefaultAppDomain][AppDataField.UserModifiedDate]) {
content.appData[DefaultAppDomain][AppDataField.UserModifiedDate] = `${new Date()}`
content.appData[DefaultAppDomain][AppDataField.UserModifiedDate] = new Date().toString()
}
return content as C

View File

@@ -7,13 +7,14 @@ import { LegacyAnonymousReference } from './LegacyAnonymousReference'
import { LegacyTagToNoteReference } from './LegacyTagToNoteReference'
import { Reference } from './Reference'
import { TagToParentTagReference } from './TagToParentTagReference'
import { AnonymousReference } from './AnonymousReference'
export const isLegacyAnonymousReference = (x: ContentReference): x is LegacyAnonymousReference => {
return (x as any).reference_type === undefined
return (x as AnonymousReference).reference_type === undefined
}
export const isReference = (x: ContentReference): x is Reference => {
return (x as any).reference_type !== undefined
return (x as AnonymousReference).reference_type !== undefined
}
export const isLegacyTagToNoteReference = (

View File

@@ -24,7 +24,10 @@ export class ItemCounter implements SNIndex {
private displayOptions?: AnyDisplayOptions
private vaultDisplayOptions?: VaultDisplayOptions
constructor(private collection: ItemCollection, public observers: TagItemCountChangeObserver[] = []) {}
constructor(
private collection: ItemCollection,
public observers: TagItemCountChangeObserver[] = [],
) {}
public addCountChangeObserver(observer: TagItemCountChangeObserver): () => void {
this.observers.push(observer)

View File

@@ -3,7 +3,10 @@ import { ReadonlyItemCollection } from '../Types'
import { CriteriaValidatorInterface } from './CriteriaValidatorInterface'
export class CollectionCriteriaValidator implements CriteriaValidatorInterface {
constructor(private collection: ReadonlyItemCollection, private element: ItemInterface) {}
constructor(
private collection: ReadonlyItemCollection,
private element: ItemInterface,
) {}
public passes(): boolean {
return this.collection.has(this.element.uuid)

View File

@@ -3,7 +3,10 @@ import { DisplayControllerCustomFilter } from '../Types'
import { CriteriaValidatorInterface } from './CriteriaValidatorInterface'
export class CustomFilterCriteriaValidator implements CriteriaValidatorInterface {
constructor(private customFilter: DisplayControllerCustomFilter, private element: DecryptedItemInterface) {}
constructor(
private customFilter: DisplayControllerCustomFilter,
private element: DecryptedItemInterface,
) {}
public passes(): boolean {
return this.customFilter(this.element)

View File

@@ -3,7 +3,10 @@ import { DecryptedItemInterface } from '../../../Abstract/Item'
import { KeySystemIdentifier } from '../../../Syncable/KeySystemRootKey/KeySystemIdentifier'
export class ExcludeVaultsCriteriaValidator implements CriteriaValidatorInterface {
constructor(private excludeVaults: KeySystemIdentifier[], private element: DecryptedItemInterface) {}
constructor(
private excludeVaults: KeySystemIdentifier[],
private element: DecryptedItemInterface,
) {}
public passes(): boolean {
const doesElementBelongToExcludedVault = this.excludeVaults.some(

View File

@@ -3,7 +3,10 @@ import { DecryptedItemInterface } from '../../../Abstract/Item'
import { KeySystemIdentifier } from '../../../Syncable/KeySystemRootKey/KeySystemIdentifier'
export class ExclusiveVaultCriteriaValidator implements CriteriaValidatorInterface {
constructor(private exclusiveVault: KeySystemIdentifier, private element: DecryptedItemInterface) {}
constructor(
private exclusiveVault: KeySystemIdentifier,
private element: DecryptedItemInterface,
) {}
public passes(): boolean {
return this.element.key_system_identifier === this.exclusiveVault

View File

@@ -2,7 +2,10 @@ import { DecryptedItemInterface } from './../../../Abstract/Item/Interfaces/Decr
import { CriteriaValidatorInterface } from './CriteriaValidatorInterface'
export class HiddenContentCriteriaValidator implements CriteriaValidatorInterface {
constructor(private hiddenContentTypes: string[], private element: DecryptedItemInterface) {}
constructor(
private hiddenContentTypes: string[],
private element: DecryptedItemInterface,
) {}
public passes(): boolean {
return !this.hiddenContentTypes.includes(this.element.content_type)

View File

@@ -81,7 +81,7 @@ export function predicateFromDSLString<T extends PredicateTarget>(dsl: string):
const predicateJson = predicateDSLArrayToJsonPredicate(components as RawPredicateInArrayForm)
return predicateFromJson(predicateJson)
} catch (e) {
throw Error(`Invalid smart view syntax ${e}`)
throw Error(`Invalid smart view syntax ${JSON.stringify(e)}`)
}
}

View File

@@ -1,7 +1,10 @@
import { PredicateTarget, PredicateInterface, PredicateJsonForm, StringKey } from './Interface'
export class IncludesPredicate<T extends PredicateTarget> implements PredicateInterface<T> {
constructor(private readonly keypath: StringKey<T>, public readonly predicate: PredicateInterface<T>) {}
constructor(
private readonly keypath: StringKey<T>,
public readonly predicate: PredicateInterface<T>,
) {}
matchesItem(item: T): boolean {
const keyPathComponents = this.keypath.split('.') as StringKey<T>[]

View File

@@ -13,7 +13,7 @@ export interface PredicateJsonForm {
}
export const AllPredicateCompoundOperators = ['and', 'or'] as const
export type PredicateCompoundOperator = typeof AllPredicateCompoundOperators[number]
export type PredicateCompoundOperator = (typeof AllPredicateCompoundOperators)[number]
export const AllNonCompoundPredicateOperators = [
'!=',
@@ -31,7 +31,7 @@ export const AllNonCompoundPredicateOperators = [
export const AllPredicateOperators = [...AllPredicateCompoundOperators, ...AllNonCompoundPredicateOperators] as const
export type PredicateOperator = typeof AllPredicateOperators[number]
export type PredicateOperator = (typeof AllPredicateOperators)[number]
export type SureValue = number | number[] | string[] | string | Date | boolean | false | ''