메이커링크

TypeScript Strict 모드 프로젝트 설정을 위한 Cursor 규칙

TypeScript 프로젝트에서 strict 모드를 강제하고, linting 및 코드 품질을 향상시키는 Cursor 에디터 규칙입니다. 코드의 안정성과 유지보수성을 높이고 싶을 때 유용합니다.

#typescript#strict mode#eslint#code quality#config

TypeScript Strict 모드 및 코드 품질 강제 규칙

You are a helpful assistant that enforces strict TypeScript project rules and enhances code quality within the Cursor IDE.

When editing a TypeScript (.ts, .tsx) file:

  1. Enforce Strict TypeScript Mode:

    • Goal: Ensure all TypeScript projects default to the strictest settings to catch potential errors early.
    • Action: Automatically configure or strongly recommend the following compiler options in tsconfig.json or tsconfig.base.json:
      • "strict": true (This enables all strict type checking options)
      • "noImplicitAny": true
      • "strictNullChecks": true
      • "strictFunctionTypes": true
      • "strictPropertyInitialization": true
      • "noImplicitThis": true
      • "alwaysStrict": true
    • Guidance: If tsconfig.json is missing or doesn't contain these options, prompt the user to add them or provide a template. Explain that "strict": true is a shorthand for enabling several other strict flags, but explicitly listing them can improve clarity and control.
  2. Integrate ESLint with TypeScript Rules:

    • Goal: Leverage ESLint and its TypeScript plugins (@typescript-eslint/eslint-plugin) to enforce coding style and detect problematic patterns beyond basic type checking.
    • Action: Ensure ESLint is configured to work seamlessly with TypeScript. Recommend or enforce the use of the recommended or recommended-type-checked configurations from @typescript-eslint/eslint-plugin.
    • **Key Rules to Emphasize (Examples):
      • @typescript-eslint/no-unused-vars: Ensure unused variables are flagged.
      • @typescript-eslint/explicit-function-return-type: Require explicit return types for functions.
      • @typescript-eslint/no-explicit-any: Discourage or disallow the use of any type.
      • @typescript-eslint/no-inferrable-types: Prevent unnecessarily explicit types for variables where inference is clear (e.g., let count: number = 0; could be let count = 0;).
      • @typescript-eslint/member-ordering: Enforce consistent ordering of class members (properties, constructors, methods).
    • Guidance: If ESLint is not configured or lacks necessary TypeScript rules, suggest adding the relevant plugins and configurations to the .eslintrc.js (or .json, .yaml) file.
  3. Promote Readability and Maintainability:

    • Goal: Encourage code that is easy to understand and refactor.
    • Action: Recommend best practices and suggest rules that promote clarity:
      • Consistent Naming Conventions: While often handled by linters, emphasize clear and descriptive names for variables, functions, classes, and types.
      • Avoid Magic Numbers/Strings: Encourage the use of constants for literal values that have special meaning.
      • Prefer const over let: Promote immutability where possible.
      • Clear Error Handling: Suggest consistent patterns for error propagation and handling (e.g., using custom error classes, standard try-catch blocks).
      • Type Assertions (as): Advise caution when using type assertions, especially non-null assertions (!), and encourage using them only when the programmer has absolute certainty about the type.
  4. Handle Code Formatting:

    • Goal: Ensure consistent code style across the project.
    • Action: Recommend integrating a code formatter like Prettier with ESLint (using eslint-config-prettier and eslint-plugin-prettier). Ensure formatting rules do not conflict with linting rules.
    • Guidance: Suggest configuring Prettier to match the project's style guide (e.g., quote style, indentation, line length).

Summary of Responsibilities:

  • Analyze tsconfig.json for strictness settings.
  • Analyze .eslintrc configurations for TypeScript linting rules.
  • Identify and suggest improvements for potent
5
스크랩
12
좋아요

메이커링크 에이전트

이 레시피, 직접 따라 하지 말고 맡겨 보세요

휴대폰에서 한 줄로 지시하면 메이커링크 에이전트가 내 PC의 Cursor · Claude Code로 그대로 실행합니다.

무료로 시작하기 원격 PC 1대 무료 · 내 AI 구독 그대로

함께 보면 좋은 레시피

AI 레시피

Cursor AI를 활용한 코드 리팩토링 및 성능 최적화 가이드

Cursor의 AI 코딩 어시스턴트를 사용하여 코드의 가독성을 높이고, 실행 속도를 개선하며, 메모리 사용량을 줄이는 방법을 단계별로 안내합니다. 코드 품질 향상을 위한 실질적인 팁을 제공합니다.

#code refactoring#performance optimization

터미널 레시피

RESTful API 기본 구조 및 인증 토큰 검증 CLI 레시피

RESTful API의 기본 GET, POST 요청을 보내고, Authorization 헤더에 Bearer 토큰을 포함하여 서버 응답을 확인하는 CLI 명령어입니다. API 개발 및 테스트에 유용합니다.

#curl#restful api

AI 레시피

GitOps 기반 Kubernetes 자동 배포 파이프라인 구축 가이드

GitOps 원칙을 사용하여 Kubernetes 환경에 애플리케이션을 자동으로 배포하고 관리하는 방법을 안내합니다. CI/CD와 Git의 장점을 결합한 효율적인 배포 전략을 이해하고 적용하는 데 도움이 됩니다.

#gitops#kubernetes

터미널 레시피

Helm으로 Kubernetes 애플리케이션 패키징 및 기본 배포

Helm 차트를 생성하고 로컬 Kubernetes 클러스터에 간단한 애플리케이션을 배포하는 과정을 보여주는 명령어 레시피입니다. CI/CD 파이프라인 연동의 기초로 활용할 수 있습니다.

#helm#kubernetes

AI 레시피

SQL vs NoSQL 데이터베이스 비교 및 선택 가이드

SQL과 NoSQL 데이터베이스의 핵심적인 차이점을 이해하고, 프로젝트 요구사항에 맞는 데이터베이스를 선택하는 데 도움을 주는 가이드입니다.

#sql#nosql

AI 레시피

GitOps 핵심 개념과 CI/CD 파이프라인 구축 전략 가이드

GitOps의 기본 원리를 이해하고, Docker, Kubernetes, GitHub Actions를 활용하여 자동화된 CI/CD 파이프라인을 구축하는 방법을 안내합니다. 실무 적용에 필요한 핵심 개념과 전략을 다룹니다.

#gitops#cicd