Skip to content

Commit

Permalink
Fix eslint 'react/no-object-type-as-default-prop'
Browse files Browse the repository at this point in the history
  • Loading branch information
mayorova committed May 17, 2023
1 parent 8c5a8d8 commit d3cda63
Show file tree
Hide file tree
Showing 13 changed files with 51 additions and 23 deletions.
Expand Up @@ -13,9 +13,11 @@ interface Props {
setApiJsonSpec: (description: string) => void;
}

const emptyArray = [] as never[]

const ApiJsonSpecInput: FunctionComponent<Props> = ({
apiJsonSpec,
errors = [],
errors = emptyArray,
setApiJsonSpec
}) => {
const textAreaId = 'api_docs_service_body'
Expand Down
Expand Up @@ -8,9 +8,11 @@ interface Props {
setDescription: (description: string) => void;
}

const emptyArray = [] as never[]

const DescriptionInput: FunctionComponent<Props> = ({
description,
errors = [],
errors = emptyArray,
setDescription
}) => {

Expand Down
4 changes: 3 additions & 1 deletion app/javascript/src/ActiveDocs/components/NameInput.tsx
Expand Up @@ -9,7 +9,9 @@ interface Props {
setName: (name: string) => void;
}

const NameInput: FunctionComponent<Props> = ({ errors = [], name, setName }) => {
const emptyArray = [] as never[]

const NameInput: FunctionComponent<Props> = ({ errors = emptyArray, name, setName }) => {
const validated = errors.length ? 'error' : 'default'

return (
Expand Down
4 changes: 3 additions & 1 deletion app/javascript/src/ActiveDocs/components/SystemNameInput.tsx
Expand Up @@ -13,7 +13,9 @@ interface Props {
systemName: string;
}

const SystemNameInput: FunctionComponent<Props> = ({ errors = [], isDisabled = false, setSystemName, systemName }) => {
const emptyArray = [] as never[]

const SystemNameInput: FunctionComponent<Props> = ({ errors = emptyArray, isDisabled = false, setSystemName, systemName }) => {
const validated = errors.length ? 'error' : 'default'

return (
Expand Down
Expand Up @@ -8,10 +8,12 @@ interface Props {
errors?: string[];
}

const emptyArray = [] as never[]

const PrivateEndpointInput: FunctionComponent<Props> = ({
privateEndpoint,
setPrivateEndpoint,
errors = []
errors = emptyArray
}) => (
<FormGroup
isRequired
Expand Down
Expand Up @@ -17,10 +17,12 @@ interface Props {
errors?: FlashMessage[];
}

const emptyArray = [] as never[]

const ChangePassword: FunctionComponent<Props> = ({
lostPasswordToken = null,
url = '',
errors = []
errors = emptyArray
}) => {
const {
isFormDisabled,
Expand Down
4 changes: 3 additions & 1 deletion app/javascript/src/Common/components/TableModal.tsx
Expand Up @@ -55,12 +55,14 @@ interface Props<T extends IRecord> {

const PER_PAGE_DEFAULT = 5

const emptyArray = [] as never[]

const TableModal = <T extends IRecord>({
title,
isOpen,
isLoading = false,
selectedItem,
pageItems = [],
pageItems = emptyArray,
itemsCount,
onSelect,
onClose,
Expand Down
4 changes: 3 additions & 1 deletion app/javascript/src/Common/components/UserDefinedField.tsx
Expand Up @@ -12,11 +12,13 @@ interface Props {
validationErrors?: string[];
}

const emptyArray = [] as never[]

const UserDefinedField: FunctionComponent<Props> = ({
fieldDefinition,
value,
onChange,
validationErrors = []
validationErrors = emptyArray
}) => {
const { id, label, required, name, choices } = fieldDefinition

Expand Down
Expand Up @@ -23,11 +23,13 @@ interface Props {
errors?: FormErrors;
}

const emptyObject = {} as never

const EmailConfigurationForm: FunctionComponent<Props> = ({
url,
emailConfiguration,
isUpdate = false,
errors = {}
errors = emptyObject
}) => {
const FORM_ID = 'email-configuration-form'
const [email, setEmail] = useState<string>(emailConfiguration.email ?? '')
Expand Down
Expand Up @@ -41,6 +41,8 @@ interface Props {
error?: string;
}

const emptyArray = [] as never[]

const NewApplicationForm: React.FunctionComponent<Props> = ({
buyer: defaultBuyer,
buyers,
Expand All @@ -55,7 +57,7 @@ const NewApplicationForm: React.FunctionComponent<Props> = ({
products,
productsCount = 0,
productsPath,
definedFields = [],
definedFields = emptyArray,
validationErrors,
error
}) => {
Expand Down
4 changes: 3 additions & 1 deletion app/javascript/src/Users/components/FeaturesFieldset.tsx
Expand Up @@ -23,9 +23,11 @@ interface Props {
onAdminSectionSelected: (section: AdminSection) => void;
}

const emptyArray = [] as never[]

const FeaturesFieldset: React.FunctionComponent<Props> = ({
features,
selectedSections = [],
selectedSections = emptyArray,
areServicesVisible = false,
onAdminSectionSelected
}) => {
Expand Down
22 changes: 13 additions & 9 deletions app/javascript/src/Users/components/PermissionsForm.tsx
Expand Up @@ -10,26 +10,30 @@ import type { FunctionComponent } from 'react'
import type { AdminSection, Feature, Role } from 'Users/types'
import type { Api } from 'Types'

interface State {
role?: Role;
// eslint-disable-next-line @typescript-eslint/naming-convention -- Comes from rails like that
admin_sections?: AdminSection[];
// eslint-disable-next-line @typescript-eslint/naming-convention -- Comes from rails like that
member_permission_service_ids?: number[];
}

interface Props {
initialState?: {
role?: Role;
// eslint-disable-next-line @typescript-eslint/naming-convention -- Comes from rails like that
admin_sections?: AdminSection[];
// eslint-disable-next-line @typescript-eslint/naming-convention -- Comes from rails like that
member_permission_service_ids?: number[];
};
initialState?: State;
features: Feature[];
services: Api[];
}

const emptyObject = {} as never

/**
* Represents the user's permissions form, also known as Administrative. It handles the user's Role and their access to different Services.
* @param {InitialState} initialState - The values of the user's current settings.
* @param {State} initialState - The values of the user's current settings.
* @param {Feature[]} features - The set of features or sections the user can have access to.
* @param {Api[]} services - The list of services or APIs the user can have access to.
*/
const PermissionsForm: FunctionComponent<Props> = ({
initialState = {},
initialState = emptyObject,
features,
services
}) => {
Expand Down
8 changes: 5 additions & 3 deletions app/javascript/src/Users/components/ServicesFieldset.tsx
Expand Up @@ -15,10 +15,12 @@ interface Props {
onServiceSelected: (id: number) => void;
}

const emptyArray = [] as never[]

const ServicesFieldset: React.FunctionComponent<Props> = ({
services = [],
selectedSections = [],
selectedServicesIds = [],
services = emptyArray,
selectedSections = emptyArray,
selectedServicesIds = emptyArray,
onServiceSelected
}) => {
const servicesListClassName = 'ServiceAccessList'
Expand Down

0 comments on commit d3cda63

Please sign in to comment.