fea47aa9f8
## Summary
- Re-implements `eslint-plugin-project-structure`'s folder structure
enforcement as a custom oxlint rule (`twenty/folder-structure`),
recovering functionality lost during the ESLint → Oxlint migration
- Validates `src/modules/` structure: kebab-case module folder names,
allowed subdirectories (hooks, utils, components, states, types,
graphql, etc.), hook file naming (`use{PascalCase}.(ts|tsx)`), util file
naming (`{camelCase}.(ts|tsx)`), and module nesting depth (max 4 levels)
- Enabled as `"warn"` in twenty-front with 403 pre-existing violations
to address incrementally
## What the rule checks
| Check | Example valid | Example invalid |
|-------|-------------|-----------------|
| Module names kebab-case | `object-record/` | `graphWidgetBarChart/` |
| Allowed subdirs only | `hooks/`, `components/`, `utils/` |
`random-stuff/` |
| Hook file naming | `useMyHook.ts` | `badName.ts` |
| Util file naming | `buildQuery.ts` | `build-query.ts` |
| Max nesting depth 4 | `a/b/c/d/hooks/` | `a/b/c/d/e/hooks/` |
| Utils kebab-case subfolders | `utils/cron-to-human/` |
`utils/camelCase/` |
## Pre-existing violations (403 total)
| Category | Count | Examples |
|----------|-------|---------|
| Non-kebab-case module names | 160 | `graphWidgetBarChart`,
`AIChatThreads` |
| Module depth > 4 | 215 |
`settings/roles/role-permissions/object-level-permissions/field-permissions`
|
| Util file naming | 22 | `.util.ts` suffix, kebab-case, PascalCase
filenames |
| Misc (hooks, tests) | 6 | Non-hook files in hooks/, folders in test
dirs |
126 lines
3.9 KiB
JSON
126 lines
3.9 KiB
JSON
{
|
|
"$schema": "./node_modules/oxlint/configuration_schema.json",
|
|
"plugins": ["react", "typescript", "unicorn", "import"],
|
|
"jsPlugins": ["../twenty-oxlint-rules/dist/oxlint-plugin.mjs"],
|
|
"categories": {
|
|
"correctness": "off"
|
|
},
|
|
"ignorePatterns": [
|
|
"node_modules",
|
|
"src/generated",
|
|
"src/generated-metadata",
|
|
"src/locales/generated",
|
|
"src/testing/mock-data",
|
|
"**/__mocks__/**",
|
|
"**/*.stories.ts",
|
|
"**/*.stories.tsx",
|
|
"build",
|
|
"coverage",
|
|
"storybook-static"
|
|
],
|
|
"rules": {
|
|
"func-style": ["error", "declaration", { "allowArrowFunctions": true }],
|
|
"no-console": ["warn", { "allow": ["group", "groupCollapsed", "groupEnd"] }],
|
|
"no-control-regex": "off",
|
|
"no-debugger": "error",
|
|
"no-duplicate-imports": "error",
|
|
"no-undef": "off",
|
|
"no-unused-vars": "off",
|
|
"no-redeclare": "off",
|
|
"no-restricted-imports": ["error", {
|
|
"patterns": [
|
|
{
|
|
"group": ["../*"],
|
|
"message": "Relative parent imports are not allowed. Use @/ alias instead."
|
|
},
|
|
{
|
|
"group": ["@tabler/icons-react"],
|
|
"message": "Please import icons from `twenty-ui`"
|
|
},
|
|
{
|
|
"group": ["react-hotkeys-web-hook"],
|
|
"importNames": ["useHotkeys"],
|
|
"message": "Please use the custom wrapper: `useScopedHotkeys` from `twenty-ui`"
|
|
},
|
|
{
|
|
"group": ["lodash"],
|
|
"message": "Please use the standalone lodash package (for instance: `import groupBy from 'lodash.groupby'` instead of `import { groupBy } from 'lodash'`)"
|
|
}
|
|
]
|
|
}],
|
|
|
|
"import/no-duplicates": "error",
|
|
|
|
"react/no-unescaped-entities": "off",
|
|
"react/prop-types": "off",
|
|
"react/jsx-key": "off",
|
|
"react/display-name": "off",
|
|
"react/jsx-uses-react": "off",
|
|
"react/react-in-jsx-scope": "off",
|
|
"react/jsx-no-useless-fragment": "off",
|
|
"react/jsx-props-no-spreading": ["error", { "explicitSpread": "ignore" }],
|
|
|
|
"react-hooks/rules-of-hooks": "error",
|
|
"react-hooks/exhaustive-deps": "warn",
|
|
|
|
"typescript/no-redeclare": "error",
|
|
"typescript/ban-ts-comment": "error",
|
|
"typescript/consistent-type-imports": ["error", {
|
|
"prefer": "type-imports",
|
|
"fixStyle": "inline-type-imports"
|
|
}],
|
|
"typescript/explicit-function-return-type": "off",
|
|
"typescript/explicit-module-boundary-types": "off",
|
|
"typescript/no-empty-object-type": ["error", {
|
|
"allowInterfaces": "with-single-extends"
|
|
}],
|
|
"typescript/no-empty-function": "off",
|
|
"typescript/no-explicit-any": "off",
|
|
"typescript/no-unused-vars": ["warn", {
|
|
"vars": "all",
|
|
"varsIgnorePattern": "^_",
|
|
"args": "after-used",
|
|
"argsIgnorePattern": "^_"
|
|
}],
|
|
|
|
"typescript/strict-boolean-expressions": ["error", {
|
|
"allowNullableBoolean": true,
|
|
"allowNullableObject": true,
|
|
"allowString": true,
|
|
"allowNumber": true,
|
|
"allowNullableString": true,
|
|
"allowNullableNumber": true,
|
|
"allowNullableEnum": true,
|
|
"allowAny": true
|
|
}],
|
|
|
|
"twenty/effect-components": "error",
|
|
"twenty/no-hardcoded-colors": "error",
|
|
"twenty/matching-state-variable": "error",
|
|
"twenty/sort-css-properties-alphabetically": "error",
|
|
"twenty/styled-components-prefixed-with-styled": "error",
|
|
"twenty/no-state-useref": "error",
|
|
"twenty/component-props-naming": "error",
|
|
"twenty/no-navigate-prefer-link": "error",
|
|
"twenty/no-jotai-store-in-selector": "error",
|
|
"twenty/no-direct-atom-family-in-selector": "error",
|
|
"twenty/folder-structure": "error",
|
|
"twenty/enforce-module-boundaries": ["error", {
|
|
"depConstraints": [
|
|
{
|
|
"sourceTag": "scope:frontend",
|
|
"onlyDependOnLibsWithTags": ["scope:shared", "scope:frontend"]
|
|
}
|
|
]
|
|
}]
|
|
},
|
|
"overrides": [
|
|
{
|
|
"files": ["**/constants/*.ts", "**/*.constants.ts"],
|
|
"rules": {
|
|
"twenty/max-consts-per-file": ["error", { "max": 1 }]
|
|
}
|
|
}
|
|
]
|
|
}
|