Token导航 LogoToken导航TokenDH.com
研究检索需要联网github未标认证来源可访问clear审计通过

enforcing-typescript-standardsenforcing TypeScript standards 搜索

Agent Skill

enforcing-typescript-standards 用于查找、检索和筛选相关信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要根据关键词、任务场景或来源线索快速定位候选结果时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

3,693

周安装

157

GitHub Stars

1

下载量

1,294
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

3

许可证

MIT

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:enforcing-typescript-standards(enforcing TypeScript standards 搜索)
来源仓库:https://github.com/jgeurts/eslint-config-decent
仓库路径:skills/enforcing-typescript-standards
安装命令:
npx skills add https://github.com/jgeurts/eslint-config-decent --skill enforcing-typescript-standards
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。不同来源提供的安装方式可能略有差异;本站展示可直接复制的安装命令,安装前请核对来源页面。

skills.shnpx skills
npx skills add https://github.com/jgeurts/eslint-config-decent --skill enforcing-typescript-standards

简介

强制 TypeScript 标准用于统一项目的显式类型、导入顺序和代码安全规则。

  • 适用于需要高质量 TypeScript 代码的团队和项目维护场景。
  • 可自动触发对新建和修改的 .ts/.tsx 文件进行规范检查。
  • 使用时需确认项目是否已配置 ESLint 和 TypeScript 插件。
  • 建议在代码提交前运行,避免破坏现有代码结构和类型定义。

SKILL.md

Enforcing TypeScript Standards

Enforces the project's core TypeScript standards including explicit typing, import organization, class member ordering, and code safety rules.

Triggers

Activate this skill when the user says or implies any of these:

  • "write", "create", "implement", "add", "build" (new TypeScript code)
  • "fix", "update", "change", "modify", "refactor" (existing TypeScript code)
  • "review", "check", "improve", "clean up" (code quality)
  • Any request involving .ts or .tsx files

Specific triggers:

  • Creating a new .ts or .tsx file
  • Modifying existing TypeScript code
  • Reviewing TypeScript code for compliance

Core Standards

Type Safety

  • Explicit return types: Prefer explicit return types when practical; omit when inference is obvious and adds no clarity
  • Explicit member accessibility: Class members require public, private, or protected
  • Type-only imports: Use import type for types: import type {Foo} from './foo.js'
  • Sorted type constituents: Union/intersection types must be alphabetically sorted
  • Only throw Error objects: Never throw strings or other primitives
  • Avoid any and type assertions: Prefer proper typing over any or as casts; use them only when truly necessary
  • Type JSON fields explicitly: Use Record<string, unknown> or specific interfaces for JSON data, never any
  • Use Number() for conversion: Prefer Number(value) over parseInt(value, 10) or parseFloat(value)
  • Reuse existing types: Before defining a new interface, search for existing types that can be reused directly, extended, or derived using Pick, Omit, Partial, or other utility types

Alternatives to Type Assertions

Before using as, try these approaches in order:

  1. Proper typing at the source
  2. Type guards (typeof, instanceof)
  3. Type narrowing through control flow
  4. Custom type predicate functions
  5. Discriminated unions
// Bad
const user = data as User;

// Good
function isUser(data: unknown): data is User {
  return typeof data === 'object' && data !== null && 'id' in data;
}
if (isUser(data)) {
  // data is now typed as User
}

Import Organization

  • Import order: builtin → external → internal → parent → sibling → index (alphabetized within groups)
  • No duplicate imports: Consolidate imports from the same module
  • Newline after imports: Blank line required after import block

Class Member Ordering

  1. Signatures (call/construct)
  2. Fields: private → public → protected
  3. Constructors: public → protected → private
  4. Methods: public → protected → private

Code Style

  • Simplicity over cleverness: Straightforward, readable code is better than clever one-liners
  • Early returns: Use guard clauses to reduce nesting; return early for edge cases
  • Nullish coalescing: Prefer ?? over || for defaults (avoids false positives on 0 or '')
  • Optional chaining: Use ?. for safe property access
  • Match existing patterns: Follow conventions already established in the codebase
  • Meaningful identifiers: Names must be descriptive (exceptions: _, i, j, k, e, x, y)
  • Function declarations: Use function foo() not const foo = function()
  • Prefer const: Use const unless reassignment is needed
  • No var: Always use const or let
  • Object shorthand: Use {foo} not {foo: foo}
  • Template literals: Use ` Hello ${name} not 'Hello ' + name`
  • Strict equality: Use === except for null comparisons
  • One class per file: Maximum one class definition per file
  • Avoid reduce: Prefer for...of loops or other array methods for clarity
  • Functions over classes: Prefer exported functions over classes with static methods (unless state is needed)
  • No nested functions: Define helper functions at module level, not inside other functions
  • Immutability: Create new objects/arrays instead of mutating existing ones

