mirror of
https://github.com/twentyhq/twenty
synced 2026-04-21 13:37:22 +00:00
fix: Enable Lingui recommended rules and fix all translation violations (#14133)
- Enable lingui/no-single-variables-to-translate and all other
recommended Lingui rules
- Fix single variable translation patterns (t`${variable}` → variable)
- Fix expression-in-message violations by extracting variables
- Fix t-call-in-function violations by moving translations inside
functions
- Update ESLint configs to use linguiPlugin.configs['flat/recommended']
- Clean up unused imports and improve translation patterns
This commit is contained in:
parent
6eb9a4e024
commit
e264d7f32b
24 changed files with 99 additions and 84 deletions
|
|
@ -14,6 +14,9 @@ export default [
|
|||
// Base JavaScript configuration
|
||||
js.configs.recommended,
|
||||
|
||||
// Lingui recommended rules
|
||||
linguiPlugin.configs['flat/recommended'],
|
||||
|
||||
// Global ignores
|
||||
{
|
||||
ignores: [
|
||||
|
|
@ -34,9 +37,6 @@ export default [
|
|||
'unicorn': unicornPlugin,
|
||||
},
|
||||
rules: {
|
||||
// Lingui rules
|
||||
'lingui/no-single-variables-to-translate': 'off',
|
||||
|
||||
// General rules
|
||||
'func-style': ['error', 'declaration', { allowArrowFunctions: true }],
|
||||
'no-console': ['warn', { allow: ['group', 'groupCollapsed', 'groupEnd'] }],
|
||||
|
|
|
|||
|
|
@ -17,6 +17,9 @@ export default [
|
|||
// Base JavaScript configuration
|
||||
js.configs.recommended,
|
||||
|
||||
// Lingui recommended rules
|
||||
linguiPlugin.configs['flat/recommended'],
|
||||
|
||||
// Base configuration for all files
|
||||
{
|
||||
files: ['**/*.{js,jsx,ts,tsx}'],
|
||||
|
|
@ -38,9 +41,6 @@ export default [
|
|||
},
|
||||
},
|
||||
rules: {
|
||||
// Lingui rules
|
||||
'lingui/no-single-variables-to-translate': 'off',
|
||||
|
||||
// General rules
|
||||
'func-style': ['error', 'declaration', { allowArrowFunctions: true }],
|
||||
'no-console': ['warn', { allow: ['group', 'groupCollapsed', 'groupEnd'] }],
|
||||
|
|
@ -294,7 +294,7 @@ export default [
|
|||
|
||||
// JSON files
|
||||
{
|
||||
files: ['*.json'],
|
||||
files: ['**/*.json'],
|
||||
languageOptions: {
|
||||
parser: jsoncParser,
|
||||
},
|
||||
|
|
|
|||
|
|
@ -34,4 +34,4 @@ export default [
|
|||
'@nx/dependency-checks': 'error',
|
||||
},
|
||||
},
|
||||
];
|
||||
];
|
||||
|
|
@ -7,7 +7,6 @@ import { recordStoreFamilyState } from '@/object-record/record-store/states/reco
|
|||
import { useRecoilComponentValue } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentValue';
|
||||
import { useActiveWorkflowVersionsWithManualTrigger } from '@/workflow/hooks/useActiveWorkflowVersionsWithManualTrigger';
|
||||
import { useRunWorkflowVersion } from '@/workflow/hooks/useRunWorkflowVersion';
|
||||
import { msg } from '@lingui/core/macro';
|
||||
|
||||
import { type WorkflowVersion } from '@/workflow/types/Workflow';
|
||||
import { COMMAND_MENU_DEFAULT_ICON } from '@/workflow/workflow-trigger/constants/CommandMenuDefaultIcon';
|
||||
|
|
@ -81,8 +80,8 @@ export const useRunWorkflowRecordActions = ({
|
|||
type: ActionType.WorkflowRun,
|
||||
key: `workflow-run-${activeWorkflowVersion.id}`,
|
||||
scope: ActionScope.RecordSelection,
|
||||
label: msg`${name}`,
|
||||
shortLabel: msg`${name}`,
|
||||
label: name,
|
||||
shortLabel: name,
|
||||
position: index,
|
||||
Icon,
|
||||
isPinned: activeWorkflowVersion.trigger?.settings?.isPinned,
|
||||
|
|
|
|||
|
|
@ -4,11 +4,10 @@ import { ActionType } from '@/action-menu/actions/types/ActionType';
|
|||
import { ActionMenuContext } from '@/action-menu/contexts/ActionMenuContext';
|
||||
import { useActiveWorkflowVersionsWithManualTrigger } from '@/workflow/hooks/useActiveWorkflowVersionsWithManualTrigger';
|
||||
import { useRunWorkflowVersion } from '@/workflow/hooks/useRunWorkflowVersion';
|
||||
import { msg } from '@lingui/core/macro';
|
||||
import { COMMAND_MENU_DEFAULT_ICON } from '@/workflow/workflow-trigger/constants/CommandMenuDefaultIcon';
|
||||
import { useContext } from 'react';
|
||||
import { capitalize, isDefined } from 'twenty-shared/utils';
|
||||
import { useIcons } from 'twenty-ui/display';
|
||||
import { COMMAND_MENU_DEFAULT_ICON } from '@/workflow/workflow-trigger/constants/CommandMenuDefaultIcon';
|
||||
|
||||
export const useRunWorkflowRecordAgnosticActions = () => {
|
||||
const { getIcon } = useIcons();
|
||||
|
|
@ -41,7 +40,7 @@ export const useRunWorkflowRecordAgnosticActions = () => {
|
|||
type: ActionType.WorkflowRun,
|
||||
key: `workflow-run-${activeWorkflowVersion.id}`,
|
||||
scope: ActionScope.Global,
|
||||
label: msg`${name}`,
|
||||
label: name,
|
||||
position: index,
|
||||
Icon,
|
||||
shouldBeRegistered: () => true,
|
||||
|
|
|
|||
|
|
@ -2,11 +2,13 @@ import { useRecoilValue } from 'recoil';
|
|||
|
||||
import { clientConfigApiStatusState } from '@/client-config/states/clientConfigApiStatusState';
|
||||
import { AppFullScreenErrorFallback } from '@/error-handler/components/AppFullScreenErrorFallback';
|
||||
import { useLingui } from '@lingui/react/macro';
|
||||
|
||||
export const ClientConfigProvider: React.FC<React.PropsWithChildren> = ({
|
||||
children,
|
||||
}) => {
|
||||
const { isErrored, error } = useRecoilValue(clientConfigApiStatusState);
|
||||
const { t } = useLingui();
|
||||
|
||||
return isErrored && error instanceof Error ? (
|
||||
<AppFullScreenErrorFallback
|
||||
|
|
@ -14,7 +16,7 @@ export const ClientConfigProvider: React.FC<React.PropsWithChildren> = ({
|
|||
resetErrorBoundary={() => {
|
||||
window.location.reload();
|
||||
}}
|
||||
title="Unable to Reach Back-end"
|
||||
title={t`Unable to Reach Back-end`}
|
||||
/>
|
||||
) : (
|
||||
children
|
||||
|
|
|
|||
|
|
@ -100,7 +100,7 @@ const StyledIcon = styled(IconReload)`
|
|||
|
||||
export const AppRootErrorFallback = ({
|
||||
resetErrorBoundary,
|
||||
title = 'Sorry, something went wrong',
|
||||
title = t`Sorry, something went wrong`,
|
||||
}: AppRootErrorFallbackProps) => {
|
||||
return (
|
||||
<StyledContainer>
|
||||
|
|
@ -117,7 +117,7 @@ export const AppRootErrorFallback = ({
|
|||
/>
|
||||
</StyledImageContainer>
|
||||
<StyledEmptyTextContainer>
|
||||
<StyledEmptyTitle>{t`${title}`}</StyledEmptyTitle>
|
||||
<StyledEmptyTitle>{title}</StyledEmptyTitle>
|
||||
<StyledEmptySubTitle>
|
||||
{t`Please refresh the page.`}
|
||||
</StyledEmptySubTitle>
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
import { approvedAccessDomainsState } from '@/settings/security/states/ApprovedAccessDomainsState';
|
||||
import { useSnackBar } from '@/ui/feedback/snack-bar-manager/hooks/useSnackBar';
|
||||
import { t } from '@lingui/core/macro';
|
||||
import { useEffect } from 'react';
|
||||
import { useSearchParams } from 'react-router-dom';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
import { useSetRecoilState } from 'recoil';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
import { useValidateApprovedAccessDomainMutation } from '~/generated-metadata/graphql';
|
||||
import { approvedAccessDomainsState } from '@/settings/security/states/ApprovedAccessDomainsState';
|
||||
|
||||
export const SettingsSecurityApprovedAccessDomainValidationEffect = () => {
|
||||
const [validateApprovedAccessDomainMutation] =
|
||||
|
|
@ -45,11 +45,10 @@ export const SettingsSecurityApprovedAccessDomainValidationEffect = () => {
|
|||
});
|
||||
},
|
||||
onError: (error) => {
|
||||
const message = error?.message
|
||||
? error.message
|
||||
: 'Error validating approved access domain';
|
||||
enqueueErrorSnackBar({
|
||||
message: t`${message}`,
|
||||
message: error?.message
|
||||
? error.message
|
||||
: t`Error validating approved access domain`,
|
||||
options: {
|
||||
dedupeKey: 'approved-access-domain-validation-error-dedupe-key',
|
||||
},
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ import {
|
|||
StyledSelectControlIconChevronDown,
|
||||
} from '@/ui/input/components/SelectControl';
|
||||
import { useTheme } from '@emotion/react';
|
||||
import { t } from '@lingui/core/macro';
|
||||
import pluralize from 'pluralize';
|
||||
import React from 'react';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
|
|
@ -64,7 +63,7 @@ export const MultiSelectControl = ({
|
|||
) : null}
|
||||
{isDefined(fixedText) ? (
|
||||
<OverflowingTextWithTooltip
|
||||
text={t`${selectedOptionsCount} ${
|
||||
text={`${selectedOptionsCount} ${
|
||||
selectedOptionsCount <= 1 ? fixedText : pluralize(fixedText)
|
||||
}`}
|
||||
/>
|
||||
|
|
|
|||
|
|
@ -35,7 +35,13 @@ export const MultiWorkspaceDropdownThemesComponents = () => {
|
|||
<MenuItem
|
||||
key={theme.id}
|
||||
LeftIcon={theme.icon}
|
||||
text={t`${theme.id}`}
|
||||
text={
|
||||
theme.id === 'System'
|
||||
? t`System`
|
||||
: theme.id === 'Dark'
|
||||
? t`Dark`
|
||||
: t`Light`
|
||||
}
|
||||
onClick={() => setColorScheme(theme.id)}
|
||||
RightIcon={theme.id === colorScheme ? IconCheck : undefined}
|
||||
/>
|
||||
|
|
|
|||
|
|
@ -20,6 +20,9 @@ export default [
|
|||
// Base JavaScript configuration
|
||||
js.configs.recommended,
|
||||
|
||||
// Lingui recommended rules
|
||||
linguiPlugin.configs['flat/recommended'],
|
||||
|
||||
// Global ignores
|
||||
{
|
||||
ignores: [
|
||||
|
|
@ -49,8 +52,6 @@ export default [
|
|||
'@stylistic': stylisticPlugin,
|
||||
},
|
||||
rules: {
|
||||
// Lingui rules
|
||||
'lingui/no-single-variables-to-translate': 'off',
|
||||
'prettier/prettier': 'error',
|
||||
|
||||
// General rules
|
||||
|
|
|
|||
|
|
@ -35,25 +35,29 @@ export const generateViewSortExceptionMessage = (
|
|||
|
||||
switch (key) {
|
||||
case ViewSortExceptionMessageKey.WORKSPACE_ID_REQUIRED:
|
||||
message = `WorkspaceId is required`;
|
||||
message = t`WorkspaceId is required`;
|
||||
break;
|
||||
case ViewSortExceptionMessageKey.VIEW_ID_REQUIRED:
|
||||
message = `ViewId is required`;
|
||||
message = t`ViewId is required`;
|
||||
break;
|
||||
case ViewSortExceptionMessageKey.VIEW_SORT_NOT_FOUND:
|
||||
message = `View sort${id ? ` (id: ${id})` : ''} not found`;
|
||||
message = id
|
||||
? t`View sort (id: ${id}) not found`
|
||||
: t`View sort not found`;
|
||||
break;
|
||||
case ViewSortExceptionMessageKey.INVALID_VIEW_SORT_DATA:
|
||||
message = `Invalid view sort data${id ? ` for view sort id: ${id}` : ''}`;
|
||||
message = id
|
||||
? t`Invalid view sort data for view sort id: ${id}`
|
||||
: t`Invalid view sort data`;
|
||||
break;
|
||||
case ViewSortExceptionMessageKey.FIELD_METADATA_ID_REQUIRED:
|
||||
message = `FieldMetadataId is required`;
|
||||
message = t`FieldMetadataId is required`;
|
||||
break;
|
||||
default:
|
||||
assertUnreachable(key);
|
||||
}
|
||||
|
||||
return t`${message}`;
|
||||
return message;
|
||||
};
|
||||
|
||||
export const generateViewSortUserFriendlyExceptionMessage = (
|
||||
|
|
|
|||
|
|
@ -150,12 +150,14 @@ export class FlatFieldMetadataTypeValidatorService {
|
|||
];
|
||||
|
||||
if (!isDefined(fieldMetadataTypeValidator)) {
|
||||
const fieldType = flatFieldMetadataToValidate.type;
|
||||
|
||||
return [
|
||||
{
|
||||
code: FieldMetadataExceptionCode.UNCOVERED_FIELD_METADATA_TYPE_VALIDATION,
|
||||
message: `Unsupported field metadata type ${flatFieldMetadataToValidate.type}`,
|
||||
value: flatFieldMetadataToValidate.type,
|
||||
userFriendlyMessage: t`Unsupported field metadata type ${flatFieldMetadataToValidate.type}`,
|
||||
message: `Unsupported field metadata type ${fieldType}`,
|
||||
value: fieldType,
|
||||
userFriendlyMessage: t`Unsupported field metadata type ${fieldType}`,
|
||||
},
|
||||
];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -99,12 +99,14 @@ export const fromUpdateFieldInputToFlatFieldMetadata = ({
|
|||
);
|
||||
|
||||
if (invalidUpdatedProperties.length > 0) {
|
||||
const invalidProperties = invalidUpdatedProperties.join(', ');
|
||||
|
||||
return {
|
||||
status: 'fail',
|
||||
error: {
|
||||
code: FieldMetadataExceptionCode.INVALID_FIELD_INPUT,
|
||||
message: `Cannot update standard field metadata properties: ${invalidUpdatedProperties.join(', ')}`,
|
||||
userFriendlyMessage: t`Cannot update standard field properties: ${invalidUpdatedProperties.join(', ')}`,
|
||||
message: `Cannot update standard field metadata properties: ${invalidProperties}`,
|
||||
userFriendlyMessage: t`Cannot update standard field properties: ${invalidProperties}`,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
import { t } from '@lingui/core/macro';
|
||||
|
||||
import { FieldMetadataExceptionCode } from 'src/engine/metadata-modules/field-metadata/field-metadata.exception';
|
||||
import { type FlatFieldMetadataValidationError } from 'src/engine/metadata-modules/flat-field-metadata/types/flat-field-metadata-validation-error.type';
|
||||
import { type FlatMetadataValidator } from 'src/engine/metadata-modules/types/flat-metadata-validator.type';
|
||||
|
|
@ -15,7 +17,7 @@ export const runFlatFieldMetadataValidators = <T>({
|
|||
if (isInvalid) {
|
||||
return {
|
||||
code: FieldMetadataExceptionCode.INVALID_FIELD_INPUT,
|
||||
message,
|
||||
message: t(message),
|
||||
value: elementToValidate,
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { t } from '@lingui/core/macro';
|
||||
import { msg, t } from '@lingui/core/macro';
|
||||
import { isNonEmptyString } from '@sniptt/guards';
|
||||
import { QUOTED_STRING_REGEX } from 'twenty-shared/constants';
|
||||
import {
|
||||
|
|
@ -31,11 +31,11 @@ const validateMetadataOptionId = (sanitizedId?: string) => {
|
|||
const validators: FlatMetadataValidator<string>[] = [
|
||||
{
|
||||
validator: (id) => !isDefined(id),
|
||||
message: t`Option id is required`,
|
||||
message: msg`Option id is required`,
|
||||
},
|
||||
{
|
||||
validator: (id) => !z.string().uuid().safeParse(id).success,
|
||||
message: t`Option id is invalid`,
|
||||
message: msg`Option id is invalid`,
|
||||
},
|
||||
];
|
||||
|
||||
|
|
@ -72,19 +72,19 @@ const validateMetadataOptionLabel = (
|
|||
const validators: FlatMetadataValidator<string>[] = [
|
||||
{
|
||||
validator: exceedsDatabaseIdentifierMaximumLength,
|
||||
message: t`Option label exceeds 63 characters`,
|
||||
message: msg`Option label exceeds 63 characters`,
|
||||
},
|
||||
{
|
||||
validator: beneathDatabaseIdentifierMinimumLength,
|
||||
message: t`Option label "${sanitizedLabel}" is beneath 1 character`,
|
||||
message: msg`Option label "${sanitizedLabel}" is beneath 1 character`,
|
||||
},
|
||||
{
|
||||
validator: (label) => label.includes(','),
|
||||
message: t`Label must not contain a comma`,
|
||||
message: msg`Label must not contain a comma`,
|
||||
},
|
||||
{
|
||||
validator: (label) => !isNonEmptyString(label) || label === ' ',
|
||||
message: t`Label must not be empty`,
|
||||
message: msg`Label must not be empty`,
|
||||
},
|
||||
];
|
||||
|
||||
|
|
@ -120,15 +120,15 @@ const validateMetadataOptionValue = (
|
|||
const validators: FlatMetadataValidator<string>[] = [
|
||||
{
|
||||
validator: exceedsDatabaseIdentifierMaximumLength,
|
||||
message: t`Option value exceeds 63 characters`,
|
||||
message: msg`Option value exceeds 63 characters`,
|
||||
},
|
||||
{
|
||||
validator: beneathDatabaseIdentifierMinimumLength,
|
||||
message: t`Option value "${sanitizedValue}" is beneath 1 character`,
|
||||
message: msg`Option value "${sanitizedValue}" is beneath 1 character`,
|
||||
},
|
||||
{
|
||||
validator: (value) => !isSnakeCaseString(value),
|
||||
message: t`Value must be in UPPER_CASE and follow snake_case "${sanitizedValue}"`,
|
||||
message: msg`Value must be in UPPER_CASE and follow snake_case "${sanitizedValue}"`,
|
||||
},
|
||||
];
|
||||
|
||||
|
|
@ -154,7 +154,7 @@ const validateDuplicates = (
|
|||
FieldMetadataDefaultOption[] | FieldMetadataComplexOption[]
|
||||
>
|
||||
>((field) => ({
|
||||
message: t`Duplicated option ${field}`,
|
||||
message: msg`Duplicated option ${field}`,
|
||||
validator: () =>
|
||||
new Set(options.map((option) => option[field])).size !== options.length,
|
||||
}));
|
||||
|
|
@ -215,14 +215,14 @@ const validateSelectDefaultValue = ({
|
|||
const validators: FlatMetadataValidator<string>[] = [
|
||||
{
|
||||
validator: (value: string) => !QUOTED_STRING_REGEX.test(value),
|
||||
message: 'Default value should be as quoted string',
|
||||
message: msg`Default value should be as quoted string`,
|
||||
},
|
||||
{
|
||||
validator: (value: string) =>
|
||||
!options.some(
|
||||
(option) => option.value === value.replace(QUOTED_STRING_REGEX, '$1'),
|
||||
),
|
||||
message: `Default value "${defaultValue}" must be one of the option values`,
|
||||
message: msg`Default value "${defaultValue}" must be one of the option values`,
|
||||
},
|
||||
];
|
||||
|
||||
|
|
@ -253,11 +253,11 @@ const validateMultiSelectDefaultValue = ({
|
|||
const validators: FlatMetadataValidator<string[]>[] = [
|
||||
{
|
||||
validator: (values) => values.length === 0,
|
||||
message: 'If defined default value must contain at least one value',
|
||||
message: msg`If defined default value must contain at least one value`,
|
||||
},
|
||||
{
|
||||
validator: (values) => new Set(values).size !== values.length,
|
||||
message: 'Default values must be unique',
|
||||
message: msg`Default values must be unique`,
|
||||
},
|
||||
];
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
import { t } from '@lingui/core/macro';
|
||||
|
||||
import { FieldMetadataExceptionCode } from 'src/engine/metadata-modules/field-metadata/field-metadata.exception';
|
||||
import { type FlatFieldMetadataValidationError } from 'src/engine/metadata-modules/flat-field-metadata/types/flat-field-metadata-validation-error.type';
|
||||
import { METADATA_NAME_VALIDATORS } from 'src/engine/metadata-modules/utils/constants/metadata-name-flat-metadata-validators.constants';
|
||||
|
|
@ -11,8 +13,8 @@ export const validateFlatFieldMetadataName = (
|
|||
if (isInvalid) {
|
||||
return {
|
||||
code: FieldMetadataExceptionCode.INVALID_FIELD_INPUT,
|
||||
message,
|
||||
userFriendlyMessage: message,
|
||||
message: t(message),
|
||||
userFriendlyMessage: t(message),
|
||||
value: name,
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
import { t } from '@lingui/core/macro';
|
||||
|
||||
import { type FlatObjectMetadataValidationError } from 'src/engine/metadata-modules/flat-object-metadata/types/flat-object-metadata-validation-error.type';
|
||||
import { ObjectMetadataExceptionCode } from 'src/engine/metadata-modules/object-metadata/object-metadata.exception';
|
||||
import { type FlatMetadataValidator } from 'src/engine/metadata-modules/types/flat-metadata-validator.type';
|
||||
|
|
@ -15,7 +17,7 @@ export const runFlatObjectMetadataValidators = <T>({
|
|||
if (isInvalid) {
|
||||
return {
|
||||
code: ObjectMetadataExceptionCode.INVALID_OBJECT_INPUT,
|
||||
message,
|
||||
message: t(message),
|
||||
value: elementToValidate,
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { t } from '@lingui/core/macro';
|
||||
import { msg, t } from '@lingui/core/macro';
|
||||
|
||||
import { type FlatObjectMetadataValidationError } from 'src/engine/metadata-modules/flat-object-metadata/types/flat-object-metadata-validation-error.type';
|
||||
import { type FlatObjectMetadata } from 'src/engine/metadata-modules/flat-object-metadata/types/flat-object-metadata.type';
|
||||
|
|
@ -20,11 +20,11 @@ export const validateFlatObjectMetadataLabel = ({
|
|||
const validators: FlatMetadataValidator<string>[] = [
|
||||
{
|
||||
validator: (label) => beneathDatabaseIdentifierMinimumLength(label),
|
||||
message: t`Object label is too short`,
|
||||
message: msg`Object label is too short`,
|
||||
},
|
||||
{
|
||||
validator: (label) => exceedsDatabaseIdentifierMaximumLength(label),
|
||||
message: t`Object label is too long`,
|
||||
message: msg`Object label is too long`,
|
||||
},
|
||||
];
|
||||
|
||||
|
|
@ -43,8 +43,8 @@ export const validateFlatObjectMetadataLabel = ({
|
|||
if (labelsAreIdentical) {
|
||||
errors.push({
|
||||
code: ObjectMetadataExceptionCode.INVALID_OBJECT_INPUT,
|
||||
userFriendlyMessage: `The singular and plural labels cannot be the same for an object`,
|
||||
message: t`The singular and plural labels cannot be the same for an object`,
|
||||
message: `The singular and plural labels cannot be the same for an object`,
|
||||
userFriendlyMessage: t`The singular and plural labels cannot be the same for an object`,
|
||||
value: labelSingular,
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
import { type MessageDescriptor } from '@lingui/core';
|
||||
|
||||
export type FlatMetadataValidator<T> = {
|
||||
validator: (value: T) => boolean;
|
||||
message: string;
|
||||
message: MessageDescriptor;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { t } from '@lingui/core/macro';
|
||||
import { msg } from '@lingui/core/macro';
|
||||
import camelCase from 'lodash.camelcase';
|
||||
|
||||
import { type FlatMetadataValidator } from 'src/engine/metadata-modules/types/flat-metadata-validator.type';
|
||||
|
|
@ -11,26 +11,26 @@ import { STARTS_WITH_LOWER_CASE_AND_CONTAINS_ONLY_CAPS_AND_LOWER_LETTERS_AND_NUM
|
|||
|
||||
export const METADATA_NAME_VALIDATORS: FlatMetadataValidator<string>[] = [
|
||||
{
|
||||
message: t`Name is too long`,
|
||||
message: msg`Name is too long`,
|
||||
validator: (name) => exceedsDatabaseIdentifierMaximumLength(name),
|
||||
},
|
||||
{
|
||||
message: t`Name is too short`,
|
||||
message: msg`Name is too short`,
|
||||
validator: (name) => beneathDatabaseIdentifierMinimumLength(name),
|
||||
},
|
||||
{
|
||||
message: t`Name should be in camelCase`,
|
||||
message: msg`Name should be in camelCase`,
|
||||
validator: (name) => name !== camelCase(name),
|
||||
},
|
||||
{
|
||||
message: t`Name is not valid: it must start with lowercase letter and contain only alphanumeric letters`,
|
||||
message: msg`Name is not valid: it must start with lowercase letter and contain only alphanumeric letters`,
|
||||
validator: (name) =>
|
||||
!name.match(
|
||||
STARTS_WITH_LOWER_CASE_AND_CONTAINS_ONLY_CAPS_AND_LOWER_LETTERS_AND_NUMBER_STRING_REGEX,
|
||||
),
|
||||
},
|
||||
{
|
||||
message: t`The name is not available`,
|
||||
message: msg`The name is not available`,
|
||||
validator: (name) => RESERVED_METADATA_NAME_KEYWORDS.includes(name),
|
||||
},
|
||||
];
|
||||
|
|
|
|||
|
|
@ -13,11 +13,14 @@ export const workspaceMigrationBuilderExceptionV2Formatter = (
|
|||
const { errors, summary } =
|
||||
fromWorkspaceMigrationBuilderExceptionToValidationResponseError(error);
|
||||
|
||||
const invalidObjects = summary.invalidObjects;
|
||||
const invalidFields = summary.invalidFields;
|
||||
|
||||
throw new BaseGraphQLError(error.message, ErrorCode.BAD_USER_INPUT, {
|
||||
code: 'METADATA_VALIDATION_ERROR',
|
||||
errors,
|
||||
summary,
|
||||
message: `Validation failed for ${summary.invalidObjects} object(s) and ${summary.invalidFields} field(s)`,
|
||||
userFriendlyMessage: t`Validation failed for ${summary.invalidObjects} object(s) and ${summary.invalidFields} field(s)`,
|
||||
message: `Validation failed for ${invalidObjects} object(s) and ${invalidFields} field(s)`,
|
||||
userFriendlyMessage: t`Validation failed for ${invalidObjects} object(s) and ${invalidFields} field(s)`,
|
||||
});
|
||||
};
|
||||
|
|
|
|||
|
|
@ -19,6 +19,9 @@ export default [
|
|||
// Base JavaScript configuration
|
||||
js.configs.recommended,
|
||||
|
||||
// Lingui recommended rules
|
||||
linguiPlugin.configs['flat/recommended'],
|
||||
|
||||
// Global ignores
|
||||
{
|
||||
ignores: [
|
||||
|
|
@ -39,9 +42,6 @@ export default [
|
|||
'unicorn': unicornPlugin,
|
||||
},
|
||||
rules: {
|
||||
// Lingui rules
|
||||
'lingui/no-single-variables-to-translate': 'off',
|
||||
|
||||
// General rules
|
||||
'func-style': ['error', 'declaration', { allowArrowFunctions: true }],
|
||||
'no-console': ['warn', { allow: ['group', 'groupCollapsed', 'groupEnd'] }],
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
import typescriptParser from '@typescript-eslint/parser';
|
||||
import jsoncParser from 'jsonc-eslint-parser';
|
||||
import path from 'path';
|
||||
import { fileURLToPath } from 'url';
|
||||
import reactConfig from '../../eslint.config.react.mjs';
|
||||
|
|
@ -18,14 +17,6 @@ export default [
|
|||
],
|
||||
},
|
||||
|
||||
// JSON files configuration
|
||||
{
|
||||
files: ['**/*.json'],
|
||||
languageOptions: {
|
||||
parser: jsoncParser,
|
||||
},
|
||||
},
|
||||
|
||||
// TypeScript project-specific configuration
|
||||
{
|
||||
files: ['**/*.{ts,tsx}'],
|
||||
|
|
|
|||
Loading…
Reference in a new issue