From 9fe8a4b68549a2a273576b1a64eccd318b0216f4 Mon Sep 17 00:00:00 2001 From: Roman Hotsiy Date: Sat, 25 Jul 2020 20:14:11 +0300 Subject: [PATCH] chore: fix eslint errors --- .eslintrc.js | 3 +++ src/components/ErrorBoundary.tsx | 5 ++++- src/services/RedocNormalizedOptions.ts | 5 ++--- src/services/models/Operation.ts | 14 +++++++------- 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 1455e63a8a..524f435e58 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -20,12 +20,15 @@ module.exports = { plugins: ['@typescript-eslint', 'import'], rules: { '@typescript-eslint/explicit-function-return-type': 'off', + '@typescript-eslint/explicit-module-boundary-types': 'off', '@typescript-eslint/no-explicit-any': 'off', '@typescript-eslint/no-use-before-define': 'off', '@typescript-eslint/interface-name-prefix': 'off', '@typescript-eslint/no-inferrable-types': 'off', '@typescript-eslint/no-non-null-assertion': 'off', '@typescript-eslint/ban-ts-ignore': 'off', + '@typescript-eslint/ban-types': ['error', { types: { object: false }, extendDefaults: true }], + '@typescript-eslint/no-var-requires': 'off', 'react/prop-types': 'off', diff --git a/src/components/ErrorBoundary.tsx b/src/components/ErrorBoundary.tsx index d73c6f5717..f71a0ea1fe 100644 --- a/src/components/ErrorBoundary.tsx +++ b/src/components/ErrorBoundary.tsx @@ -6,7 +6,10 @@ const ErrorWrapper = styled.div` color: red; `; -export class ErrorBoundary extends React.Component<{}, { error?: Error }> { +export class ErrorBoundary extends React.Component< + React.PropsWithChildren, + { error?: Error } +> { constructor(props) { super(props); this.state = { error: undefined }; diff --git a/src/services/RedocNormalizedOptions.ts b/src/services/RedocNormalizedOptions.ts index 75f3e9b475..cd3547849e 100644 --- a/src/services/RedocNormalizedOptions.ts +++ b/src/services/RedocNormalizedOptions.ts @@ -68,7 +68,7 @@ export class RedocNormalizedOptions { } if (typeof value === 'string') { const res = {}; - value.split(',').forEach(code => { + value.split(',').forEach((code) => { res[code.trim()] = true; }); return res; @@ -134,7 +134,7 @@ export class RedocNormalizedOptions { case 'false': return false; default: - return value.split(',').map(ext => ext.trim()); + return value.split(',').map((ext) => ext.trim()); } } @@ -238,7 +238,6 @@ export class RedocNormalizedOptions { this.payloadSampleIdx = RedocNormalizedOptions.normalizePayloadSampleIdx(raw.payloadSampleIdx); this.expandSingleSchemaField = argValueToBoolean(raw.expandSingleSchemaField); - // eslint-disable-next-line @typescript-eslint/camelcase this.unstable_ignoreMimeParameters = argValueToBoolean(raw.unstable_ignoreMimeParameters); this.allowedMdComponents = raw.allowedMdComponents || {}; diff --git a/src/services/models/Operation.ts b/src/services/models/Operation.ts index 2bb63a0184..12ba2f6d65 100644 --- a/src/services/models/Operation.ts +++ b/src/services/models/Operation.ts @@ -50,7 +50,7 @@ export class OperationModel implements IMenuItem { absoluteIdx?: number; name: string; description?: string; - type = 'operation' as 'operation'; + type = 'operation' as const; parent?: GroupModel; externalDocs?: OpenAPIExternalDocumentation; @@ -102,7 +102,7 @@ export class OperationModel implements IMenuItem { // NOTE: Callbacks by default should not inherit the specification's global `security` definition. // Can be defined individually per-callback in the specification. Defaults to none. this.security = (operationSpec.security || []).map( - security => new SecurityRequirementModel(security, parser), + (security) => new SecurityRequirementModel(security, parser), ); // TODO: update getting pathInfo for overriding servers on path level @@ -116,7 +116,7 @@ export class OperationModel implements IMenuItem { : this.pointer; this.security = (operationSpec.security || parser.spec.security || []).map( - security => new SecurityRequirementModel(security, parser), + (security) => new SecurityRequirementModel(security, parser), ); this.servers = normalizeServers( @@ -208,7 +208,7 @@ export class OperationModel implements IMenuItem { this.operationSpec.pathParameters, this.operationSpec.parameters, // TODO: fix pointer - ).map(paramOrRef => new FieldModel(this.parser, paramOrRef, this.pointer, this.options)); + ).map((paramOrRef) => new FieldModel(this.parser, paramOrRef, this.pointer, this.options)); if (this.options.sortPropsAlphabetically) { return sortByField(_parameters, 'name'); @@ -224,7 +224,7 @@ export class OperationModel implements IMenuItem { get responses() { let hasSuccessResponses = false; return Object.keys(this.operationSpec.responses || []) - .filter(code => { + .filter((code) => { if (code === 'default') { return true; } @@ -235,7 +235,7 @@ export class OperationModel implements IMenuItem { return isStatusCode(code); }) // filter out other props (e.g. x-props) - .map(code => { + .map((code) => { return new ResponseModel( this.parser, code, @@ -248,7 +248,7 @@ export class OperationModel implements IMenuItem { @memoize get callbacks() { - return Object.keys(this.operationSpec.callbacks || []).map(callbackEventName => { + return Object.keys(this.operationSpec.callbacks || []).map((callbackEventName) => { return new CallbackModel( this.parser, callbackEventName,