Naming Conventions

  • Enum members: Use PascalCase (e.g., MyValue)
  • No trailing underscores: Identifiers cannot end with _

Comments

  • No redundant comments: Never comment what the code already expresses clearly
  • No duplicate comments: Don't repeat information from function names, types, or nearby comments
  • Meaningful only: Only add comments to explain *why*, not *what* — the code shows what it does

Boolean Expressions

  • Prefer truthiness checks: Use implicit truthy/falsy checks over explicit comparisons
  • Exception: Use explicit checks when distinguishing 0/'' (valid values) from null/undefined is semantically important

Testing

  • Minimize mocking: Avoid mocking everything; use real implementations and data generators when available
  • Test real behavior: Testing mocks provides little value — test actual code paths
  • Don't be lazy: Write thorough tests that cover edge cases, not just happy paths

Error Handling

  • Specific error types: Prefer specific error types over generic Error when meaningful
  • Avoid silent failures: Don't swallow errors with empty catch blocks
  • Handle rejections: Always handle promise rejections
  • Let errors propagate: Don't catch errors just to re-throw or log — let them bubble up to error handlers

Negative Knowledge

Avoid these anti-patterns:

  • console.log() statements in production code
  • eval() or Function() constructor
  • Nested ternary operators
  • await inside loops when Promise.all would be simpler (sequential awaits are fine when order matters or parallelism adds complexity)
  • Empty interfaces
  • Variable shadowing
  • Functions defined inside loops
  • @ts-ignore without explanation (use @ts-expect-error with 10+ char description)
  • Comments that restate the code: // increment counter above counter++
  • Comments that duplicate type information: // returns a string when return type is : string
  • Commented-out code (delete it; use version control)
  • Verbose boolean comparisons: arr.length > 0, str!== '', obj!== null && obj!== undefined
  • Disabling lint rules via comments (fix the code instead)
  • Overuse of any type or as type assertions
  • Over-mocking in tests instead of using real implementations or data generators
  • Empty catch blocks that silently swallow errors
  • Using || for defaults when ?? is more appropriate
  • Deep nesting when early returns would simplify
  • Catching errors just to re-throw or log them
  • Nested function definitions inside other functions
  • Mutating objects/arrays instead of creating new ones
  • TOCTOU: Checking file/resource existence before operating (try and handle errors instead)
  • Classes with only static methods (use plain functions instead)
  • Duplicating existing interfaces instead of reusing or deriving with Pick/Omit/Partial

Verification Workflow

  1. Analyze: Compare the code change against these TypeScript standards
  2. Generate/Refactor: Write or modify code to comply with all rules above
  3. Simplify: Review for opportunities to simplify — prefer clear, straightforward code over clever solutions
  4. Review naming: Verify variable and function names still make sense in context after changes
  5. Build: Verify types compile without errors (e.g., npm run build or npx tsc --noEmit)
  6. Lint: Run npm run lint to confirm compliance before completing the task

Examples

Comments Examples

// Standard
// Retry with exponential backoff to handle transient network failures
async function fetchWithRetry(url: string, attempts = 3): Promise<Response> {
  for (let i = 0; i < attempts; i++) {
    try {
      return await fetch(url);
    } catch {
      await sleep(2 ** i * 100);
    }
  }
  throw new Error(`Failed after ${attempts} attempts`);
}

// Non-Standard
/**
 * Fetches data from a URL with retry logic
 * @param url - The URL to fetch from
 * @param attempts - Number of attempts (default 3)
 * @returns A Promise that resolves to a Response
 */
async function fetchWithRetry(url: string, attempts = 3): Promise<Response> {
  // Loop through attempts
  for (let i = 0; i < attempts; i++) {
    try {
      // Try to fetch the URL
      return await fetch(url);
    } catch {
      // Wait before retrying
      await sleep(2 ** i * 100);
    }
  }
  // Throw error if all attempts fail
  throw new Error(`Failed after ${attempts} attempts`);
}

Boolean Expressions Examples

// Standard
if (myArray.length) {
}
if (myString) {
}
if (myObject) {
}
if (!value) {
}

