Skip to content

Commit

Permalink
Update prettier & eslint (bluesky-social#2373)
Browse files Browse the repository at this point in the history
* chore(deps): update linting tools

* style(lint): format code
  • Loading branch information
matthieusieben authored Apr 3, 2024
1 parent a1e22df commit 97482da
Show file tree
Hide file tree
Showing 52 changed files with 381 additions and 246 deletions.
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,18 @@
"@swc/jest": "^0.2.24",
"@types/jest": "^28.1.4",
"@types/node": "^18.19.24",
"@typescript-eslint/eslint-plugin": "^6.14.0",
"@typescript-eslint/parser": "^6.14.0",
"@typescript-eslint/eslint-plugin": "^7.4.0",
"@typescript-eslint/parser": "^7.4.0",
"babel-eslint": "^10.1.0",
"dotenv": "^16.0.3",
"eslint": "^8.24.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-prettier": "^4.2.1",
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.1.3",
"jest": "^28.1.2",
"node-gyp": "^9.3.1",
"pino-pretty": "^9.1.0",
"prettier": "^2.7.1",
"prettier-config-standard": "^5.0.0",
"prettier": "^3.2.5",
"prettier-config-standard": "^7.0.0",
"typescript": "^5.3.3"
},
"workspaces": {
Expand Down
4 changes: 2 additions & 2 deletions packages/api/src/moderation/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ export function interpretLabelValueDefinition(
def.severity === 'alert'
? 'alert'
: def.severity === 'inform'
? 'inform'
: undefined
? 'inform'
: undefined
if (def.blurs === 'content') {
// target=account, blurs=content
behaviors.account.profileList = alertOrInform
Expand Down
5 changes: 4 additions & 1 deletion packages/api/src/rich-text/rich-text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,10 @@ export interface RichTextOpts {
}

export class RichTextSegment {
constructor(public text: string, public facet?: Facet) {}
constructor(
public text: string,
public facet?: Facet,
) {}

get link(): FacetLink | undefined {
const link = this.facet?.features.find(AppBskyRichtextFacet.isLink)
Expand Down
5 changes: 4 additions & 1 deletion packages/aws/src/s3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ export class S3BlobStore implements BlobStore {
private client: aws.S3
private bucket: string

constructor(public did: string, cfg: S3Config) {
constructor(
public did: string,
cfg: S3Config,
) {
const { bucket, ...rest } = cfg
this.bucket = bucket
this.client = new aws.S3({
Expand Down
5 changes: 4 additions & 1 deletion packages/bsky/src/api/app/bsky/feed/getAuthorFeed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,10 @@ class SelfThreadTracker {
feedUris = new Set<string>()
cache = new Map<string, boolean>()

constructor(items: FeedItem[], private hydration: HydrationState) {
constructor(
items: FeedItem[],
private hydration: HydrationState,
) {
items.forEach((item) => {
if (!item.repost) {
this.feedUris.add(item.post.uri)
Expand Down
4 changes: 2 additions & 2 deletions packages/bsky/src/api/app/bsky/notification/registerPush.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ export default function (server: Server, ctx: AppContext) {
platform === 'ios'
? AppPlatform.IOS
: platform === 'android'
? AppPlatform.ANDROID
: AppPlatform.WEB,
? AppPlatform.ANDROID
: AppPlatform.WEB,
appId,
})
},
Expand Down
5 changes: 4 additions & 1 deletion packages/bsky/src/auth-verifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,10 @@ export class AuthVerifier {
public modServiceDid: string
private adminPasses: Set<string>

constructor(public dataplane: DataPlaneClient, opts: AuthVerifierOpts) {
constructor(
public dataplane: DataPlaneClient,
opts: AuthVerifierOpts,
) {
this.ownDid = opts.ownDid
this.modServiceDid = opts.modServiceDid
this.adminPasses = new Set(opts.adminPasses)
Expand Down
20 changes: 13 additions & 7 deletions packages/bsky/src/cache/read-through.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ export type CacheOptions<T> = {
}

export class ReadThroughCache<T> {
constructor(public redis: Redis, public opts: CacheOptions<T>) {}
constructor(
public redis: Redis,
public opts: CacheOptions<T>,
) {}

private async _fetchMany(keys: string[]): Promise<Record<string, T | null>> {
let result: Record<string, T | null> = {}
Expand Down Expand Up @@ -142,10 +145,13 @@ export class ReadThroughCache<T> {
}

const removeNulls = <T>(obj: Record<string, T | null>): Record<string, T> => {
return Object.entries(obj).reduce((acc, [key, val]) => {
if (val !== null) {
acc[key] = val
}
return acc
}, {} as Record<string, T>)
return Object.entries(obj).reduce(
(acc, [key, val]) => {
if (val !== null) {
acc[key] = val
}
return acc
},
{} as Record<string, T>,
)
}
5 changes: 4 additions & 1 deletion packages/bsky/src/data-plane/server/db/pagination.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ export type LabeledResult = {
* ↳ SQL Condition
*/
export abstract class GenericKeyset<R, LR extends LabeledResult> {
constructor(public primary: DbRef, public secondary: DbRef) {}
constructor(
public primary: DbRef,
public secondary: DbRef,
) {}
abstract labelResult(result: R): LR
abstract labeledResultToCursor(labeled: LR): Cursor
abstract cursorToLabeledResult(cursor: Cursor): LR
Expand Down
5 changes: 4 additions & 1 deletion packages/bsky/src/data-plane/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ import { IdResolver, MemoryCache } from '@atproto/identity'
export { RepoSubscription } from './subscription'

export class DataPlaneServer {
constructor(public server: http.Server, public idResolver: IdResolver) {}
constructor(
public server: http.Server,
public idResolver: IdResolver,
) {}

static async create(db: Database, port: number, plcUrl?: string) {
const app = express()
Expand Down
17 changes: 10 additions & 7 deletions packages/bsky/src/data-plane/server/indexing/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,13 +206,16 @@ export class IndexingService {
.where('did', '=', did)
.select(['uri', 'cid'])
.execute()
return res.reduce((acc, cur) => {
acc[cur.uri] = {
uri: new AtUri(cur.uri),
cid: CID.parse(cur.cid),
}
return acc
}, {} as Record<string, { uri: AtUri; cid: CID }>)
return res.reduce(
(acc, cur) => {
acc[cur.uri] = {
uri: new AtUri(cur.uri),
cid: CID.parse(cur.cid),
}
return acc
},
{} as Record<string, { uri: AtUri; cid: CID }>,
)
}

async setCommitLastSeen(
Expand Down
5 changes: 2 additions & 3 deletions packages/bsky/src/data-plane/server/subscription/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,8 @@ export class RepoSubscription {
return
}
if (msg.rebase) {
const needsReindex = await this.indexingSvc.checkCommitNeedsIndexing(
root,
)
const needsReindex =
await this.indexingSvc.checkCommitNeedsIndexing(root)
if (needsReindex) {
await this.indexingSvc.indexRepo(msg.repo, rootCid.toString())
}
Expand Down
5 changes: 4 additions & 1 deletion packages/bsky/src/data-plane/server/subscription/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,10 @@ export class ConsecutiveList<T> {

export class ConsecutiveItem<T> {
isComplete = false
constructor(private consecutive: ConsecutiveList<T>, public value: T) {}
constructor(
private consecutive: ConsecutiveList<T>,
public value: T,
) {}

complete() {
this.isComplete = true
Expand Down
17 changes: 10 additions & 7 deletions packages/bsky/src/hydration/actor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,16 @@ export class ActorHydrator {
const res = handles.length
? await this.dataplane.getDidsByHandles({ handles })
: { dids: [] }
const didByHandle = handles.reduce((acc, cur, i) => {
const did = res.dids[i]
if (did && did.length > 0) {
return acc.set(cur, did)
}
return acc
}, new Map() as Map<string, string>)
const didByHandle = handles.reduce(
(acc, cur, i) => {
const did = res.dids[i]
if (did && did.length > 0) {
return acc.set(cur, did)
}
return acc
},
new Map() as Map<string, string>,
)
return handleOrDids.map((id) =>
id.startsWith('did:') ? id : didByHandle.get(id),
)
Expand Down
13 changes: 8 additions & 5 deletions packages/bsky/src/hydration/graph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,14 @@ export type Block = RecordInfo<BlockRecord>
export type RelationshipPair = [didA: string, didB: string]

const dedupePairs = (pairs: RelationshipPair[]): RelationshipPair[] => {
const mapped = pairs.reduce((acc, cur) => {
const sorted = ([...cur] as RelationshipPair).sort()
acc[sorted.join('-')] = sorted
return acc
}, {} as Record<string, RelationshipPair>)
const mapped = pairs.reduce(
(acc, cur) => {
const sorted = ([...cur] as RelationshipPair).sort()
acc[sorted.join('-')] = sorted
return acc
},
{} as Record<string, RelationshipPair>,
)
return Object.values(mapped)
}

Expand Down
5 changes: 4 additions & 1 deletion packages/bsky/src/image/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ export class ImageProcessingServer {
app: Express = express()
uriBuilder: ImageUriBuilder

constructor(public cfg: ServerConfig, public cache: BlobCache) {
constructor(
public cfg: ServerConfig,
public cache: BlobCache,
) {
this.uriBuilder = new ImageUriBuilder('')
this.app.get('*', this.handler.bind(this))
this.app.use(errorMiddleware)
Expand Down
8 changes: 4 additions & 4 deletions packages/bsky/tests/_util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,16 +178,16 @@ export const stripViewerFromPost = (postUnknown: unknown): PostView => {
post.embed && isViewRecord(post.embed.record)
? post.embed.record // Record from record embed
: post.embed?.['record'] && isViewRecord(post.embed['record']['record'])
? post.embed['record']['record'] // Record from record-with-media embed
: undefined
? post.embed['record']['record'] // Record from record-with-media embed
: undefined
if (recordEmbed) {
recordEmbed.author = stripViewer(recordEmbed.author)
recordEmbed.embeds?.forEach((deepEmbed) => {
const deepRecordEmbed = isViewRecord(deepEmbed.record)
? deepEmbed.record // Record from record embed
: deepEmbed['record'] && isViewRecord(deepEmbed['record']['record'])
? deepEmbed['record']['record'] // Record from record-with-media embed
: undefined
? deepEmbed['record']['record'] // Record from record-with-media embed
: undefined
if (deepRecordEmbed) {
deepRecordEmbed.author = stripViewer(deepRecordEmbed.author)
}
Expand Down
11 changes: 7 additions & 4 deletions packages/common-web/src/arrays.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
export const keyBy = <T>(arr: T[], key: string): Record<string, T> => {
return arr.reduce((acc, cur) => {
acc[cur[key]] = cur
return acc
}, {} as Record<string, T>)
return arr.reduce(
(acc, cur) => {
acc[cur[key]] = cur
return acc
},
{} as Record<string, T>,
)
}

export const mapDefined = <T, S>(
Expand Down
5 changes: 4 additions & 1 deletion packages/common/src/ipld.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,10 @@ export class VerifyCidTransform extends Transform {
}

export class VerifyCidError extends Error {
constructor(public expected: CID, public actual: CID) {
constructor(
public expected: CID,
public actual: CID,
) {
super('Bad cid check')
}
}
5 changes: 4 additions & 1 deletion packages/common/src/streams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@ export const bytesToStream = (bytes: Uint8Array): Readable => {

export class MaxSizeChecker extends Transform {
totalSize = 0
constructor(public maxSize: number, public createError: () => Error) {
constructor(
public maxSize: number,
public createError: () => Error,
) {
super()
}
_transform(chunk: Uint8Array, _enc: BufferEncoding, cb: TransformCallback) {
Expand Down
5 changes: 4 additions & 1 deletion packages/crypto/src/p256/keypair.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ export class P256Keypair implements Keypair {
jwtAlg = P256_JWT_ALG
private publicKey: Uint8Array

constructor(private privateKey: Uint8Array, private exportable: boolean) {
constructor(
private privateKey: Uint8Array,
private exportable: boolean,
) {
this.publicKey = p256.getPublicKey(privateKey)
}

Expand Down
5 changes: 4 additions & 1 deletion packages/crypto/src/secp256k1/keypair.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ export class Secp256k1Keypair implements Keypair {
jwtAlg = SECP256K1_JWT_ALG
private publicKey: Uint8Array

constructor(private privateKey: Uint8Array, private exportable: boolean) {
constructor(
private privateKey: Uint8Array,
private exportable: boolean,
) {
this.publicKey = k256.getPublicKey(privateKey)
}

Expand Down
5 changes: 4 additions & 1 deletion packages/dev-env/src/network-no-appview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ import { SeedClient } from './seed/client'

export class TestNetworkNoAppView {
feedGens: TestFeedGen[] = []
constructor(public plc: TestPlc, public pds: TestPds) {}
constructor(
public plc: TestPlc,
public pds: TestPds,
) {}

static async create(
params: Partial<TestServerParams> = {},
Expand Down
4 changes: 2 additions & 2 deletions packages/dev-env/src/ozone.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ export class TestOzone {
role === 'admin'
? this.adminAccnt
: role === 'moderator'
? this.moderatorAccnt
: this.triageAccnt
? this.moderatorAccnt
: this.triageAccnt
const jwt = await createServiceJwt({
iss: account.did,
aud: this.ctx.cfg.service.did,
Expand Down
9 changes: 6 additions & 3 deletions packages/dev-env/src/seed/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,10 @@ export class SeedClient<
>
dids: Record<string, string>

constructor(public network: Network, public agent: AtpAgent) {
constructor(
public network: Network,
public agent: AtpAgent,
) {
this.accounts = {}
this.profiles = {}
this.follows = {}
Expand Down Expand Up @@ -277,8 +280,8 @@ export class SeedClient<
media: imageEmbed,
}
: recordEmbed
? { $type: 'app.bsky.embed.record', ...recordEmbed }
: imageEmbed
? { $type: 'app.bsky.embed.record', ...recordEmbed }
: imageEmbed
const res = await this.agent.api.app.bsky.feed.post.create(
{ repo: by },
{
Expand Down
5 changes: 4 additions & 1 deletion packages/identity/src/did/web-resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ import { PoorlyFormattedDidError, UnsupportedDidWebPathError } from '../errors'
export const DOC_PATH = '/.well-known/did.json'

export class DidWebResolver extends BaseResolver {
constructor(public timeout: number, public cache?: DidCache) {
constructor(
public timeout: number,
public cache?: DidCache,
) {
super(cache)
}

Expand Down
Loading

0 comments on commit 97482da

Please sign in to comment.