Skip to content

Commit 7fb7fa9

Browse files
committed
chore: lint files applying the updated rules
- Replace outdate rule names - Replace `any` types - Pre-pend `_` to unused variables
1 parent 267e63c commit 7fb7fa9

20 files changed

Lines changed: 51 additions & 44 deletions

File tree

packages/zcli-apps/src/commands/apps/clean.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export default class Clean extends Command {
2525
try {
2626
await cleanDirectory(tmpDirectoryPath)
2727
this.log(chalk.green(`Successfully removed ${tmpDirectoryPath} directory.`))
28-
} catch (error) {
28+
} catch (_error) {
2929
this.error(chalk.red(`Failed to remove ${tmpDirectoryPath} directory.`))
3030
}
3131
}

packages/zcli-apps/src/commands/apps/create.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export default class Create extends Command {
4444
const { job_id } = await deployApp('POST', 'api/apps.json', upload_id, manifest.name)
4545

4646
try {
47-
const { app_id }: any = await getUploadJobStatus(job_id, appPath)
47+
const { app_id }: { app_id: string } = await getUploadJobStatus(job_id, appPath)
4848
CliUx.ux.action.stop('Deployed')
4949

5050
const allConfigs = getAllConfigs(appPath)

packages/zcli-apps/src/commands/apps/update.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export default class Update extends Command {
3030
const { job_id } = await deployApp('PUT', `api/v2/apps/${appID}`, uploadId)
3131

3232
try {
33-
const { app_id }: any = await getUploadJobStatus(job_id, appPath)
33+
const { app_id }: { app_id: string } = await getUploadJobStatus(job_id, appPath)
3434
CliUx.ux.action.stop('Deployed')
3535
if (!manifest.requirementsOnly && manifest.location) {
3636
Object.keys(manifest.location).forEach(async product => {

packages/zcli-apps/src/lib/buildAppJSON.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ describe('buildAppJSON', () => {
276276
const mockId = '1'
277277

278278
test
279-
.stub(appPath, 'validateAppPath', () => {}) // eslint-disable-line @typescript-eslint/no-empty-function
279+
.stub(appPath, 'validateAppPath', () => {})
280280
.stub(manifest, 'getManifestFile', () => manifestOutput)
281281
.stub(appConfig, 'getAllConfigs', () => ({
282282
app_id: '234',
@@ -328,7 +328,7 @@ describe('buildAppJSON', () => {
328328

329329
describe('for non private apps', () => {
330330
test
331-
.stub(appPath, 'validateAppPath', () => {}) // eslint-disable-line @typescript-eslint/no-empty-function
331+
.stub(appPath, 'validateAppPath', () => {})
332332
.stub(manifest, 'getManifestFile', () => manifestOutputNoParams)
333333
.stub(uuid, 'uuidV4', () => mockId)
334334
.stub(buildAppJSON, 'getLocationIcons', () => { return multiProductLocationIcons })
@@ -370,7 +370,7 @@ describe('buildAppJSON', () => {
370370

371371
describe('with no params attribute on manifest file', () => {
372372
test
373-
.stub(appPath, 'validateAppPath', () => {}) // eslint-disable-line @typescript-eslint/no-empty-function
373+
.stub(appPath, 'validateAppPath', () => {})
374374
.stub(manifest, 'getManifestFile', () => manifestOutputNoParams)
375375
.stub(appConfig, 'getAllConfigs', () => ({
376376
app_id: '234',

packages/zcli-apps/src/lib/buildAppJSON.ts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export const getLocationIcons = (appPath: string, manifestLocations: Location =
4949
}, {})
5050
}
5151

52-
export const getInstallation = (appId: string, app: App, configFileContents: ZcliConfigFileContent, appSettings: Array<Record<string, any>>): Installation => {
52+
export const getInstallation = (appId: string, app: App, configFileContents: ZcliConfigFileContent, appSettings: Array<Record<string, unknown>>): Installation => {
5353
const installationId = configFileContents.installation_id || uuidV4()
5454

5555
return {
@@ -73,20 +73,21 @@ const mergeLocationAndIcons = (locations: Location, locationIcons: LocationIcons
7373
for (const locationName in locationIcons[product]) {
7474
if (typeof (locations[product][locationName]) === 'string') {
7575
locations[product][locationName] = {
76-
url: locations[product][locationName]
76+
url: locations[product][locationName] as string
7777
}
7878
}
79+
7980
if (locationIcons[product][locationName].svg) {
80-
locations[product][locationName].svg = locationIcons[product][locationName].svg
81+
(locations[product][locationName] as { svg: string }).svg = locationIcons[product][locationName].svg
8182
}
8283
if (locationIcons[product][locationName].active) {
83-
locations[product][locationName].active = locationIcons[product][locationName].active
84+
(locations[product][locationName] as { active: string }).active = locationIcons[product][locationName].active
8485
}
8586
if (locationIcons[product][locationName].inactive) {
86-
locations[product][locationName].inactive = locationIcons[product][locationName].inactive
87+
(locations[product][locationName] as { inactive: string }).inactive = locationIcons[product][locationName].inactive
8788
}
8889
if (locationIcons[product][locationName].hover) {
89-
locations[product][locationName].hover = locationIcons[product][locationName].hover
90+
(locations[product][locationName] as { hover: string }).hover = locationIcons[product][locationName].hover
9091
}
9192
}
9293
}
@@ -95,7 +96,7 @@ const mergeLocationAndIcons = (locations: Location, locationIcons: LocationIcons
9596
for (const locationName in locations[product]) {
9697
if (typeof (locations[product][locationName]) === 'string') {
9798
locations[product][locationName] = {
98-
url: locations[product][locationName]
99+
url: locations[product][locationName] as string
99100
}
100101
}
101102
}
@@ -122,8 +123,8 @@ export const getAppPayloadFromManifest = (appManifest: Manifest, port: number, a
122123
return appPayload
123124
}
124125

125-
const getSettingsArr = (appSettings: any) => {
126-
const s: any[] = []
126+
const getSettingsArr = (appSettings: Record<string, string>) => {
127+
const s: Record<string, string>[] = []
127128
Object.keys(appSettings).forEach((settingName: string) => {
128129
const setting: Record<string, string> = {}
129130
setting[settingName] = appSettings[settingName]

packages/zcli-apps/src/lib/package.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ describe('package', () => {
2020
.it('should throw if package has validation errors', async () => {
2121
try {
2222
await validatePkg('./app-path')
23-
} catch (error: any) {
24-
expect(error.message).to.equal('invalid location')
23+
} catch (error: unknown) {
24+
expect((error as Error).message).to.equal('invalid location')
2525
}
2626
})
2727

@@ -31,8 +31,8 @@ describe('package', () => {
3131
.it('should throw if app path is invalid', async () => {
3232
try {
3333
await validatePkg('./bad-path')
34-
} catch (error: any) {
35-
expect(error.message).to.equal('Package not found at ./bad-path')
34+
} catch (error: unknown) {
35+
expect((error as Error).message).to.equal('Package not found at ./bad-path')
3636
}
3737
})
3838
})

packages/zcli-apps/src/types.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,13 @@ export type Dictionary<T> = {
1616

1717
// Begin AppJSON definitions
1818
export interface AppLocation {
19-
[appLocation: string]: any;
19+
[appLocation: string]: string | {
20+
active?: string;
21+
hover?: string;
22+
inactive?: string;
23+
svg?: string;
24+
url: string;
25+
};
2026
}
2127

2228
export interface IconLocationAllowlist {
@@ -107,8 +113,8 @@ export interface Installation {
107113
enabled: boolean;
108114
id: string;
109115
plan?: string;
110-
requirements: Array<Record<string, any>>;
111-
settings: Array<Record<string, any>>;
116+
requirements: Array<Record<string, unknown>>;
117+
settings: Array<Record<string, unknown>>;
112118
updated_at: string;
113119
}
114120

packages/zcli-apps/src/utils/appConfig.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export const getAllConfigs = (appPath: string, configFileName: string = DEFAULT_
1313
const zcliConfigFile = fs.readFileSync(configFilePath, 'utf8')
1414
try {
1515
return JSON.parse(zcliConfigFile)
16-
} catch (error) {
16+
} catch (_error) {
1717
throw new CLIError(chalk.red(`zcli configuration file was malformed at path: ${configFilePath}`))
1818
}
1919
}

packages/zcli-apps/src/utils/createApp.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export const getManifestAppName = (appPath: string): string | undefined => {
1111
return getManifestFile(appPath).name
1212
}
1313

14-
export const uploadAppPkg = async (pkgPath: string): Promise<any> => {
14+
export const uploadAppPkg = async (pkgPath: string): Promise<{ id: number }> => {
1515
const pkgBuffer = await fs.readFile(pkgPath)
1616

1717
const formData = new FormData()
@@ -63,7 +63,7 @@ export const deployApp = async (method: string, url: string, upload_id: number,
6363
return installationResponse.data
6464
}
6565

66-
export const createProductInstallation = async (settings: any, manifest: Manifest, app_id: string, product: string): Promise<boolean> => {
66+
export const createProductInstallation = async (settings: Record<string, unknown>, manifest: Manifest, app_id: string, product: string): Promise<boolean> => {
6767
const installResponse = await request.requestAPI(`api/${product}/apps/installations.json`, {
6868
method: 'POST',
6969
data: JSON.stringify({ app_id: `${app_id}`, settings: { name: manifest.name, ...settings } }),

packages/zcli-apps/src/utils/uploadApp.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { request } from '@zendesk/zcli-core'
33
import { getAppSettings } from './getAppSettings'
44
import { Manifest, Installations, ZcliConfigFileContent } from '../types'
55

6-
export const getUploadJobStatus = async (job_id: string, appPath: string, pollAfter = 1000) => new Promise((resolve, reject) => {
6+
export const getUploadJobStatus = async (job_id: string, appPath: string, pollAfter = 1000) => new Promise<{ status: string, message: string, app_id: string }>((resolve, reject) => {
77
const polling = setInterval(async () => {
88
const res = await request.requestAPI(`api/v2/apps/job_statuses/${job_id}`, { method: 'GET' })
99
const { status, message, app_id } = await res.data

0 commit comments

Comments
 (0)