From c419d15907e9504ad9ef055243cb3e9f4ab8e0cd Mon Sep 17 00:00:00 2001 From: Dane Everitt Date: Sat, 4 Jul 2020 18:30:50 -0700 Subject: [PATCH] eslint cleanup --- package.json | 1 + resources/scripts/.eslintrc.yml | 4 +++- resources/scripts/api/account/createApiKey.ts | 4 ++-- resources/scripts/api/account/updateAccountPassword.ts | 2 -- resources/scripts/api/auth/loginCheckpoint.ts | 2 -- resources/scripts/api/auth/performPasswordReset.ts | 1 - resources/scripts/api/getServers.ts | 3 +-- resources/scripts/api/getSystemPermissions.ts | 2 +- resources/scripts/api/http.ts | 2 +- resources/scripts/api/server/files/renameFile.ts | 2 -- resources/scripts/api/server/getServer.ts | 3 ++- resources/scripts/api/server/getServerDatabases.ts | 2 +- resources/scripts/api/server/reinstallServer.ts | 2 +- .../api/server/schedules/createOrUpdateScheduleTask.ts | 1 - .../scripts/api/server/schedules/deleteScheduleTask.ts | 2 +- resources/scripts/api/server/schedules/getServerSchedule.ts | 2 +- .../scripts/api/server/schedules/getServerSchedules.tsx | 2 +- resources/scripts/api/server/users/createOrUpdateSubuser.ts | 2 +- .../scripts/components/auth/LoginCheckpointContainer.tsx | 2 +- .../scripts/components/auth/ResetPasswordContainer.tsx | 2 +- .../components/dashboard/forms/ConfigureTwoFactorForm.tsx | 2 +- resources/scripts/components/elements/ProgressBar.tsx | 4 ++-- resources/scripts/components/server/WebsocketHandler.tsx | 2 +- .../scripts/components/server/backups/BackupContextMenu.tsx | 2 +- .../components/server/files/FileManagerContainer.tsx | 2 +- .../components/server/schedules/ScheduleEditContainer.tsx | 2 +- .../scripts/components/server/schedules/ScheduleTaskRow.tsx | 2 +- .../scripts/components/server/users/RemoveSubuserButton.tsx | 2 +- resources/scripts/i18n.ts | 4 ++-- resources/scripts/plugins/useEventListener.ts | 4 ++-- resources/scripts/plugins/usePersistedState.ts | 6 +++--- resources/scripts/plugins/useWebsocketEvent.ts | 2 +- resources/scripts/routers/ServerRouter.tsx | 4 ++-- resources/scripts/state/permissions.ts | 2 +- resources/scripts/state/server/files.ts | 2 +- resources/scripts/state/server/index.ts | 2 +- resources/scripts/state/user.ts | 2 +- 37 files changed, 42 insertions(+), 47 deletions(-) diff --git a/package.json b/package.json index 32334baae..d50fc0cb1 100644 --- a/package.json +++ b/package.json @@ -115,6 +115,7 @@ }, "scripts": { "clean": "rm -rf public/assets/*.{js,css,map}", + "lint": "eslint ./resources/scripts/**/*.{ts,tsx} --ext .ts,.tsx", "watch": "cross-env NODE_ENV=development ./node_modules/.bin/webpack --watch --progress", "build": "cross-env NODE_ENV=development ./node_modules/.bin/webpack --progress", "build:production": "yarn run clean && cross-env NODE_ENV=production ./node_modules/.bin/webpack --mode production", diff --git a/resources/scripts/.eslintrc.yml b/resources/scripts/.eslintrc.yml index 2d77a9d90..9ecd57a7a 100644 --- a/resources/scripts/.eslintrc.yml +++ b/resources/scripts/.eslintrc.yml @@ -49,7 +49,7 @@ rules: "@typescript-eslint/no-explicit-any": 0 "@typescript-eslint/no-non-null-assertion": 0 "@typescript-eslint/ban-ts-comment": 0 - # @todo this would be nice to have, but don't want to deal with the warning spam at the moment. + # This would be nice to have, but don't want to deal with the warning spam at the moment. "@typescript-eslint/explicit-module-boundary-types": 0 no-restricted-imports: - error @@ -58,6 +58,8 @@ rules: message: Please import from styled-components/macro. patterns: - "!styled-components/macro" + # Not sure, this rule just doesn't work right and is protected by our use of Typescript anyways + # so I'm just not going to worry about it. "react/prop-types": 0 "react/display-name": 0 "react/jsx-indent-props": diff --git a/resources/scripts/api/account/createApiKey.ts b/resources/scripts/api/account/createApiKey.ts index afe509264..7067ec145 100644 --- a/resources/scripts/api/account/createApiKey.ts +++ b/resources/scripts/api/account/createApiKey.ts @@ -3,13 +3,13 @@ import { ApiKey, rawDataToApiKey } from '@/api/account/getApiKeys'; export default (description: string, allowedIps: string): Promise => { return new Promise((resolve, reject) => { - http.post(`/api/client/account/api-keys`, { + http.post('/api/client/account/api-keys', { description, - // eslint-disable-next-line @typescript-eslint/camelcase allowed_ips: allowedIps.length > 0 ? allowedIps.split('\n') : [], }) .then(({ data }) => resolve({ ...rawDataToApiKey(data.attributes), + // eslint-disable-next-line camelcase secretToken: data.meta?.secret_token ?? '', })) .catch(reject); diff --git a/resources/scripts/api/account/updateAccountPassword.ts b/resources/scripts/api/account/updateAccountPassword.ts index c29aefd2d..d59e85e9c 100644 --- a/resources/scripts/api/account/updateAccountPassword.ts +++ b/resources/scripts/api/account/updateAccountPassword.ts @@ -9,10 +9,8 @@ interface Data { export default ({ current, password, confirmPassword }: Data): Promise => { return new Promise((resolve, reject) => { http.put('/api/client/account/password', { - // eslint-disable-next-line @typescript-eslint/camelcase current_password: current, password: password, - // eslint-disable-next-line @typescript-eslint/camelcase password_confirmation: confirmPassword, }) .then(() => resolve()) diff --git a/resources/scripts/api/auth/loginCheckpoint.ts b/resources/scripts/api/auth/loginCheckpoint.ts index 25bb715a4..2d139fa52 100644 --- a/resources/scripts/api/auth/loginCheckpoint.ts +++ b/resources/scripts/api/auth/loginCheckpoint.ts @@ -4,11 +4,9 @@ import { LoginResponse } from '@/api/auth/login'; export default (token: string, code: string, recoveryToken?: string): Promise => { return new Promise((resolve, reject) => { http.post('/auth/login/checkpoint', { - /* eslint-disable @typescript-eslint/camelcase */ confirmation_token: token, authentication_code: code, recovery_token: (recoveryToken && recoveryToken.length > 0) ? recoveryToken : undefined, - /* eslint-enable @typescript-eslint/camelcase */ }) .then(response => resolve({ complete: response.data.data.complete, diff --git a/resources/scripts/api/auth/performPasswordReset.ts b/resources/scripts/api/auth/performPasswordReset.ts index f6263c4fe..6695099ee 100644 --- a/resources/scripts/api/auth/performPasswordReset.ts +++ b/resources/scripts/api/auth/performPasswordReset.ts @@ -17,7 +17,6 @@ export default (email: string, data: Data): Promise => { email, token: data.token, password: data.password, - // eslint-disable-next-line @typescript-eslint/camelcase password_confirmation: data.passwordConfirmation, }) .then(response => resolve({ diff --git a/resources/scripts/api/getServers.ts b/resources/scripts/api/getServers.ts index 499932376..42b2d501b 100644 --- a/resources/scripts/api/getServers.ts +++ b/resources/scripts/api/getServers.ts @@ -3,10 +3,9 @@ import http, { getPaginationSet, PaginatedResult } from '@/api/http'; export default (query?: string, includeAdmin?: boolean): Promise> => { return new Promise((resolve, reject) => { - http.get(`/api/client`, { + http.get('/api/client', { params: { include: [ 'allocation' ], - // eslint-disable-next-line @typescript-eslint/camelcase filter: includeAdmin ? 'all' : undefined, query, }, diff --git a/resources/scripts/api/getSystemPermissions.ts b/resources/scripts/api/getSystemPermissions.ts index 69fb56797..0e7f27caa 100644 --- a/resources/scripts/api/getSystemPermissions.ts +++ b/resources/scripts/api/getSystemPermissions.ts @@ -3,7 +3,7 @@ import http from '@/api/http'; export default (): Promise => { return new Promise((resolve, reject) => { - http.get(`/api/client/permissions`) + http.get('/api/client/permissions') .then(({ data }) => resolve(data.attributes.permissions)) .catch(reject); }); diff --git a/resources/scripts/api/http.ts b/resources/scripts/api/http.ts index 98f74d56c..21111ba9b 100644 --- a/resources/scripts/api/http.ts +++ b/resources/scripts/api/http.ts @@ -5,7 +5,7 @@ const http: AxiosInstance = axios.create({ timeout: 20000, headers: { 'X-Requested-With': 'XMLHttpRequest', - 'Accept': 'application/json', + Accept: 'application/json', 'Content-Type': 'application/json', 'X-CSRF-Token': (window as any).X_CSRF_TOKEN as string || '', }, diff --git a/resources/scripts/api/server/files/renameFile.ts b/resources/scripts/api/server/files/renameFile.ts index ba483d99c..6b307c837 100644 --- a/resources/scripts/api/server/files/renameFile.ts +++ b/resources/scripts/api/server/files/renameFile.ts @@ -8,9 +8,7 @@ interface Data { export default (uuid: string, { renameFrom, renameTo }: Data): Promise => { return new Promise((resolve, reject) => { http.put(`/api/client/servers/${uuid}/files/rename`, { - // eslint-disable-next-line @typescript-eslint/camelcase rename_from: renameFrom, - // eslint-disable-next-line @typescript-eslint/camelcase rename_to: renameTo, }) .then(() => resolve()) diff --git a/resources/scripts/api/server/getServer.ts b/resources/scripts/api/server/getServer.ts index 0a0b4e4a5..bd4f90ba8 100644 --- a/resources/scripts/api/server/getServer.ts +++ b/resources/scripts/api/server/getServer.ts @@ -62,7 +62,8 @@ export default (uuid: string): Promise<[ Server, string[] ]> => { http.get(`/api/client/servers/${uuid}`) .then(({ data }) => resolve([ rawDataToServerObject(data.attributes), - data.meta?.is_server_owner ? ['*'] : (data.meta?.user_permissions || []), + // eslint-disable-next-line camelcase + data.meta?.is_server_owner ? [ '*' ] : (data.meta?.user_permissions || []), ])) .catch(reject); }); diff --git a/resources/scripts/api/server/getServerDatabases.ts b/resources/scripts/api/server/getServerDatabases.ts index 835964c27..cf7c9037d 100644 --- a/resources/scripts/api/server/getServerDatabases.ts +++ b/resources/scripts/api/server/getServerDatabases.ts @@ -18,7 +18,7 @@ export const rawDataToServerDatabase = (data: any): ServerDatabase => ({ password: data.relationships && data.relationships.password ? data.relationships.password.attributes.password : undefined, }); -export default (uuid: string, includePassword: boolean = true): Promise => { +export default (uuid: string, includePassword = true): Promise => { return new Promise((resolve, reject) => { http.get(`/api/client/servers/${uuid}/databases`, { params: includePassword ? { include: 'password' } : undefined, diff --git a/resources/scripts/api/server/reinstallServer.ts b/resources/scripts/api/server/reinstallServer.ts index e931d7991..5cb2ca5e7 100644 --- a/resources/scripts/api/server/reinstallServer.ts +++ b/resources/scripts/api/server/reinstallServer.ts @@ -6,4 +6,4 @@ export default (uuid: string): Promise => { .then(() => resolve()) .catch(reject); }); -} +}; diff --git a/resources/scripts/api/server/schedules/createOrUpdateScheduleTask.ts b/resources/scripts/api/server/schedules/createOrUpdateScheduleTask.ts index d48214d09..c0d7fbbe7 100644 --- a/resources/scripts/api/server/schedules/createOrUpdateScheduleTask.ts +++ b/resources/scripts/api/server/schedules/createOrUpdateScheduleTask.ts @@ -11,7 +11,6 @@ export default (uuid: string, schedule: number, task: number | undefined, { time return new Promise((resolve, reject) => { http.post(`/api/client/servers/${uuid}/schedules/${schedule}/tasks${task ? `/${task}` : ''}`, { ...data, - // eslint-disable-next-line @typescript-eslint/camelcase time_offset: timeOffset, }) .then(({ data }) => resolve(rawDataToServerTask(data.attributes))) diff --git a/resources/scripts/api/server/schedules/deleteScheduleTask.ts b/resources/scripts/api/server/schedules/deleteScheduleTask.ts index 4b5a33296..8867677b2 100644 --- a/resources/scripts/api/server/schedules/deleteScheduleTask.ts +++ b/resources/scripts/api/server/schedules/deleteScheduleTask.ts @@ -5,5 +5,5 @@ export default (uuid: string, scheduleId: number, taskId: number): Promise http.delete(`/api/client/servers/${uuid}/schedules/${scheduleId}/tasks/${taskId}`) .then(() => resolve()) .catch(reject); - }) + }); }; diff --git a/resources/scripts/api/server/schedules/getServerSchedule.ts b/resources/scripts/api/server/schedules/getServerSchedule.ts index 537124bd6..63e3d6f98 100644 --- a/resources/scripts/api/server/schedules/getServerSchedule.ts +++ b/resources/scripts/api/server/schedules/getServerSchedule.ts @@ -5,7 +5,7 @@ export default (uuid: string, schedule: number): Promise => { return new Promise((resolve, reject) => { http.get(`/api/client/servers/${uuid}/schedules/${schedule}`, { params: { - include: ['tasks'], + include: [ 'tasks' ], }, }) .then(({ data }) => resolve(rawDataToServerSchedule(data.attributes))) diff --git a/resources/scripts/api/server/schedules/getServerSchedules.tsx b/resources/scripts/api/server/schedules/getServerSchedules.tsx index 7d3ae4d1c..42514582a 100644 --- a/resources/scripts/api/server/schedules/getServerSchedules.tsx +++ b/resources/scripts/api/server/schedules/getServerSchedules.tsx @@ -64,7 +64,7 @@ export default (uuid: string): Promise => { return new Promise((resolve, reject) => { http.get(`/api/client/servers/${uuid}/schedules`, { params: { - include: ['tasks'], + include: [ 'tasks' ], }, }) .then(({ data }) => resolve((data.data || []).map((row: any) => rawDataToServerSchedule(row.attributes)))) diff --git a/resources/scripts/api/server/users/createOrUpdateSubuser.ts b/resources/scripts/api/server/users/createOrUpdateSubuser.ts index fbcf78fe5..93303a2db 100644 --- a/resources/scripts/api/server/users/createOrUpdateSubuser.ts +++ b/resources/scripts/api/server/users/createOrUpdateSubuser.ts @@ -15,4 +15,4 @@ export default (uuid: string, params: Params, subuser?: Subuser): Promise resolve(rawDataToServerSubuser(data.data))) .catch(reject); }); -} +}; diff --git a/resources/scripts/components/auth/LoginCheckpointContainer.tsx b/resources/scripts/components/auth/LoginCheckpointContainer.tsx index 41af2ac20..a546c9664 100644 --- a/resources/scripts/components/auth/LoginCheckpointContainer.tsx +++ b/resources/scripts/components/auth/LoginCheckpointContainer.tsx @@ -17,7 +17,7 @@ interface Values { recoveryCode: '', } -type OwnProps = RouteComponentProps<{}, StaticContext, { token?: string }> +type OwnProps = RouteComponentProps, StaticContext, { token?: string }> type Props = OwnProps & { addError: ActionCreator; diff --git a/resources/scripts/components/auth/ResetPasswordContainer.tsx b/resources/scripts/components/auth/ResetPasswordContainer.tsx index 6535d9d20..92bba53ab 100644 --- a/resources/scripts/components/auth/ResetPasswordContainer.tsx +++ b/resources/scripts/components/auth/ResetPasswordContainer.tsx @@ -57,7 +57,7 @@ export default ({ match, location }: RouteComponentProps<{ token: string }>) => .min(8, 'Your new password should be at least 8 characters in length.'), passwordConfirmation: string() .required('Your new password does not match.') - .oneOf([ref('password'), null], 'Your new password does not match.'), + .oneOf([ ref('password'), null ], 'Your new password does not match.'), })} > {({ isSubmitting }) => ( diff --git a/resources/scripts/components/dashboard/forms/ConfigureTwoFactorForm.tsx b/resources/scripts/components/dashboard/forms/ConfigureTwoFactorForm.tsx index f848b633d..0b0db4d77 100644 --- a/resources/scripts/components/dashboard/forms/ConfigureTwoFactorForm.tsx +++ b/resources/scripts/components/dashboard/forms/ConfigureTwoFactorForm.tsx @@ -14,7 +14,7 @@ export default () => {
{visible && setVisible(false)} /> diff --git a/resources/scripts/components/elements/ProgressBar.tsx b/resources/scripts/components/elements/ProgressBar.tsx index 448815414..a40b92705 100644 --- a/resources/scripts/components/elements/ProgressBar.tsx +++ b/resources/scripts/components/elements/ProgressBar.tsx @@ -62,9 +62,9 @@ export default () => {
diff --git a/resources/scripts/components/server/WebsocketHandler.tsx b/resources/scripts/components/server/WebsocketHandler.tsx index 174626f4d..b2dd6e84e 100644 --- a/resources/scripts/components/server/WebsocketHandler.tsx +++ b/resources/scripts/components/server/WebsocketHandler.tsx @@ -67,7 +67,7 @@ export default () => { return ( error ? - +
diff --git a/resources/scripts/components/server/backups/BackupContextMenu.tsx b/resources/scripts/components/server/backups/BackupContextMenu.tsx index 7d2def09f..3dbcd2ace 100644 --- a/resources/scripts/components/server/backups/BackupContextMenu.tsx +++ b/resources/scripts/components/server/backups/BackupContextMenu.tsx @@ -80,7 +80,7 @@ export default ({ backup }: Props) => { be recovered once deleted. } - + (