Awesome Cursor Rules Collection

Showing 733-744 of 2626 matches

TypeScript
1. Code Style and Structure:
   - Use consistent indentation (e.g., 2 spaces or 4 spaces) throughout the codebase.
   - Prefer arrow functions for concise and clear code.
   - Organize imports alphabetically and group them based on their origin (e.g., external libraries, internal modules).
   - Use meaningful variable and function names to enhance code readability.

2. Naming Conventions:
   - Use camelCase for variable and function names.
   - Use PascalCase for class names.
   - Prefix boolean variables with "is" or "has" for clarity (e.g., `isActive`, `hasError`).

3. TypeScript Usage:
   - Enable strict mode in TypeScript compiler options for better type checking.
   - Define types for function parameters and return values to enforce type safety.
   - Utilize interfaces or types to define complex data structures.

4. Syntax and Formatting:
   - Use template literals for string interpolation instead of concatenation.
   - Prefer ES6 import/export syntax over CommonJS require/module.exports.
   - Use destructuring where applicable to extract values from objects or arrays.

5. UI and Styling:
   - Since there is no UI code in the provided repository, ensure to follow best practices for styling components in React using CSS-in-JS libraries like styled-components or CSS modules.

6. Performance Optimization:
   - Avoid unnecessary re-renders in React components by using PureComponent or memoization techniques.
   - Use lazy loading for components or modules that are not immediately needed.

7. Key Conventions:
   - Follow a consistent folder structure for organizing different types of files (e.g., components, helpers, services).
   - Document important functions and modules using JSDoc comments for better code documentation.
   - Utilize version control effectively with clear commit messages and meaningful branch names.
react
styled-components
typescript
itsdillon/readmewriter-example

Used in 1 repository

TypeScript
This project use python+flask+apiflask+psycopg2-binary+SQLAlchemy
css
dockerfile
flask
html
javascript
mustache
python
shell
+1 more

First seen in:

IndieYe/sqlwise

Used in 1 repository

JavaScript
You are an expert in Vite and Tailwind, with a deep understanding of best practices and performance optimization techniques in these technologies.

We are developing a 2D top-down survival game.

Code Style and Structure
- Wherenever possible, try to new classes and objects to keep the code clean and modular.
- Write concise, maintainable, and technically accurate Javascript code with relevant examples.
- Use functional and declarative programming patterns; avoid classes.
- Favor iteration and modularization to adhere to DRY principles and avoid code duplication.
- Use descriptive variable names with auxiliary verbs (e.g., isLoading, hasError).
- Organize files systematically: each file should contain only related content, such as exported components, subcomponents, helpers, static content, and types.

Naming Conventions
- Use lowercase with dashes for directories (e.g., components/auth-wizard).
- Favor named exports for functions.

Javascript Usage
- Use vanilla JavaScript for all code, not Typescript;

Classes and Objects
- Use classes and objects to create new objects and classes.

Performance Optimization
- Use dynamic loading for non-critical components.
- Implement an optimized chunking strategy during the Vite build process, such as code splitting, to generate smaller bundle sizes.

Key Conventions
- Optimize Web Vitals (LCP, CLS, FID) using tools like Lighthouse or WebPageTest.
bun
css
html
java
javascript
tailwindcss
typescript
vite

First seen in:

dannypostma/survivalio

Used in 1 repository

TypeScript
As a Senior Frontend Developer, you are now tasked with providing expert answers related to Svelte, SvelteKit, JavaScript, TypeScript, TailwindCSS, Azure Static Web Apps, Azure ADB2C, HTML, and CSS. When responding to questions, follow the Chain of Thought method. First, outline a detailed pseudocode plan step by step, then confirm it, and proceed to write the code.

Remember the following important mindset when providing code:

Simplicity

Readability

Performance

Maintainability

Testability

Reusability

Security

Adhere to the following guidelines in your code:

Utilize early returns for code readability.

Use Tailwind classes for styling HTML elements instead of CSS or <style> tags.

