-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enforce front project structure through ESLINT #7863
Changes from 1 commit
07c8097
8399d05
44e28eb
f3566ca
28db80e
ae412bd
5021f2b
736edcd
0d2d998
001626d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,7 +21,14 @@ module.exports = { | |
parserOptions: { | ||
project: ['packages/twenty-front/tsconfig.{json,*.json}'], | ||
}, | ||
rules: {}, | ||
plugins: ['project-structure'], | ||
settings: { | ||
'project-structure/folder-structure-config-path': | ||
'./packages/twenty-front/folderStructure.json', | ||
}, | ||
rules: { | ||
'project-structure/folder-structure': 'warn', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. only warning for now |
||
}, | ||
}, | ||
], | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
{ | ||
"$schema": "../../node_modules/eslint-plugin-project-structure/folderStructure.schema.json", | ||
"regexParameters": { | ||
"camelCase": "^[a-zA-Z]+([A-Z][a-z]+)+" | ||
}, | ||
"structure": [ | ||
{ | ||
"name": "packages", | ||
"children": [ | ||
{ | ||
"name": "twenty-front", | ||
"children": [ | ||
{ | ||
"name": "src", | ||
"children": [ | ||
{ "name": "*", "children": [] }, | ||
{ "name": "*" }, | ||
{ | ||
"name": "modules", | ||
"children": [{ "ruleId": "moduleFolderRule" }] | ||
} | ||
] | ||
} | ||
] | ||
} | ||
] | ||
} | ||
], | ||
"rules": { | ||
"moduleFolderRule": { | ||
"name": "^(?!utils$|hooks$|states|types|graphql|components|effect-components|constants|validation-schemas|context$)[a-z][a-z0-9]**(?:-[a-z0-9]+)**$", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. style: The regex for module folder names is complex and may be difficult to maintain. Consider simplifying or documenting it for clarity. |
||
"folderRecursionLimit": 3, | ||
"children": [ | ||
{ "ruleId": "moduleFolderRule" }, | ||
{ "name": "hooks", "ruleId": "hooksLeafFolderRule" }, | ||
{ "name": "utils", "ruleId": "utilsLeafFolderRule" }, | ||
{ "name": "states", "ruleId": "doNotCheckLeafFolderRule" }, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have added this rule for now we can progressively add the rules folder by folder once we have fixed the existing warnings (we have ~150), let's do it step by step There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've actually fixed existing warnings but I don't want to move everything now, we will activate these rules progressively |
||
{ "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": "context", "ruleId": "doNotCheckLeafFolderRule" } | ||
] | ||
}, | ||
"hooksLeafFolderRule": { | ||
"folderRecursionLimit": 2, | ||
"children": [ | ||
{ "name": "use{PascalCase}.(ts|tsx)" }, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. style: The naming convention for hooks files is strict. Ensure all existing hooks follow this pattern, or consider allowing more flexibility. |
||
{ | ||
"name": "__tests__", | ||
"children": [{ "name": "use{PascalCase}.test.(ts|tsx)" }] | ||
}, | ||
{ "name": "internal", "ruleId": "hooksLeafFolderRule" } | ||
] | ||
}, | ||
"doNotCheckLeafFolderRule": { | ||
"folderRecursionLimit": 1, | ||
"children": [{ "name": "*" }, { "name": "*", "children": [] }] | ||
}, | ||
"utilsLeafFolderRule": { | ||
"folderRecursionLimit": 1, | ||
"children": [ | ||
{ "name": "{camelCase}.ts" }, | ||
{ | ||
"name": "__tests__", | ||
"children": [{ "name": "{camelCase}.test.ts" }] | ||
} | ||
] | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: Consider adding a comment explaining the purpose of the 'project-structure' plugin for future maintainers