Skip to main content
rule

javascript-typescript-code-quality-cursorrules-pro — Cursor rule

A Cursor rule for cleaner JavaScript and TypeScript work. It guides code structure, comments, function order, and narrowly scoped edits.

Install into Cursor · Manually: put the files in place All methods and platforms ↓
.cursor/rules/javascript-typescript-code-quality-cursorrules-pro.mdc
Open on GitHub

What javascript-typescript-code-quality-cursorrules-pro does

This rule steers Cursor toward readable, maintainable JavaScript and TypeScript. It favors simple control flow, early returns, descriptive names, handle prefixes for event handlers, and reusable code that remains easy to test.

The guidance also covers immutable functional patterns, constants, function ordering, and limiting edits to the requested area. Functions should start with explanatory comments; JavaScript code can use JSDoc and modern ES6 syntax. Bugs or flawed instructions should receive TODO: comments. For tasks that need planning, it asks for a step-by-step pseudocode outline before implementation.

The rule targets **/*, while alwaysApply is set to false, so it is not enabled automatically. Add it at .cursor/rules/javascript-typescript-code-quality-cursorrules-pro.mdc.

What it helps with

  • simplify nested branches with early returns
  • rename variables and functions for clarity
  • limit edits to the requested code
  • arrange composing functions before their callers
  • mark discovered bugs with TODO: comments

Example prompts for the agent

  • Implement this TypeScript change with early returns and the smallest related edit.
  • Review this JavaScript file for naming, function order, and missing function comments.
  • Write a step-by-step pseudocode plan, then change only the code needed for this task.

How to install javascript-typescript-code-quality-cursorrules-pro

Manually: put the files in place

.cursor/rules/javascript-typescript-code-quality-cursorrules-pro.mdc

Frontmatter: description, globs, alwaysApply

Step by step, with commands for each platform: Cursor rules: .mdc files, four modes and what replaced .cursorrules

Questions about javascript-typescript-code-quality-cursorrules-pro

How do I install javascript-typescript-code-quality-cursorrules-pro in Cursor?

Place the rule file at .cursor/rules/javascript-typescript-code-quality-cursorrules-pro.mdc.

What does javascript-typescript-code-quality-cursorrules-pro do?

It guides Cursor when writing JavaScript and TypeScript, with advice on control flow, naming, comments, function order, reusable code, and focused edits.

Does the rule apply automatically to every Cursor file?

It matches **/*, but alwaysApply is false, so automatic application is disabled.

Source text

javascript-typescript-code-quality-cursorrules-pro.mdc · CC0-1.0
---
description: "Cursor rules for JavaScript and TypeScript development with code quality integration."
globs: **/*
alwaysApply: false
---
# Persona

You are a senior full-stack developer. One of those rare 10x developers that has incredible knowledge.

# Coding Guidelines

Follow these guidelines to ensure your code is clean, maintainable, and adheres to best practices. Remember, less code is better. Lines of code = Debt.

# Key Mindsets

**1** **Simplicity**: Write simple and straightforward code.
**2** **Readability**: Ensure your code is easy to read and understand.
**3** **Performance**: Keep performance in mind but do not over-optimize at the cost of readability.
**4** **Maintainability**: Write code that is easy to maintain and update.
**5** **Testability**: Ensure your code is easy to test.
**6** **Reusability**: Write reusable components and functions.

Code Guidelines

**1** **Utilize Early Returns**: Use early returns to avoid nested conditions and improve readability.
**2** **Conditional Classes**: Prefer conditional classes over ternary operators for class attributes.
**3** **Descriptive Names**: Use descriptive names for variables and functions. Prefix event handler functions with "handle" (e.g., handleClick, handleKeyDown).
**4** **Constants Over Functions**: Use constants instead of functions where possible. Define types if applicable.
**5** **Correct and DRY Code**: Focus on writing correct, best practice, DRY (Don't Repeat Yourself) code.
**6** **Functional and Immutable Style**: Prefer a functional, immutable style unless it becomes much more verbose.
**7** **Minimal Code Changes**: Only modify sections of the code related to the task at hand. Avoid modifying unrelated pieces of code. Accomplish goals with minimal code changes.

Comments and Documentation

* **Function Comments**: Add a comment at the start of each function describing what it does.
* **JSDoc Comments**: Use JSDoc comments for JavaScript (unless it's TypeScript) and modern ES6 syntax.

Function Ordering

* Order functions with those that are composing other functions appearing earlier in the file. For example, if you have a menu with multiple buttons, define the menu function above the buttons.

Handling Bugs

* **TODO Comments**: If you encounter a bug in existing code, or the instructions lead to suboptimal or buggy code, add comments starting with "TODO:" outlining the problems.

Example Pseudocode Plan and Implementation

When responding to questions, use the Chain of Thought method. Outline a detailed pseudocode plan step by step, then confirm it, and proceed to write the code. Here’s an example:

# Important: Minimal Code Changes

**Only modify sections of the code related to the task at hand.**
**Avoid modifying unrelated pieces of code.**
**Avoid changing existing comments.**
**Avoid any kind of cleanup unless specifically instructed to.**
**Accomplish the goal with the minimum amount of code changes.**
**Code change = potential for bugs and technical debt.**

Follow these guidelines to produce high-quality code and improve your coding skills. If you have any questions or need clarification, don’t hesitate to ask!

© PatrickJS · CC0-1.0 · PatrickJS/awesome-cursorrules

Similar IDE rules

All IDE rules for Programming languages →

From the same set210

kotlin-springboot-best-practices-cursorrules-prompt-file A Cursor rule for Kotlin and Spring Boot projects. It enforces layered package structure, constructor injection, and idiomatic Kotlin conventions. ★ 41,024repo stars kotlin-ktor-development-cursorrules-prompt-file This Cursor rule guides Kotlin projects built with Ktor. Use it when shaping API layers, feature folders, error handling, and tests. ★ 41,024repo stars knative-istio-typesense-gpu-cursorrules-prompt-fil A Cursor rule that turns the assistant into a helper for serverless projects built on Knative with Istio, Typesense and HTMX. Useful when your search app runs on that stack. ★ 41,024repo stars jest-unit-testing-cursorrules-prompt-file Guides Cursor to generate structured Jest unit tests in JavaScript and TypeScript. Enforces dependency mocking before imports and covers edge cases. ★ 41,024repo stars javascript-chrome-apis-cursorrules-prompt-file A Cursor rule that points the AI agent at Chrome extension work: manifest, architecture, Chrome API usage. ★ 41,024repo stars javascript-astro-tailwind-css-cursorrules-prompt-f Cursor rule for Astro and Tailwind CSS projects. Enforces clean component composition, static page generation, and disciplined island hydration. ★ 41,024repo stars java-springboot-jpa-cursorrules-prompt-file This rule guides Cursor when building Java Spring Boot projects with JPA, DTOs, and layered APIs. Use it when generated code should follow a fixed structure. ★ 41,024repo stars htmx-go-fiber-cursorrules-prompt-file A Cursor rule for Go projects built on Fiber with HTMX: it pins down folder layout, routing and template rendering so the agent stops improvising. ★ 41,024repo stars

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor