-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Better cursor rules #10431
Better cursor rules #10431
Conversation
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.
PR Summary
This PR reorganizes the development guidelines by splitting the monolithic .cursorrules file into granular, topic-specific documentation under the .cursor/rules directory.
- Added comprehensive
README.md
in.cursor/rules
serving as a central index for all development guidelines and commands - Created detailed
architecture.md
documenting Twenty's monorepo structure, tech stack, and infrastructure components - Added focused state management guidelines in
react-state-management-guidelines.md
covering Recoil and Apollo Client best practices - Introduced clear code style rules in
code-style-guidelines.md
for control flow, error handling, and organization - Removed the monolithic
.cursorrules
file in favor of this more maintainable structure
10 file(s) reviewed, 10 comment(s)
Edit PR Review Bot Settings | Greptile
const isValidName = (name: string) => { | ||
return name.length >= 2 && /^[a-zA-Z\s]*$/.test(name); | ||
}; |
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: The regex pattern ^[a-zA-Z\s]*$
doesn't handle international names. Consider using Unicode properties for name validation.
logger.error('Failed to fetch user data', { | ||
userId, | ||
error: error instanceof Error ? error.message : 'Unknown error', | ||
}); | ||
throw new UserFetchError('Failed to fetch user data'); |
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: Error message is duplicated in logger.error and UserFetchError. Consider using a single error message source.
logger.error('Failed to fetch user data', { | |
userId, | |
error: error instanceof Error ? error.message : 'Unknown error', | |
}); | |
throw new UserFetchError('Failed to fetch user data'); | |
const errorMessage = 'Failed to fetch user data'; | |
logger.error(errorMessage, { | |
userId, | |
error: error instanceof Error ? error.message : 'Unknown error', | |
}); | |
throw new UserFetchError(errorMessage); |
const statusColors: Record<Status, string> = { | ||
success: 'green', | ||
warning: 'yellow', | ||
error: 'red', | ||
default: 'gray', | ||
}; |
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.
logic: The lookup object example is missing type safety for the default case if Status is a union type.
const handleScroll = useCallback((event: UIEvent) => { | ||
// Complex scroll handling | ||
}, []); |
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.
logic: empty dependency array with event parameter usage could cause stale closure issues
|
||
// Local imports | ||
import { UserAvatar } from './UserAvatar'; | ||
import { type UserProfileProps } from './types'; |
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: type import should be before component import to maintain consistent ordering (types before components)
|
||
### Test File Location | ||
- Place test files next to implementation | ||
- Use `.test.ts` or `.spec.ts` extension |
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.
logic: inconsistent file extension guidance - earlier examples use .tsx for React components but here suggests .ts for test files
async login(email: string, password: string) { | ||
await this.page.fill('[data-testid="email-input"]', email); | ||
await this.page.fill('[data-testid="password-input"]', password); | ||
await this.page.click('[data-testid="login-button"]'); | ||
} |
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.
logic: LoginPage class is missing page initialization in constructor
async login(email: string, password: string) { | |
await this.page.fill('[data-testid="email-input"]', email); | |
await this.page.fill('[data-testid="password-input"]', password); | |
await this.page.click('[data-testid="login-button"]'); | |
} | |
constructor(private page: Page) {} | |
async login(email: string, password: string) { | |
await this.page.fill('[data-testid="email-input"]', email); | |
await this.page.fill('[data-testid="password-input"]', password); | |
await this.page.click('[data-testid="login-button"]'); | |
} |
it('matches visual snapshot', async () => { | ||
const image = await page.screenshot(); | ||
expect(image).toMatchImageSnapshot(); | ||
}); |
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: Visual snapshot test missing viewport size configuration which could lead to inconsistent results
``` | ||
|
||
#### Provide Context | ||
- Lingui provides powerfulway to add context for translators but we don't use them as of today. |
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.
syntax: 'powerfulway' should be 'powerful way'
- Lingui provides powerfulway to add context for translators but we don't use them as of today. | |
- Lingui provides powerful way to add context for translators but we don't use them as of today. |
function handleResult(result: Result) { | ||
if (result.type === 'success') { | ||
// TypeScript knows result.data exists | ||
console.log(result.data); | ||
} | ||
} |
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: Type guard example should handle both success and error cases to demonstrate proper exhaustive checking.
function handleResult(result: Result) { | |
if (result.type === 'success') { | |
// TypeScript knows result.data exists | |
console.log(result.data); | |
} | |
} | |
function handleResult(result: Result) { | |
if (result.type === 'success') { | |
// TypeScript knows result.data exists | |
console.log(result.data); | |
} else { | |
// TypeScript knows this is the error case | |
console.error(result.message); | |
} | |
} |
Move to the new cursor rule folder style and make it more granular