feat: enforce @/ alias for imports and fix all relative parent imports (#16787)
## Summary This PR enforces the use of `@/` alias for imports instead of relative parent imports (`../`). ## Changes ### ESLint Configuration - Added `no-restricted-imports` pattern in `eslint.config.react.mjs` to block `../*` imports with the message "Relative parent imports are not allowed. Use @/ alias instead." - Removed the non-working `import/no-relative-parent-imports` rule (doesn't work properly in ESLint flat config) ### VS Code Settings - Added `javascript.preferences.importModuleSpecifier: non-relative` to `.vscode/settings.json` (TypeScript setting was already there) ### Code Fixes - Fixed **941 relative parent imports** across **706 files** in `packages/twenty-front` - All `../` imports converted to use `@/` alias ## Why - Consistent import style across the codebase - Easier to move files without breaking imports - Better IDE support for auto-imports - Clearer understanding of where imports come from
This commit is contained in:
+1
-1
@@ -10,7 +10,7 @@ import {
|
||||
import { MessageParticipantRole } from 'twenty-shared/types';
|
||||
import { generateEmptyJestRecordNode } from '~/testing/jest/generateEmptyJestRecordNode';
|
||||
import { getJestMetadataAndApolloMocksWrapper } from '~/testing/jest/getJestMetadataAndApolloMocksWrapper';
|
||||
import { useEmailThreadInCommandMenu } from '../useEmailThreadInCommandMenu';
|
||||
import { useEmailThreadInCommandMenu } from '@/command-menu/pages/message-thread/hooks/useEmailThreadInCommandMenu';
|
||||
|
||||
const mocks = [
|
||||
{
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ import {
|
||||
GraphOrderBy,
|
||||
GraphType,
|
||||
} from '~/generated-metadata/graphql';
|
||||
import { useChartSettingsValues } from '../useChartSettingsValues';
|
||||
import { useChartSettingsValues } from '@/command-menu/pages/page-layout/hooks/useChartSettingsValues';
|
||||
|
||||
const mockObjectMetadataItem: ObjectMetadataItem = {
|
||||
id: 'obj-1',
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ import {
|
||||
GraphOrderBy,
|
||||
type PieChartConfiguration,
|
||||
} from '~/generated/graphql';
|
||||
import { buildChartGroupByFieldConfigUpdate } from '../buildChartGroupByFieldConfigUpdate';
|
||||
import { buildChartGroupByFieldConfigUpdate } from '@/command-menu/pages/page-layout/utils/buildChartGroupByFieldConfigUpdate';
|
||||
|
||||
describe('buildChartGroupByFieldConfigUpdate', () => {
|
||||
it('sets default orderBy and dateGranularity for primary axis', () => {
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@ import { SORT_BY_GROUP_BY_FIELD_SETTING } from '@/command-menu/pages/page-layout
|
||||
import { STACKED_BARS_SETTING } from '@/command-menu/pages/page-layout/constants/settings/StackedBarsSetting';
|
||||
import { IconAxisX, IconAxisY } from 'twenty-ui/display';
|
||||
import { GraphType } from '~/generated-metadata/graphql';
|
||||
import { getBarChartSettings } from '../getBarChartSettings';
|
||||
import { getBarChartSettings } from '@/command-menu/pages/page-layout/utils/getBarChartSettings';
|
||||
|
||||
describe('getBarChartSettings', () => {
|
||||
describe('Vertical bar chart', () => {
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@ import {
|
||||
type AggregateChartConfiguration,
|
||||
type BarChartConfiguration,
|
||||
} from '~/generated/graphql';
|
||||
import { isAggregateChartConfiguration } from '../isAggregateChartConfiguration';
|
||||
import { isAggregateChartConfiguration } from '@/command-menu/pages/page-layout/utils/isAggregateChartConfiguration';
|
||||
|
||||
describe('isAggregateChartConfiguration', () => {
|
||||
it('should return true for AggregateChartConfiguration', () => {
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@ import {
|
||||
type BarChartConfiguration,
|
||||
type LineChartConfiguration,
|
||||
} from '~/generated/graphql';
|
||||
import { isBarChartConfiguration } from '../isBarChartConfiguration';
|
||||
import { isBarChartConfiguration } from '@/command-menu/pages/page-layout/utils/isBarChartConfiguration';
|
||||
|
||||
describe('isBarChartConfiguration', () => {
|
||||
it('should return true for BarChartConfiguration', () => {
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@ import {
|
||||
type LineChartConfiguration,
|
||||
type PieChartConfiguration,
|
||||
} from '~/generated/graphql';
|
||||
import { isBarOrLineChartConfiguration } from '../isBarOrLineChartConfiguration';
|
||||
import { isBarOrLineChartConfiguration } from '@/command-menu/pages/page-layout/utils/isBarOrLineChartConfiguration';
|
||||
|
||||
describe('isBarOrLineChartConfiguration', () => {
|
||||
it('should return true for BarChartConfiguration', () => {
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@ import {
|
||||
type PieChartConfiguration,
|
||||
type StandaloneRichTextConfiguration,
|
||||
} from '~/generated/graphql';
|
||||
import { isChartConfiguration } from '../isChartConfiguration';
|
||||
import { isChartConfiguration } from '@/command-menu/pages/page-layout/utils/isChartConfiguration';
|
||||
|
||||
describe('isChartConfiguration', () => {
|
||||
it('should return true for BarChartConfiguration', () => {
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
import { type ObjectMetadataItem } from '@/object-metadata/types/ObjectMetadataItem';
|
||||
import { FieldMetadataType } from 'twenty-shared/types';
|
||||
import { isFieldOrRelationNestedFieldDateKind } from '../isFieldOrNestedFieldDateKind';
|
||||
import { isFieldOrRelationNestedFieldDateKind } from '@/command-menu/pages/page-layout/utils/isFieldOrNestedFieldDateKind';
|
||||
|
||||
describe('isFieldOrNestedFieldDateKind', () => {
|
||||
it('returns false when fieldId is null', () => {
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@ import {
|
||||
type BarChartConfiguration,
|
||||
type GaugeChartConfiguration,
|
||||
} from '~/generated/graphql';
|
||||
import { isGaugeChartConfiguration } from '../isGaugeChartConfiguration';
|
||||
import { isGaugeChartConfiguration } from '@/command-menu/pages/page-layout/utils/isGaugeChartConfiguration';
|
||||
|
||||
describe('isGaugeChartConfiguration', () => {
|
||||
it('should return true for GaugeChartConfiguration', () => {
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@ import {
|
||||
type BarChartConfiguration,
|
||||
type IframeConfiguration,
|
||||
} from '~/generated/graphql';
|
||||
import { isIframeConfiguration } from '../isIframeConfiguration';
|
||||
import { isIframeConfiguration } from '@/command-menu/pages/page-layout/utils/isIframeConfiguration';
|
||||
|
||||
describe('isIframeConfiguration', () => {
|
||||
it('should return true for IframeConfiguration', () => {
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@ import {
|
||||
type BarChartConfiguration,
|
||||
type LineChartConfiguration,
|
||||
} from '~/generated/graphql';
|
||||
import { isLineChartConfiguration } from '../isLineChartConfiguration';
|
||||
import { isLineChartConfiguration } from '@/command-menu/pages/page-layout/utils/isLineChartConfiguration';
|
||||
|
||||
describe('isLineChartConfiguration', () => {
|
||||
it('should return true for LineChartConfiguration', () => {
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@ import {
|
||||
type BarChartConfiguration,
|
||||
type PieChartConfiguration,
|
||||
} from '~/generated/graphql';
|
||||
import { isPieChartConfiguration } from '../isPieChartConfiguration';
|
||||
import { isPieChartConfiguration } from '@/command-menu/pages/page-layout/utils/isPieChartConfiguration';
|
||||
|
||||
describe('isPieChartConfiguration', () => {
|
||||
it('should return true for PieChartConfiguration', () => {
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ import { type ObjectMetadataItem } from '@/object-metadata/types/ObjectMetadataI
|
||||
import { msg } from '@lingui/core/macro';
|
||||
import { FieldMetadataType } from 'twenty-shared/types';
|
||||
import { IconChartBar } from 'twenty-ui/display';
|
||||
import { shouldHideChartSetting } from '../shouldHideChartSetting';
|
||||
import { shouldHideChartSetting } from '@/command-menu/pages/page-layout/utils/shouldHideChartSetting';
|
||||
|
||||
describe('shouldHideChartSetting', () => {
|
||||
const mockItemWithoutDependencies: ChartSettingsItem = {
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ import styled from '@emotion/styled';
|
||||
import { lazy, Suspense } from 'react';
|
||||
import Skeleton, { SkeletonTheme } from 'react-loading-skeleton';
|
||||
import { useRecoilValue } from 'recoil';
|
||||
import { viewableRichTextComponentState } from '../states/viewableRichTextComponentState';
|
||||
import { viewableRichTextComponentState } from '@/command-menu/pages/rich-text-page/states/viewableRichTextComponentState';
|
||||
|
||||
const ActivityRichTextEditor = lazy(() =>
|
||||
import('@/activities/components/ActivityRichTextEditor').then((module) => ({
|
||||
|
||||
Reference in New Issue
Block a user