Skip to content

Commit

Permalink
small syntax lints (bluesky-social#1646)
Browse files Browse the repository at this point in the history
* lint: remove unused imports and variables

* lint: prefix unused args with '_'

* eslint: skip no-explicit-any; ignore unused _var (prefix)

* eslint: explicitly mark ignores for tricky cases
  • Loading branch information
bnewbold authored Sep 21, 2023
1 parent 462de21 commit 7e36c48
Show file tree
Hide file tree
Showing 19 changed files with 21 additions and 38 deletions.
5 changes: 3 additions & 2 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,12 @@
"no-misleading-character-class": "warn",
"@typescript-eslint/no-unused-vars": [
"warn",
{ "argsIgnorePattern": "^_" }
{ "argsIgnorePattern": "^_", "varsIgnorePattern": "^_" }
],
"@typescript-eslint/ban-ts-comment": "off",
"@typescript-eslint/no-empty-interface": "off",
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/no-empty-function": "off"
"@typescript-eslint/no-empty-function": "off",
"@typescript-eslint/no-explicit-any": "off"
}
}
1 change: 0 additions & 1 deletion packages/api/src/agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
ComAtprotoServerCreateSession,
ComAtprotoServerGetSession,
ComAtprotoServerRefreshSession,
ComAtprotoRepoUploadBlob,
} from './client'
import {
AtpSessionData,
Expand Down
2 changes: 2 additions & 0 deletions packages/api/src/bsky-agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -311,12 +311,14 @@ export class BskyAgent extends AtpAgent {
AppBskyActorDefs.isFeedViewPref(pref) &&
AppBskyActorDefs.validateFeedViewPref(pref).success
) {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { $type, feed, ...v } = pref
prefs.feedViewPrefs[pref.feed] = { ...FEED_VIEW_PREF_DEFAULTS, ...v }
} else if (
AppBskyActorDefs.isThreadViewPref(pref) &&
AppBskyActorDefs.validateThreadViewPref(pref).success
) {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { $type, ...v } = pref
prefs.threadViewPrefs = { ...prefs.threadViewPrefs, ...v }
}
Expand Down
4 changes: 2 additions & 2 deletions packages/api/src/moderation/subjects/feed-generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import {
} from '../types'

export function decideFeedGenerator(
subject: ModerationSubjectFeedGenerator,
opts: ModerationOpts,
_subject: ModerationSubjectFeedGenerator,
_opts: ModerationOpts,
): ModerationDecision {
// TODO handle labels applied on the feed generator itself
return ModerationDecision.noop()
Expand Down
4 changes: 2 additions & 2 deletions packages/api/src/moderation/subjects/user-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import {
} from '../types'

export function decideUserList(
subject: ModerationSubjectUserList,
opts: ModerationOpts,
_subject: ModerationSubjectUserList,
_opts: ModerationOpts,
): ModerationDecision {
// TODO handle labels applied on the list itself
return ModerationDecision.noop()
Expand Down
6 changes: 1 addition & 5 deletions packages/api/src/moderation/util.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import {
AppBskyEmbedRecord,
AppBskyEmbedRecordWithMedia,
AppBskyFeedPost,
} from '../client'
import { AppBskyEmbedRecord, AppBskyEmbedRecordWithMedia } from '../client'
import { ModerationDecision, ModerationUI } from './types'

export function takeHighestPriorityDecision(
Expand Down
2 changes: 2 additions & 0 deletions packages/api/src/rich-text/sanitization.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { RichText } from './rich-text'
import { UnicodeString } from './unicode'

// this regex is intentionally matching on the zero-with-separator codepoint
// eslint-disable-next-line no-misleading-character-class
const EXCESS_SPACE_RE = /[\r\n]([\u00AD\u2060\u200D\u200C\u200B\s]*[\r\n]){2,}/
const REPLACEMENT_STR = '\n\n'

Expand Down
6 changes: 3 additions & 3 deletions packages/api/tests/bsky-agent.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ describe('agent', () => {

let hasConflicted = false
let ranTwice = false
await agent.upsertProfile(async (existing) => {
await agent.upsertProfile(async (_existing) => {
if (!hasConflicted) {
await agent.com.atproto.repo.putRecord({
repo: agent.session?.did || '',
Expand Down Expand Up @@ -104,7 +104,7 @@ describe('agent', () => {
const profile1 = await agent.getProfile({ actor: agent.session?.did || '' })
expect(profile1.data.displayName).toBeFalsy()

const p = agent.upsertProfile(async (existing) => {
const p = agent.upsertProfile(async (_existing) => {
await agent.com.atproto.repo.putRecord({
repo: agent.session?.did || '',
collection: 'app.bsky.actor.profile',
Expand All @@ -130,7 +130,7 @@ describe('agent', () => {
password: 'password',
})

const p = agent.upsertProfile((existing) => {
const p = agent.upsertProfile((_existing) => {
return {
displayName: { string: 'Bob' },
} as unknown as AppBskyActorProfile.Record
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { AtUri } from '@atproto/syntax'
import { AuthRequiredError, InvalidRequestError } from '@atproto/xrpc-server'
import {
ACKNOWLEDGE,
Expand Down
1 change: 0 additions & 1 deletion packages/bsky/tests/seeds/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { InputSchema as CreateReportInput } from '@atproto/api/src/client/types/
import { Record as PostRecord } from '@atproto/api/src/client/types/app/bsky/feed/post'
import { Record as LikeRecord } from '@atproto/api/src/client/types/app/bsky/feed/like'
import { Record as FollowRecord } from '@atproto/api/src/client/types/app/bsky/graph/follow'
import { Record as ListRecord } from '@atproto/api/src/client/types/app/bsky/graph/list'

// Makes it simple to create data via the XRPC client,
// and keeps track of all created data in memory for convenience.
Expand Down
6 changes: 0 additions & 6 deletions packages/bsky/tests/views/actor-likes.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@ import AtpAgent, { AtUri } from '@atproto/api'
import { TestNetwork } from '@atproto/dev-env'
import { SeedClient } from '../seeds/client'
import basicSeed from '../seeds/basic'
import {
BlockedByActorError,
BlockedActorError,
} from '@atproto/api/src/client/types/app/bsky/feed/getActorLikes'

describe('bsky actor likes feed views', () => {
let network: TestNetwork
Expand All @@ -17,7 +13,6 @@ describe('bsky actor likes feed views', () => {
let alice: string
let bob: string
let carol: string
let dan: string

beforeAll(async () => {
network = await TestNetwork.create({
Expand All @@ -31,7 +26,6 @@ describe('bsky actor likes feed views', () => {
alice = sc.dids.alice
bob = sc.dids.bob
carol = sc.dids.carol
dan = sc.dids.dan
})

afterAll(async () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/common/tests/streams.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as streams from '../src/streams'
import { PassThrough, Readable, pipeline } from 'node:stream'
import { PassThrough, Readable } from 'node:stream'

describe('streams', () => {
describe('forwardStreamErrors', () => {
Expand Down
1 change: 1 addition & 0 deletions packages/crypto/tests/signatures.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ describe('signatures', () => {
})
})

// eslint-disable-next-line @typescript-eslint/no-unused-vars
async function generateTestVectors(): Promise<TestVector[]> {
const p256Key = await EcdsaKeypair.create({ exportable: true })
const secpKey = await Secp256k1Keypair.create({ exportable: true })
Expand Down
1 change: 0 additions & 1 deletion packages/lexicon/tests/general.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { CID } from 'multiformats/cid'
import { lexiconDoc, Lexicons } from '../src/index'
import { object } from '../src/validators/complex'
import LexiconDocs from './_scaffolds/lexicons'

describe('Lexicons collection', () => {
Expand Down
1 change: 0 additions & 1 deletion packages/pds/src/app-view/services/label/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { sql } from 'kysely'
import { CID } from 'multiformats/cid'
import { AtUri } from '@atproto/syntax'
import Database from '../../../db'
import {
Expand Down
11 changes: 3 additions & 8 deletions packages/pds/src/feed-gen/with-friends.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
import AppContext from '../context'
import { QueryParams as SkeletonParams } from '../lexicon/types/app/bsky/feed/getFeedSkeleton'
import { paginate } from '../db/pagination'
import { AlgoHandler, AlgoResponse } from './types'
import {
FeedKeyset,
getFeedDateThreshold,
} from '../app-view/api/app/bsky/util/feed'

const handler: AlgoHandler = async (
ctx: AppContext,
params: SkeletonParams,
requester: string,
_ctx: AppContext,
_params: SkeletonParams,
_requester: string,
): Promise<AlgoResponse> => {
// Temporary change to only return a post notifying users that the feed is down
return {
Expand Down
1 change: 0 additions & 1 deletion packages/pds/src/services/moderation/views.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import { AccountService } from '../account'
import { RecordService } from '../record'
import { ModerationReportRowWithHandle } from '.'
import { getSelfLabels } from '../../app-view/services/label'
import { jsonStringToLex } from '@atproto/lexicon'

export class ModerationViews {
constructor(private db: Database, private messageDispatcher: MessageQueue) {}
Expand Down
2 changes: 0 additions & 2 deletions packages/pds/tests/views/actor-likes.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ describe('pds actor likes feed views', () => {
let alice: string
let bob: string
let carol: string
let dan: string

beforeAll(async () => {
const server = await runTestServer({
Expand All @@ -25,7 +24,6 @@ describe('pds actor likes feed views', () => {
alice = sc.dids.alice
bob = sc.dids.bob
carol = sc.dids.carol
dan = sc.dids.dan
await server.processAll()
})

Expand Down
2 changes: 1 addition & 1 deletion packages/repo/tests/util.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe('Utils', () => {
await car.put(block)
throw new Error('Oops!')
})
for await (const bytes of iter) {
for await (const _bytes of iter) {
// no-op
}
}
Expand Down

0 comments on commit 7e36c48

Please sign in to comment.