Cursor rule
.cursor/rules/typescript-coding-guidelines.mdcTypeScript coding guidelines / style – check when working on TypeScript files
Cursor rules
Quality
65/100
Scores the file, not the repository.Length
570 words
8 headings · 2 code blocksRepository
1.6k
— · pushed 0 days agoLast changed
3 days ago
First indexed 3 days ago.123456# General78- Prefer 'const myFunc = () => {}' over function declarations.9- Parallelize async calls where appropriate via `Promise.all` instead of sequential fetches in a `for` loop.10- No `any` allowed. If the input type is genuinely unknown, use `unknown` and write appropriate logic to narrow the type.11- Prefer `??` over `||`12- No unchecked index access (`array[0]` might be `undefined`). Optional chain or check and throw and error (depending on whether it is acceptable for the result to be undefined or not).13- Don't make formatting corrections to lines you aren't already modifying. Auto-fixing will handle it.14- Avoid single-letter variable names. e.g. `event`, not `e`. Exception: in `for` loops (e.g. `i` is fine).15- Variable names are all in `camelCase`. No `SCREAMING_SNAKE_CASE`.16- Check function and type signatures carefully to understand APIs and what fields are available.17 For external libraries, these should be available in a type declaration file.18 Don't guess APIs! Check the signatures.1920# Avoid these!2122- Don't make changes unrelated to the user's requests. You can suggest further changes at the end of your work.23- Don't get stuck fixing linting errors – stop and ask for help sooner.24- Don't attempt to run the app. Let the user handle testing.2526# Workspaces2728- The project uses yarn workspaces.29- If you want to install a dependency, you need to do it in the relevant workspace. e.g. `apps/hash-frontend`.30- The project3132# Frontend3334- Use React function components35- Use MUI components for all HTML elements (import from `@mui/material`)36 - Style using the `sx` prop37 - Flex boxes should use the `Stack` component38- Use ApolloClient hooks for fetching from the API (e.g. `useQuery`)3940# Entities4142- An `Entity` is a key primitive in the system. They have types which describe their properties. Each entity can have multiple types.4344## Types4546- A `ClosedMultiEntityType` is the combined schema of the entity types an entity has.47- When requesting entities from the GraphQL API, via `getEntitySubgraphQuery`, a map of `ClosedMultiEntityType`s is available on48 `closedMultiEntityTypes` in the return field (so long as `includeEntityTypes: "resolved"` has been passed in the `variables.request` object)49- To retrieve a specific `ClosedMultiEntityType` from the map, use `getClosedMultiEntityTypeFromMap` imported from `@local/hash-graph-sdk/entity`50- The property and data types for a given `ClosedMultiEntityType` are available in the `definitions` field returned from the API.51- Labels for entities (human-readable display strings) can be generated by calling `generateEntityLabel(closedMultiEntityType, entity)`52- If a `ClosedMultiEntityType` is needed for an arbitrary set of `entityTypeIds`, e.g. for draft/proposed entities, use `getClosedMultiEntityTypesQuery`.53 It also returns a `closedMultiEntityTypes` and `definitions` fields.54 This should be an array of arrays, where each entry in the array is a set of entityTypeIds you require a closed type for.55- To get the `icon` for an entity if required, call `getDisplayFieldsForClosedEntityType(closedMultiEntityType)`.5657## Linked entities5859- A 'subgraph' will contain details of entities and entities linked to it.6061# File organization6263- When exports from a module are only used in one other file, they should be created in a subfolder named after the importing file.64 e.g.6566```md67- page.tsx68- page/header.tsx69- page/header/header-button.tsx70- page/sidebar.tsx71```7273- If a module is used by multiple other files, it should be in a `shared` folder at the highest point at which it is needed in the file tree. e.g.7475```md76- page.tsx77- api.tsx78- shared/types.ts // types is used by both page and api79```80
Also in hashintel/hash
Diff this repo’s formatsOne repository carrying more than one format is the comparison this product exists for: does anyone actually write different content in each file, or is one a copy of the other?
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| hashintel/hash.cursor/rules/ai-assistant-guidelines.mdc · 1.6k | Cursor rules | do-not | 51/100 | 3 days ago | |
| hashintel/hash.cursor/rules/rust-documentation.mdc · 1.6k | Cursor rules | docs | 33/100 | 3 days ago | |
| hashintel/hash.cursor/rules/git-commit-conventions.mdc · 1.6k | Cursor rules | lint-formatstylegitdo-not | 51/100 | 3 days ago | |
| hashintel/hash.cursor/rules/meaningful-identifiers.mdc · 1.6k | Cursor rules | do-not | 32/100 | 3 days ago | |
| hashintel/hash.cursor/rules/rust-coding-style.mdc · 1.6k | Cursor rules | lint-formatstyletypesdependencies+2 | 69/100 | 3 days ago | |
| hashintel/hash.cursor/rules/rust-error-handling.mdc · 1.6k | Cursor rules | no sections | 31/100 | 3 days ago | |
| hashintel/hash.cursor/rules/rust-testing-strategy.mdc · 1.6k | Cursor rules | testlint-formatstyletesting-strategy | 81/100 | 3 days ago | |
| hashintel/hash.cursor/rules/rust-tracing-practices.mdc · 1.6k | Cursor rules | no sections | 45/100 | 3 days ago | |
| hashintel/hash.cursor/rules/update-rules.mdc · 1.6k | Cursor rules | no sections | 4/100 | 3 days ago | |
| hashintel/hash.github/instructions/code-review.instructions.md · 1.6k | Copilot instructions | lint-formatstylegitdo-not+1 | 78/100 | 3 days ago | |
| hashintel/hash.github/instructions/rust-review.instructions.md · 1.6k | Copilot instructions | lint-formatstylegitdo-not | 73/100 | 3 days ago | |
| hashintel/hash.github/instructions/typescript-review.instructions.md · 1.6k | Copilot instructions | testlint-formatstyletypes+2 | 66/100 | 3 days ago | |
| hashintel/hashAGENTS.md · 1.6k | AGENTS.md | testlint-formatarchtypes+4 | 93/100 | 3 days ago | |
| hashintel/hashlibs/@hashintel/ds-components/AGENTS.md · 1.6k | AGENTS.md | buildtestlint-formatstyle+5 | 97/100 | 3 days ago | |
| hashintel/hashlibs/@hashintel/ds-helpers/AGENTS.md · 1.6k | AGENTS.md | archdependenciesagent-behaviour | 62/100 | 3 days ago | |
| hashintel/hashlibs/@hashintel/petrinaut/AGENTS.md · 1.6k | AGENTS.md | buildtestlint-formatstyle | 80/100 | 3 days ago |
Diff against .cursor/rules/ai-assistant-guidelines.mdc Diff against .cursor/rules/rust-documentation.mdc Diff against .cursor/rules/git-commit-conventions.mdc Diff against .cursor/rules/meaningful-identifiers.mdc Diff against .cursor/rules/rust-coding-style.mdc Diff against .cursor/rules/rust-error-handling.mdc Diff against .cursor/rules/rust-testing-strategy.mdc Diff against .cursor/rules/rust-tracing-practices.mdc Diff against .cursor/rules/update-rules.mdc Diff against .github/instructions/code-review.instructions.md Diff against .github/instructions/rust-review.instructions.md Diff against .github/instructions/typescript-review.instructions.md Diff against AGENTS.md Diff against libs/@hashintel/ds-components/AGENTS.md Diff against libs/@hashintel/ds-helpers/AGENTS.md Diff against libs/@hashintel/petrinaut/AGENTS.md
Similar configs
Same format, overlapping stack, ranked by quality.
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| hiromaily/go-crypto-wallet.cursor/rules/typescript.mdc · 126 | Cursor rules | setupbuildtestlint-format+6 | 100/100 | 3 days ago | |
| TechSquidTV/Hermes.cursor/rules/10-hermes-api.mdc · 45 | Cursor rules | testlint-formatstylearch+5 | 100/100 | 3 days ago | |
| markstev/mark-starter.cursor/rules/frontend.mdc · 0 | Cursor rules | setuptestlint-formatstyle+6 | 99/100 | 3 days ago | |
| Allymahmoud/case-intake-platform.cursor/rules/frontend.mdc · 0 | Cursor rules | setuptestlint-formatstyle+7 | 99/100 | 3 days ago | |
| dodgecfr/combatfilms-webapp.cursor/rules/frontend.mdc · 0 | Cursor rules | setuptestlint-formatstyle+7 | 99/100 | 3 days ago | |
| deifos/clipmira-subtitles.cursor/rules/frontend.mdc · 1 | Cursor rules | setuptestlint-formatstyle+7 | 99/100 | 3 days ago | |
| langflow-ai/langflow.cursor/rules/docs_development.mdc · 153k | Cursor rules | setupbuildtestlint-format+7 | 97/100 | 3 days ago | |
| TechSquidTV/Hermes.cursor/rules/20-hermes-api-tests.mdc · 45 | Cursor rules | teststyletesting-strategysecurity+3 | 97/100 | 3 days ago |
