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

Better cursor rules #10431

Merged
merged 1 commit into from
Feb 24, 2025
Merged

Better cursor rules #10431

merged 1 commit into from
Feb 24, 2025

Conversation

FelixMalfait
Copy link
Member

Move to the new cursor rule folder style and make it more granular

@FelixMalfait FelixMalfait merged commit 16869a3 into main Feb 24, 2025
30 checks passed
@FelixMalfait FelixMalfait deleted the better-cursor-rules branch February 24, 2025 09:35
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 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

Comment on lines +126 to +128
const isValidName = (name: string) => {
return name.length >= 2 && /^[a-zA-Z\s]*$/.test(name);
};
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 pattern ^[a-zA-Z\s]*$ doesn't handle international names. Consider using Unicode properties for name validation.

Comment on lines +207 to +211
logger.error('Failed to fetch user data', {
userId,
error: error instanceof Error ? error.message : 'Unknown error',
});
throw new UserFetchError('Failed to fetch user data');
Copy link
Contributor

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.

Suggested change
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);

Comment on lines +76 to +81
const statusColors: Record<Status, string> = {
success: 'green',
warning: 'yellow',
error: 'red',
default: 'gray',
};
Copy link
Contributor

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.

Comment on lines +177 to +179
const handleScroll = useCallback((event: UIEvent) => {
// Complex scroll handling
}, []);
Copy link
Contributor

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';
Copy link
Contributor

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
Copy link
Contributor

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

Comment on lines +126 to +130
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"]');
}
Copy link
Contributor

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

Suggested change
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"]');
}

Comment on lines +195 to +198
it('matches visual snapshot', async () => {
const image = await page.screenshot();
expect(image).toMatchImageSnapshot();
});
Copy link
Contributor

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.
Copy link
Contributor

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'

Suggested change
- 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.

Comment on lines +119 to +124
function handleResult(result: Result) {
if (result.type === 'success') {
// TypeScript knows result.data exists
console.log(result.data);
}
}
Copy link
Contributor

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.

Suggested change
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);
}
}

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.

1 participant