mirror of
https://github.com/lingble/twenty.git
synced 2025-11-02 21:57:56 +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/cache
|
||||
projectStructure.cache.json
|
||||
|
||||
.pnp.*
|
||||
.yarn/*
|
||||
|
||||
@@ -296,7 +296,7 @@
|
||||
"eslint-plugin-jsx-a11y": "^6.8.0",
|
||||
"eslint-plugin-prefer-arrow": "^1.2.3",
|
||||
"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-hooks": "^4.6.0",
|
||||
"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/
|
||||
.nyc_output/
|
||||
|
||||
# eslint-plugin-project-structure
|
||||
projectStructure.cache.json
|
||||
|
||||
@@ -1,57 +1,45 @@
|
||||
{
|
||||
"$schema": "../../node_modules/eslint-plugin-project-structure/folderStructure.schema.json",
|
||||
"projectRoot": "packages/twenty-front",
|
||||
"structureRoot": "src",
|
||||
"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": [
|
||||
{
|
||||
"name": "packages",
|
||||
"children": [
|
||||
{
|
||||
"name": "twenty-front",
|
||||
"children": [
|
||||
{ "name": "*", "children": [] },
|
||||
{ "name": "*" },
|
||||
{
|
||||
"name": "src",
|
||||
"children": [
|
||||
{ "name": "*", "children": [] },
|
||||
{ "name": "*" },
|
||||
{
|
||||
"name": "modules",
|
||||
"children": [
|
||||
{ "ruleId": "moduleFolderRule" },
|
||||
{ "name": "types", "ruleId": "doNotCheckLeafFolderRule" }
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
{ "name": "modules", "ruleId": "modulesFolderRule" }
|
||||
],
|
||||
"rules": {
|
||||
"modulesFolderRule": {
|
||||
"children": [
|
||||
{ "ruleId": "moduleFolderRule" },
|
||||
{ "name": "types", "children": [] }
|
||||
]
|
||||
},
|
||||
|
||||
"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,
|
||||
"children": [
|
||||
{ "ruleId": "moduleFolderRule" },
|
||||
{ "name": "hooks", "ruleId": "hooksLeafFolderRule" },
|
||||
{ "name": "utils", "ruleId": "utilsLeafFolderRule" },
|
||||
{ "name": "states", "ruleId": "doNotCheckLeafFolderRule" },
|
||||
{ "name": "types", "ruleId": "doNotCheckLeafFolderRule" },
|
||||
{ "name": "graphql", "ruleId": "doNotCheckLeafFolderRule" },
|
||||
{ "name": "components", "ruleId": "doNotCheckLeafFolderRule" },
|
||||
{ "name": "effect-components", "ruleId": "doNotCheckLeafFolderRule" },
|
||||
{ "name": "constants", "ruleId": "doNotCheckLeafFolderRule" },
|
||||
{ "name": "validation-schemas", "ruleId": "doNotCheckLeafFolderRule" },
|
||||
{ "name": "contexts", "ruleId": "doNotCheckLeafFolderRule" },
|
||||
{ "name": "scopes", "ruleId": "doNotCheckLeafFolderRule" },
|
||||
{ "name": "services", "ruleId": "doNotCheckLeafFolderRule" },
|
||||
{ "name": "errors", "ruleId": "doNotCheckLeafFolderRule" }
|
||||
{ "name": "states", "children": [] },
|
||||
{ "name": "types", "children": [] },
|
||||
{ "name": "graphql", "children": [] },
|
||||
{ "name": "components", "children": [] },
|
||||
{ "name": "effect-components", "children": [] },
|
||||
{ "name": "constants", "children": [] },
|
||||
{ "name": "validation-schemas", "children": [] },
|
||||
{ "name": "contexts", "children": [] },
|
||||
{ "name": "scopes", "children": [] },
|
||||
{ "name": "services", "children": [] },
|
||||
{ "name": "errors", "children": [] }
|
||||
]
|
||||
},
|
||||
|
||||
"hooksLeafFolderRule": {
|
||||
"folderRecursionLimit": 2,
|
||||
"children": [
|
||||
@@ -63,12 +51,8 @@
|
||||
{ "name": "internal", "ruleId": "hooksLeafFolderRule" }
|
||||
]
|
||||
},
|
||||
"doNotCheckLeafFolderRule": {
|
||||
"folderRecursionLimit": 1,
|
||||
"children": [{ "name": "*" }, { "name": "*", "children": [] }]
|
||||
},
|
||||
|
||||
"utilsLeafFolderRule": {
|
||||
"folderRecursionLimit": 1,
|
||||
"children": [
|
||||
{ "name": "{camelCase}.ts" },
|
||||
{
|
||||
|
||||
@@ -11,5 +11,5 @@ export const query = gql`
|
||||
export const variables = { idToDelete: 'idToDelete' };
|
||||
|
||||
export const responseData = {
|
||||
id: 'idToDelete'
|
||||
id: 'idToDelete',
|
||||
};
|
||||
|
||||
@@ -2,7 +2,8 @@ import { gql } from '@apollo/client';
|
||||
import { FieldMetadataType } from '~/generated/graphql';
|
||||
|
||||
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';
|
||||
|
||||
const baseFields = `
|
||||
@@ -94,7 +95,7 @@ export const variables = {
|
||||
deactivateMetadataField: {
|
||||
idToUpdate: FIELD_METADATA_ID,
|
||||
updatePayload: { isActive: false, label: undefined },
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
const defaultResponseData = {
|
||||
@@ -127,4 +128,3 @@ export const responseData = {
|
||||
options: [],
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ export const PERSON_FRAGMENT_WITH_DEPTH_ZERO_RELATIONS = `
|
||||
primaryLinkLabel
|
||||
secondaryLinks
|
||||
}
|
||||
`
|
||||
`;
|
||||
|
||||
export const PERSON_FRAGMENT_WITH_DEPTH_ONE_RELATIONS = `
|
||||
__typename
|
||||
@@ -324,4 +324,4 @@ export const PERSON_FRAGMENT_WITH_DEPTH_ONE_RELATIONS = `
|
||||
primaryLinkLabel
|
||||
secondaryLinks
|
||||
}
|
||||
`
|
||||
`;
|
||||
|
||||
@@ -3,10 +3,19 @@ import { gql } from '@apollo/client';
|
||||
|
||||
import { peopleQueryResult } from '~/testing/mock-data/people';
|
||||
|
||||
|
||||
export const query = gql`
|
||||
query FindManyPeople($filter: PersonFilterInput, $orderBy: [PersonOrderByInput], $lastCursor: String, $limit: Int) {
|
||||
people(filter: $filter, orderBy: $orderBy, first: $limit, after: $lastCursor){
|
||||
query FindManyPeople(
|
||||
$filter: PersonFilterInput
|
||||
$orderBy: [PersonOrderByInput]
|
||||
$lastCursor: String
|
||||
$limit: Int
|
||||
) {
|
||||
people(
|
||||
filter: $filter
|
||||
orderBy: $orderBy
|
||||
first: $limit
|
||||
after: $lastCursor
|
||||
) {
|
||||
edges {
|
||||
node {
|
||||
__typename
|
||||
@@ -27,38 +36,51 @@ export const query = gql`
|
||||
|
||||
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 secondRequestLastCursor = peopleMockWithIdsOnly.edges[mockPageSize * 2].cursor;
|
||||
export const thirdRequestLastCursor = peopleMockWithIdsOnly.edges[mockPageSize * 3].cursor;
|
||||
export const firstRequestLastCursor =
|
||||
peopleMockWithIdsOnly.edges[mockPageSize].cursor;
|
||||
export const secondRequestLastCursor =
|
||||
peopleMockWithIdsOnly.edges[mockPageSize * 2].cursor;
|
||||
export const thirdRequestLastCursor =
|
||||
peopleMockWithIdsOnly.edges[mockPageSize * 3].cursor;
|
||||
|
||||
export const variablesFirstRequest = {
|
||||
filter: undefined,
|
||||
limit: mockPageSize,
|
||||
orderBy: undefined
|
||||
orderBy: undefined,
|
||||
};
|
||||
|
||||
export const variablesSecondRequest = {
|
||||
filter: undefined,
|
||||
limit: mockPageSize,
|
||||
orderBy: undefined,
|
||||
lastCursor: firstRequestLastCursor
|
||||
lastCursor: firstRequestLastCursor,
|
||||
};
|
||||
|
||||
export const variablesThirdRequest = {
|
||||
filter: undefined,
|
||||
limit: mockPageSize,
|
||||
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 {
|
||||
...response,
|
||||
edges: [
|
||||
...response.edges.slice(start, end)
|
||||
],
|
||||
edges: [...response.edges.slice(start, end)],
|
||||
pageInfo: {
|
||||
...response.pageInfo,
|
||||
startCursor: response.edges[start].cursor,
|
||||
@@ -66,17 +88,35 @@ const paginateRequestResponse = (response: RecordGqlConnection, start: number, e
|
||||
hasNextPage,
|
||||
} satisfies RecordGqlConnection['pageInfo'],
|
||||
totalCount,
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
export const responseFirstRequest = {
|
||||
people: paginateRequestResponse(peopleMockWithIdsOnly, 0, mockPageSize, true, 6),
|
||||
people: paginateRequestResponse(
|
||||
peopleMockWithIdsOnly,
|
||||
0,
|
||||
mockPageSize,
|
||||
true,
|
||||
6,
|
||||
),
|
||||
};
|
||||
|
||||
export const responseSecondRequest = {
|
||||
people: paginateRequestResponse(peopleMockWithIdsOnly, mockPageSize, mockPageSize * 2, true, 6),
|
||||
people: paginateRequestResponse(
|
||||
peopleMockWithIdsOnly,
|
||||
mockPageSize,
|
||||
mockPageSize * 2,
|
||||
true,
|
||||
6,
|
||||
),
|
||||
};
|
||||
|
||||
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,
|
||||
FieldRatingMetadata,
|
||||
FieldSelectMetadata,
|
||||
FieldTextMetadata
|
||||
FieldTextMetadata,
|
||||
} from '@/object-record/record-field/types/FieldMetadata';
|
||||
import { FieldMetadataType } from '~/generated-metadata/graphql';
|
||||
import { generatedMockObjectMetadataItems } from '~/testing/mock-data/generatedMockObjectMetadataItems';
|
||||
@@ -29,7 +29,6 @@ if (!mockedPersonObjectMetadataItem) {
|
||||
throw new Error('Person object metadata item not found');
|
||||
}
|
||||
|
||||
|
||||
const relationFieldMetadataItem = mockedPersonObjectMetadataItem?.fields?.find(
|
||||
({ name }) => name === 'company',
|
||||
);
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import styled from '@emotion/styled';
|
||||
|
||||
import {
|
||||
// eslint-disable-next-line prettier/prettier
|
||||
SettingsDataModelFieldPreview,
|
||||
SettingsDataModelFieldPreviewProps,
|
||||
} 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
|
||||
linkType: hard
|
||||
|
||||
"eslint-plugin-project-structure@npm:^3.7.2":
|
||||
version: 3.7.2
|
||||
resolution: "eslint-plugin-project-structure@npm:3.7.2"
|
||||
"eslint-plugin-project-structure@npm:^3.9.1":
|
||||
version: 3.9.1
|
||||
resolution: "eslint-plugin-project-structure@npm:3.9.1"
|
||||
dependencies:
|
||||
"@typescript-eslint/utils": "npm:^8.8.0"
|
||||
comment-json: "npm:^4.2.5"
|
||||
js-yaml: "npm:^4.1.0"
|
||||
jsonschema: "npm:^1.4.1"
|
||||
micromatch: "npm:^4.0.8"
|
||||
checksum: 10c0/bb5d972cb2f24eceae0b5eefc7ccfaed1e0802977bc5ea33d3eb105521b590b5a69b36adcd3124ae67367af6b7798a05b17f06d085deaf9059e53b0839e3621e
|
||||
checksum: 10c0/be37a67298568931ae7fa29b4afe2ad97f945652ea0e595fcc2dd6ce2e09d9e5bb981a99b6b5e1e9a807655a26924c19b640b69a72828ba5bf0aa2ebbfa79df4
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
@@ -44484,7 +44484,7 @@ __metadata:
|
||||
eslint-plugin-jsx-a11y: "npm:^6.8.0"
|
||||
eslint-plugin-prefer-arrow: "npm:^1.2.3"
|
||||
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-hooks: "npm:^4.6.0"
|
||||
eslint-plugin-react-refresh: "npm:^0.4.4"
|
||||
|
||||
Reference in New Issue
Block a user