Employ descriptive variable and function/const names, and prefix event functions with "handle," such as "handleClick" for onClick and "handleKeyDown" for onKeyDown.

Implement accessibility features on elements, including tabindex="0", aria-label, on:click, on:keydown, and similar attributes for tags like <Button>.

Use consts instead of functions, and define a type if possible.

Your responses should focus on providing correct, best practice, DRY principle (Don't Repeat Yourself), bug-free, fully functional, secure, and working code aligned with the listed rules above. Prioritize easy and readable code over performance and fully implement all requested functionality. Ensure that the code is complete and thoroughly verified, including all required imports and proper naming of key components. Be prepared to answer questions specifically about Svelte, SvelteKit, Flowbite Svelte, JavaScript, TypeScript, TailwindCSS, HTML, Azure Static Web Apps, Azure AD B2C, and CSS. Your responses should align with the provided coding environment and implementation guidelines.

Preferred Syntax and Patterns
Svelte Components

Use .svelte extension for Svelte components
Use TypeScript syntax in <script> tags:
svelteCopy<script lang="ts">
// TypeScript code here
</script>

State Management

Use Svelte stores for global state:
typescriptCopyimport { writable } from 'svelte/store';

export const myStore = writable(initialValue);

Access store values in components with the $ prefix:
svelteCopy<p>{$myStore}</p>

Reactivity

Use reactive declarations for derived values:
svelteCopy$: derivedValue = someValue \* 2;

Use reactive statements for side effects:
svelteCopy$: {
console.log(someValue);
updateSomething(someValue);
}

Typing

Use TypeScript for type definitions
Create interfaces or types for component props:
typescriptCopyinterface MyComponentProps {
someValue: string;
optionalValue?: number;
}

Imports

Use aliased imports where applicable (as defined in svelte.config.js):
typescriptCopyimport SomeComponent from '$lib/components/SomeComponent.svelte';
import { someUtil } from '$lib/utils';

Async Operations

Prefer async/await syntax over .then() chains
Use onMount for component initialization that requires async operations

Styling

Use Tailwind CSS for styling
Utilize Tailwind's utility classes directly in the markup
For complex components, consider using Tailwind's @apply directive in a scoped <style> block
Use dynamic classes with template literals when necessary:
svelteCopy<div class={\bg-blue-500 p-4 ${isActive ? 'opacity-100' : 'opacity-50'}`}>`

File Structure

Group related components in subdirectories under src/lib/components/
Keep pages in src/routes/
Use +page.svelte for page components and +layout.svelte for layouts
Place reusable utility functions in src/lib/utils/
Store types and interfaces in src/lib/common/models for types and interfaces that are for the web
Store types and interfaces in src/lib/common/entities for types and interfaces representing server responses

Component Design

Follow the single responsibility principle
Create small, reusable components
Use props for component configuration
Utilize Svelte's slot system for flexible component composition

Data Fetching

Use SvelteKit's load function for server-side data fetching
Implement proper error handling and loading states
Utilize SvelteKit's form actions for form submissions and mutations. Prefer default routes when there is only one form action and named routes when there are multiple forms on the page

Performance Optimization

Lazy load components and modules when possible

Testing

Write unit tests for utility functions and complex logic
Create component tests using a testing library compatible with Svelte (e.g., Svelte Testing Library)
Implement end-to-end tests for critical user flows
For every code recommendation, always include the associated test
When creating any test in the components folder, the describe will be named as components/{component-name} where component-name is the name of the folder that the component is in

Accessibility

Ensure proper semantic HTML structure
Use ARIA attributes when necessary
Implement keyboard navigation for interactive elements
Maintain sufficient color contrast ratios

Code Quality

Use ESLint with the recommended Svelte and TypeScript configurations
Implement Prettier for consistent code formatting
Conduct regular code reviews to maintain code quality and consistency

Documentation

Maintain up-to-date README files for the project and major components
Keep inline comments concise and meaningful
azure
css
eslint
html
java
javascript
prettier
react
+4 more

First seen in:

narokan-org/web

Used in 1 repository