// Non-Standard
if (myArray.length !== 0) {
}
if (myArray.length > 0) {
}
if (myString !== '') {
}
if (myObject !== null && myObject !== undefined) {
}
if (value === null || value === undefined) {
}

Early Return Examples

// Standard
function processUser(user: User | null): Result {
  if (!user) {
    return { error: 'No user provided' };
  }
  if (!user.isActive) {
    return { error: 'User is inactive' };
  }
  return { data: transform(user) };
}

// Non-Standard
function processUser(user: User | null): Result {
  if (user) {
    if (user.isActive) {
      return { data: transform(user) };
    } else {
      return { error: 'User is inactive' };
    }
  } else {
    return { error: 'No user provided' };
  }
}

Functions Over Classes Examples

// Standard
export function calculateTotal(items: Item[]): number {
  return items.reduce((sum, item) => sum + item.price, 0);
}

export function formatCurrency(amount: number): string {
  return `$${amount.toFixed(2)}`;
}

// Non-Standard
export class Calculator {
  static calculateTotal(items: Item[]): number {
    return items.reduce((sum, item) => sum + item.price, 0);
  }

  static formatCurrency(amount: number): string {
    return `$${amount.toFixed(2)}`;
  }
}

No Nested Functions Examples

// Standard
function transformItem(item: Item): TransformedItem {
  return { id: item.id, name: item.name.toUpperCase() };
}

async function processItems(items: Item[]): Promise<TransformedItem[]> {
  return items.map(transformItem);
}

// Non-Standard
async function processItems(items: Item[]): Promise<TransformedItem[]> {
  function transformItem(item: Item): TransformedItem {
    return { id: item.id, name: item.name.toUpperCase() };
  }
  return items.map(transformItem);
}

Immutability Examples

// Standard
function addItem(items: Item[], newItem: Item): Item[] {
  return [...items, newItem];
}

function removeItem(items: Item[], id: string): Item[] {
  return items.filter((item) => item.id !== id);
}

function updateItem(items: Item[], id: string, updates: Partial<Item>): Item[] {
  return items.map((item) => (item.id === id ? { ...item, ...updates } : item));
}

// Non-Standard
function addItem(items: Item[], newItem: Item): Item[] {
  items.push(newItem);
  return items;
}

function removeItem(items: Item[], id: string): Item[] {
  const index = items.findIndex((item) => item.id === id);
  items.splice(index, 1);
  return items;
}

Error Propagation Examples

// Standard
async function getUser(id: string): Promise<User> {
  return userService.findById(id);
}

// Non-Standard
async function getUser(id: string): Promise<User> {
  try {
    return await userService.findById(id);
  } catch (error) {
    console.error(error);
    throw error;
  }
}

TOCTOU Examples

// Standard
async function readConfig(path: string): Promise<Config> {
  try {
    const content = await readFile(path, 'utf-8');
    return JSON.parse(content);
  } catch (error) {
    if (isNotFoundError(error)) {
      return defaultConfig;
    }
    throw error;
  }
}

// Non-Standard
async function readConfig(path: string): Promise<Config> {
  if (await fileExists(path)) {
    const content = await readFile(path, 'utf-8');
    return JSON.parse(content);
  }
  return defaultConfig;
}

Type Reuse Examples

// Given an existing type
interface User {
  id: string;
  email: string;
  name: string;
  passwordHash: string;
  createdAt: Date;
  updatedAt: Date;
}

// Standard - derive from existing type
type PublicUser = Omit<User, 'passwordHash'>;
type UserSummary = Pick<User, 'id' | 'name'>;
type UserUpdate = Partial<Pick<User, 'email' | 'name'>>;

// Non-Standard - duplicating fields that already exist
interface PublicUser {
  id: string;
  email: string;
  name: string;
  createdAt: Date;
  updatedAt: Date;
}

interface UserSummary {
  id: string;
  name: string;
}

interface UserUpdate {
  email?: string;
  name?: string;
}

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

04

需要参考平台分布和安装热度时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

补充不同宿主或平台的使用分布数据

能力 5

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Claude Code

29.64%
按下载量换算384

github-copilot

24.9%
按下载量换算322

Gemini CLI

18.33%
按下载量换算237

Codex

14.13%
按下载量换算183

Cursor

8.14%
按下载量换算105

Antigravity

3.57%
按下载量换算46

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。

来源信息

继续浏览同类 Skills