mirror of
https://github.com/lingble/twenty.git
synced 2025-11-03 14:17:58 +00:00
folderStructure.json refactor (#8088)
#7911 If you encounter any issues or have any questions regarding the library, feel free to write [here](https://github.com/Igorkowalski94/eslint-plugin-project-structure/discussions/new?category=help), I’d be happy to help.
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -9,7 +9,6 @@
|
|||||||
|
|
||||||
.nx/installation
|
.nx/installation
|
||||||
.nx/cache
|
.nx/cache
|
||||||
projectStructure.cache.json
|
|
||||||
|
|
||||||
.pnp.*
|
.pnp.*
|
||||||
.yarn/*
|
.yarn/*
|
||||||
|
|||||||
@@ -296,7 +296,7 @@
|
|||||||
"eslint-plugin-jsx-a11y": "^6.8.0",
|
"eslint-plugin-jsx-a11y": "^6.8.0",
|
||||||
"eslint-plugin-prefer-arrow": "^1.2.3",
|
"eslint-plugin-prefer-arrow": "^1.2.3",
|
||||||
"eslint-plugin-prettier": "^5.1.2",
|
"eslint-plugin-prettier": "^5.1.2",
|
||||||
"eslint-plugin-project-structure": "^3.7.2",
|
"eslint-plugin-project-structure": "^3.9.1",
|
||||||
"eslint-plugin-react": "^7.33.2",
|
"eslint-plugin-react": "^7.33.2",
|
||||||
"eslint-plugin-react-hooks": "^4.6.0",
|
"eslint-plugin-react-hooks": "^4.6.0",
|
||||||
"eslint-plugin-react-refresh": "^0.4.4",
|
"eslint-plugin-react-refresh": "^0.4.4",
|
||||||
|
|||||||
3
packages/twenty-front/.gitignore
vendored
3
packages/twenty-front/.gitignore
vendored
@@ -42,3 +42,6 @@ dist-ssr
|
|||||||
|
|
||||||
.vite/
|
.vite/
|
||||||
.nyc_output/
|
.nyc_output/
|
||||||
|
|
||||||
|
# eslint-plugin-project-structure
|
||||||
|
projectStructure.cache.json
|
||||||
|
|||||||
@@ -1,57 +1,45 @@
|
|||||||
{
|
{
|
||||||
"$schema": "../../node_modules/eslint-plugin-project-structure/folderStructure.schema.json",
|
"$schema": "../../node_modules/eslint-plugin-project-structure/folderStructure.schema.json",
|
||||||
|
"projectRoot": "packages/twenty-front",
|
||||||
|
"structureRoot": "src",
|
||||||
"regexParameters": {
|
"regexParameters": {
|
||||||
"camelCase": "^[a-z]+[A-Za-z0-9]+"
|
"camelCase": "^[a-z]+([A-Za-z0-9]+)+",
|
||||||
|
"kebab-case": "[a-z][a-z0-9]*(?:-[a-z0-9]+)*"
|
||||||
},
|
},
|
||||||
"structure": [
|
"structure": [
|
||||||
{
|
|
||||||
"name": "packages",
|
|
||||||
"children": [
|
|
||||||
{
|
|
||||||
"name": "twenty-front",
|
|
||||||
"children": [
|
|
||||||
{ "name": "*", "children": [] },
|
|
||||||
{ "name": "*" },
|
{ "name": "*" },
|
||||||
{
|
|
||||||
"name": "src",
|
|
||||||
"children": [
|
|
||||||
{ "name": "*", "children": [] },
|
{ "name": "*", "children": [] },
|
||||||
{ "name": "*" },
|
{ "name": "modules", "ruleId": "modulesFolderRule" }
|
||||||
{
|
|
||||||
"name": "modules",
|
|
||||||
"children": [
|
|
||||||
{ "ruleId": "moduleFolderRule" },
|
|
||||||
{ "name": "types", "ruleId": "doNotCheckLeafFolderRule" }
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
],
|
||||||
"rules": {
|
"rules": {
|
||||||
|
"modulesFolderRule": {
|
||||||
|
"children": [
|
||||||
|
{ "ruleId": "moduleFolderRule" },
|
||||||
|
{ "name": "types", "children": [] }
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
"moduleFolderRule": {
|
"moduleFolderRule": {
|
||||||
"name": "^(?!utils$|hooks$|states$|types$|graphql$|components$|effect-components$|constants$|validation-schemas$|contexts$|scopes$|services$|errors$)[a-z][a-z0-9]**(?:-[a-z0-9]+)**$",
|
"name": "{kebab-case}",
|
||||||
"folderRecursionLimit": 6,
|
"folderRecursionLimit": 6,
|
||||||
"children": [
|
"children": [
|
||||||
{ "ruleId": "moduleFolderRule" },
|
{ "ruleId": "moduleFolderRule" },
|
||||||
{ "name": "hooks", "ruleId": "hooksLeafFolderRule" },
|
{ "name": "hooks", "ruleId": "hooksLeafFolderRule" },
|
||||||
{ "name": "utils", "ruleId": "utilsLeafFolderRule" },
|
{ "name": "utils", "ruleId": "utilsLeafFolderRule" },
|
||||||
{ "name": "states", "ruleId": "doNotCheckLeafFolderRule" },
|
{ "name": "states", "children": [] },
|
||||||
{ "name": "types", "ruleId": "doNotCheckLeafFolderRule" },
|
{ "name": "types", "children": [] },
|
||||||
{ "name": "graphql", "ruleId": "doNotCheckLeafFolderRule" },
|
{ "name": "graphql", "children": [] },
|
||||||
{ "name": "components", "ruleId": "doNotCheckLeafFolderRule" },
|
{ "name": "components", "children": [] },
|
||||||
{ "name": "effect-components", "ruleId": "doNotCheckLeafFolderRule" },
|
{ "name": "effect-components", "children": [] },
|
||||||
{ "name": "constants", "ruleId": "doNotCheckLeafFolderRule" },
|
{ "name": "constants", "children": [] },
|
||||||
{ "name": "validation-schemas", "ruleId": "doNotCheckLeafFolderRule" },
|
{ "name": "validation-schemas", "children": [] },
|
||||||
{ "name": "contexts", "ruleId": "doNotCheckLeafFolderRule" },
|
{ "name": "contexts", "children": [] },
|
||||||
{ "name": "scopes", "ruleId": "doNotCheckLeafFolderRule" },
|
{ "name": "scopes", "children": [] },
|
||||||
{ "name": "services", "ruleId": "doNotCheckLeafFolderRule" },
|
{ "name": "services", "children": [] },
|
||||||
{ "name": "errors", "ruleId": "doNotCheckLeafFolderRule" }
|
{ "name": "errors", "children": [] }
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
||||||
"hooksLeafFolderRule": {
|
"hooksLeafFolderRule": {
|
||||||
"folderRecursionLimit": 2,
|
"folderRecursionLimit": 2,
|
||||||
"children": [
|
"children": [
|
||||||
@@ -63,12 +51,8 @@
|
|||||||
{ "name": "internal", "ruleId": "hooksLeafFolderRule" }
|
{ "name": "internal", "ruleId": "hooksLeafFolderRule" }
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"doNotCheckLeafFolderRule": {
|
|
||||||
"folderRecursionLimit": 1,
|
|
||||||
"children": [{ "name": "*" }, { "name": "*", "children": [] }]
|
|
||||||
},
|
|
||||||
"utilsLeafFolderRule": {
|
"utilsLeafFolderRule": {
|
||||||
"folderRecursionLimit": 1,
|
|
||||||
"children": [
|
"children": [
|
||||||
{ "name": "{camelCase}.ts" },
|
{ "name": "{camelCase}.ts" },
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -11,5 +11,5 @@ export const query = gql`
|
|||||||
export const variables = { idToDelete: 'idToDelete' };
|
export const variables = { idToDelete: 'idToDelete' };
|
||||||
|
|
||||||
export const responseData = {
|
export const responseData = {
|
||||||
id: 'idToDelete'
|
id: 'idToDelete',
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -2,7 +2,8 @@ import { gql } from '@apollo/client';
|
|||||||
import { FieldMetadataType } from '~/generated/graphql';
|
import { FieldMetadataType } from '~/generated/graphql';
|
||||||
|
|
||||||
export const FIELD_METADATA_ID = '2c43466a-fe9e-4005-8d08-c5836067aa6c';
|
export const FIELD_METADATA_ID = '2c43466a-fe9e-4005-8d08-c5836067aa6c';
|
||||||
export const FIELD_RELATION_METADATA_ID = '4da0302d-358a-45cd-9973-9f92723ed3c1';
|
export const FIELD_RELATION_METADATA_ID =
|
||||||
|
'4da0302d-358a-45cd-9973-9f92723ed3c1';
|
||||||
export const RELATION_METADATA_ID = 'f81d4fae-7dec-11d0-a765-00a0c91e6bf6';
|
export const RELATION_METADATA_ID = 'f81d4fae-7dec-11d0-a765-00a0c91e6bf6';
|
||||||
|
|
||||||
const baseFields = `
|
const baseFields = `
|
||||||
@@ -94,7 +95,7 @@ export const variables = {
|
|||||||
deactivateMetadataField: {
|
deactivateMetadataField: {
|
||||||
idToUpdate: FIELD_METADATA_ID,
|
idToUpdate: FIELD_METADATA_ID,
|
||||||
updatePayload: { isActive: false, label: undefined },
|
updatePayload: { isActive: false, label: undefined },
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const defaultResponseData = {
|
const defaultResponseData = {
|
||||||
@@ -127,4 +128,3 @@ export const responseData = {
|
|||||||
options: [],
|
options: [],
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ export const PERSON_FRAGMENT_WITH_DEPTH_ZERO_RELATIONS = `
|
|||||||
primaryLinkLabel
|
primaryLinkLabel
|
||||||
secondaryLinks
|
secondaryLinks
|
||||||
}
|
}
|
||||||
`
|
`;
|
||||||
|
|
||||||
export const PERSON_FRAGMENT_WITH_DEPTH_ONE_RELATIONS = `
|
export const PERSON_FRAGMENT_WITH_DEPTH_ONE_RELATIONS = `
|
||||||
__typename
|
__typename
|
||||||
@@ -324,4 +324,4 @@ export const PERSON_FRAGMENT_WITH_DEPTH_ONE_RELATIONS = `
|
|||||||
primaryLinkLabel
|
primaryLinkLabel
|
||||||
secondaryLinks
|
secondaryLinks
|
||||||
}
|
}
|
||||||
`
|
`;
|
||||||
|
|||||||
@@ -3,10 +3,19 @@ import { gql } from '@apollo/client';
|
|||||||
|
|
||||||
import { peopleQueryResult } from '~/testing/mock-data/people';
|
import { peopleQueryResult } from '~/testing/mock-data/people';
|
||||||
|
|
||||||
|
|
||||||
export const query = gql`
|
export const query = gql`
|
||||||
query FindManyPeople($filter: PersonFilterInput, $orderBy: [PersonOrderByInput], $lastCursor: String, $limit: Int) {
|
query FindManyPeople(
|
||||||
people(filter: $filter, orderBy: $orderBy, first: $limit, after: $lastCursor){
|
$filter: PersonFilterInput
|
||||||
|
$orderBy: [PersonOrderByInput]
|
||||||
|
$lastCursor: String
|
||||||
|
$limit: Int
|
||||||
|
) {
|
||||||
|
people(
|
||||||
|
filter: $filter
|
||||||
|
orderBy: $orderBy
|
||||||
|
first: $limit
|
||||||
|
after: $lastCursor
|
||||||
|
) {
|
||||||
edges {
|
edges {
|
||||||
node {
|
node {
|
||||||
__typename
|
__typename
|
||||||
@@ -27,38 +36,51 @@ export const query = gql`
|
|||||||
|
|
||||||
export const mockPageSize = 2;
|
export const mockPageSize = 2;
|
||||||
|
|
||||||
export const peopleMockWithIdsOnly: RecordGqlConnection = { ...peopleQueryResult.people,edges: peopleQueryResult.people.edges.map((edge) => ({ ...edge, node: { __typename: 'Person', id: edge.node.id } })) };
|
export const peopleMockWithIdsOnly: RecordGqlConnection = {
|
||||||
|
...peopleQueryResult.people,
|
||||||
|
edges: peopleQueryResult.people.edges.map((edge) => ({
|
||||||
|
...edge,
|
||||||
|
node: { __typename: 'Person', id: edge.node.id },
|
||||||
|
})),
|
||||||
|
};
|
||||||
|
|
||||||
export const firstRequestLastCursor = peopleMockWithIdsOnly.edges[mockPageSize].cursor;
|
export const firstRequestLastCursor =
|
||||||
export const secondRequestLastCursor = peopleMockWithIdsOnly.edges[mockPageSize * 2].cursor;
|
peopleMockWithIdsOnly.edges[mockPageSize].cursor;
|
||||||
export const thirdRequestLastCursor = peopleMockWithIdsOnly.edges[mockPageSize * 3].cursor;
|
export const secondRequestLastCursor =
|
||||||
|
peopleMockWithIdsOnly.edges[mockPageSize * 2].cursor;
|
||||||
|
export const thirdRequestLastCursor =
|
||||||
|
peopleMockWithIdsOnly.edges[mockPageSize * 3].cursor;
|
||||||
|
|
||||||
export const variablesFirstRequest = {
|
export const variablesFirstRequest = {
|
||||||
filter: undefined,
|
filter: undefined,
|
||||||
limit: mockPageSize,
|
limit: mockPageSize,
|
||||||
orderBy: undefined
|
orderBy: undefined,
|
||||||
};
|
};
|
||||||
|
|
||||||
export const variablesSecondRequest = {
|
export const variablesSecondRequest = {
|
||||||
filter: undefined,
|
filter: undefined,
|
||||||
limit: mockPageSize,
|
limit: mockPageSize,
|
||||||
orderBy: undefined,
|
orderBy: undefined,
|
||||||
lastCursor: firstRequestLastCursor
|
lastCursor: firstRequestLastCursor,
|
||||||
};
|
};
|
||||||
|
|
||||||
export const variablesThirdRequest = {
|
export const variablesThirdRequest = {
|
||||||
filter: undefined,
|
filter: undefined,
|
||||||
limit: mockPageSize,
|
limit: mockPageSize,
|
||||||
orderBy: undefined,
|
orderBy: undefined,
|
||||||
lastCursor: secondRequestLastCursor
|
lastCursor: secondRequestLastCursor,
|
||||||
}
|
};
|
||||||
|
|
||||||
const paginateRequestResponse = (response: RecordGqlConnection, start: number, end: number, hasNextPage: boolean, totalCount: number) => {
|
const paginateRequestResponse = (
|
||||||
|
response: RecordGqlConnection,
|
||||||
|
start: number,
|
||||||
|
end: number,
|
||||||
|
hasNextPage: boolean,
|
||||||
|
totalCount: number,
|
||||||
|
) => {
|
||||||
return {
|
return {
|
||||||
...response,
|
...response,
|
||||||
edges: [
|
edges: [...response.edges.slice(start, end)],
|
||||||
...response.edges.slice(start, end)
|
|
||||||
],
|
|
||||||
pageInfo: {
|
pageInfo: {
|
||||||
...response.pageInfo,
|
...response.pageInfo,
|
||||||
startCursor: response.edges[start].cursor,
|
startCursor: response.edges[start].cursor,
|
||||||
@@ -66,17 +88,35 @@ const paginateRequestResponse = (response: RecordGqlConnection, start: number, e
|
|||||||
hasNextPage,
|
hasNextPage,
|
||||||
} satisfies RecordGqlConnection['pageInfo'],
|
} satisfies RecordGqlConnection['pageInfo'],
|
||||||
totalCount,
|
totalCount,
|
||||||
}
|
};
|
||||||
}
|
};
|
||||||
|
|
||||||
export const responseFirstRequest = {
|
export const responseFirstRequest = {
|
||||||
people: paginateRequestResponse(peopleMockWithIdsOnly, 0, mockPageSize, true, 6),
|
people: paginateRequestResponse(
|
||||||
|
peopleMockWithIdsOnly,
|
||||||
|
0,
|
||||||
|
mockPageSize,
|
||||||
|
true,
|
||||||
|
6,
|
||||||
|
),
|
||||||
};
|
};
|
||||||
|
|
||||||
export const responseSecondRequest = {
|
export const responseSecondRequest = {
|
||||||
people: paginateRequestResponse(peopleMockWithIdsOnly, mockPageSize, mockPageSize * 2, true, 6),
|
people: paginateRequestResponse(
|
||||||
|
peopleMockWithIdsOnly,
|
||||||
|
mockPageSize,
|
||||||
|
mockPageSize * 2,
|
||||||
|
true,
|
||||||
|
6,
|
||||||
|
),
|
||||||
};
|
};
|
||||||
|
|
||||||
export const responseThirdRequest = {
|
export const responseThirdRequest = {
|
||||||
people: paginateRequestResponse(peopleMockWithIdsOnly, mockPageSize * 2, mockPageSize * 3, false, 6),
|
people: paginateRequestResponse(
|
||||||
|
peopleMockWithIdsOnly,
|
||||||
|
mockPageSize * 2,
|
||||||
|
mockPageSize * 3,
|
||||||
|
false,
|
||||||
|
6,
|
||||||
|
),
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import {
|
|||||||
FieldFullNameMetadata,
|
FieldFullNameMetadata,
|
||||||
FieldRatingMetadata,
|
FieldRatingMetadata,
|
||||||
FieldSelectMetadata,
|
FieldSelectMetadata,
|
||||||
FieldTextMetadata
|
FieldTextMetadata,
|
||||||
} from '@/object-record/record-field/types/FieldMetadata';
|
} from '@/object-record/record-field/types/FieldMetadata';
|
||||||
import { FieldMetadataType } from '~/generated-metadata/graphql';
|
import { FieldMetadataType } from '~/generated-metadata/graphql';
|
||||||
import { generatedMockObjectMetadataItems } from '~/testing/mock-data/generatedMockObjectMetadataItems';
|
import { generatedMockObjectMetadataItems } from '~/testing/mock-data/generatedMockObjectMetadataItems';
|
||||||
@@ -29,7 +29,6 @@ if (!mockedPersonObjectMetadataItem) {
|
|||||||
throw new Error('Person object metadata item not found');
|
throw new Error('Person object metadata item not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const relationFieldMetadataItem = mockedPersonObjectMetadataItem?.fields?.find(
|
const relationFieldMetadataItem = mockedPersonObjectMetadataItem?.fields?.find(
|
||||||
({ name }) => name === 'company',
|
({ name }) => name === 'company',
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import styled from '@emotion/styled';
|
import styled from '@emotion/styled';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
// eslint-disable-next-line prettier/prettier
|
|
||||||
SettingsDataModelFieldPreview,
|
SettingsDataModelFieldPreview,
|
||||||
SettingsDataModelFieldPreviewProps,
|
SettingsDataModelFieldPreviewProps,
|
||||||
} from '@/settings/data-model/fields/preview/components/SettingsDataModelFieldPreview';
|
} from '@/settings/data-model/fields/preview/components/SettingsDataModelFieldPreview';
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
10
yarn.lock
10
yarn.lock
@@ -25835,16 +25835,16 @@ __metadata:
|
|||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
"eslint-plugin-project-structure@npm:^3.7.2":
|
"eslint-plugin-project-structure@npm:^3.9.1":
|
||||||
version: 3.7.2
|
version: 3.9.1
|
||||||
resolution: "eslint-plugin-project-structure@npm:3.7.2"
|
resolution: "eslint-plugin-project-structure@npm:3.9.1"
|
||||||
dependencies:
|
dependencies:
|
||||||
"@typescript-eslint/utils": "npm:^8.8.0"
|
"@typescript-eslint/utils": "npm:^8.8.0"
|
||||||
comment-json: "npm:^4.2.5"
|
comment-json: "npm:^4.2.5"
|
||||||
js-yaml: "npm:^4.1.0"
|
js-yaml: "npm:^4.1.0"
|
||||||
jsonschema: "npm:^1.4.1"
|
jsonschema: "npm:^1.4.1"
|
||||||
micromatch: "npm:^4.0.8"
|
micromatch: "npm:^4.0.8"
|
||||||
checksum: 10c0/bb5d972cb2f24eceae0b5eefc7ccfaed1e0802977bc5ea33d3eb105521b590b5a69b36adcd3124ae67367af6b7798a05b17f06d085deaf9059e53b0839e3621e
|
checksum: 10c0/be37a67298568931ae7fa29b4afe2ad97f945652ea0e595fcc2dd6ce2e09d9e5bb981a99b6b5e1e9a807655a26924c19b640b69a72828ba5bf0aa2ebbfa79df4
|
||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
@@ -44484,7 +44484,7 @@ __metadata:
|
|||||||
eslint-plugin-jsx-a11y: "npm:^6.8.0"
|
eslint-plugin-jsx-a11y: "npm:^6.8.0"
|
||||||
eslint-plugin-prefer-arrow: "npm:^1.2.3"
|
eslint-plugin-prefer-arrow: "npm:^1.2.3"
|
||||||
eslint-plugin-prettier: "npm:^5.1.2"
|
eslint-plugin-prettier: "npm:^5.1.2"
|
||||||
eslint-plugin-project-structure: "npm:^3.7.2"
|
eslint-plugin-project-structure: "npm:^3.9.1"
|
||||||
eslint-plugin-react: "npm:^7.33.2"
|
eslint-plugin-react: "npm:^7.33.2"
|
||||||
eslint-plugin-react-hooks: "npm:^4.6.0"
|
eslint-plugin-react-hooks: "npm:^4.6.0"
|
||||||
eslint-plugin-react-refresh: "npm:^0.4.4"
|
eslint-plugin-react-refresh: "npm:^0.4.4"
|
||||||
|
|||||||
Reference in New Issue
Block a user