Skip to content
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

Merged
merged 10 commits into from
Oct 20, 2024

Conversation

charlesBochet
Copy link
Member

@charlesBochet charlesBochet commented Oct 19, 2024

Fixes: #7329

'./packages/twenty-front/folderStructure.json',
},
rules: {
'project-structure/folder-structure': 'warn',
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

only warning for now

{ "ruleId": "moduleFolderRule" },
{ "name": "hooks", "ruleId": "hooksLeafFolderRule" },
{ "name": "utils", "ruleId": "utilsLeafFolderRule" },
{ "name": "states", "ruleId": "doNotCheckLeafFolderRule" },
Copy link
Member Author

Choose a reason for hiding this comment

The 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

Copy link
Member Author

Choose a reason for hiding this comment

The 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

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Summary

This PR enforces a new folder structure for the twenty-front package using ESLint rules, aiming to improve code organization and maintainability.

  • Added 'eslint-plugin-project-structure' in package.json and configured it in .eslintrc.cjs
  • Introduced folderStructure.json to define expected structure for modules, hooks, and utilities
  • Renamed test directories from 'test' to 'tests' for consistency
  • Changed file extensions from .tsx to .ts for several hooks in the workflow module
  • Reordered imports in some files to align with best practices

21 file(s) reviewed, 25 comment(s)
Edit PR Review Bot Settings | Greptile

@@ -21,7 +21,14 @@ module.exports = {
parserOptions: {
project: ['packages/twenty-front/tsconfig.{json,*.json}'],
},
rules: {},
plugins: ['project-structure'],
Copy link
Contributor

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

],
"rules": {
"moduleFolderRule": {
"name": "^(?!utils$|hooks$|states|types|graphql|components|effect-components|constants|validation-schemas|context$)[a-z][a-z0-9]**(?:-[a-z0-9]+)**$",
Copy link
Contributor

Choose a reason for hiding this comment

The 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.

"hooksLeafFolderRule": {
"folderRecursionLimit": 2,
"children": [
{ "name": "use{PascalCase}.(ts|tsx)" },
Copy link
Contributor

Choose a reason for hiding this comment

The 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": "modules",
"children": [
{ "ruleId": "moduleFolderRule" },
{ "name": "types", "ruleId": "doNotCheckLeafFolderRule" }
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

temporary

@charlesBochet charlesBochet merged commit eccf0bf into main Oct 20, 2024
18 checks passed
@charlesBochet charlesBochet deleted the eslint-rule-folder-structure branch October 20, 2024 18:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[ESLint plugin] Add a rule to enforce folder architecture on frontend
1 participant