jpskill.com
🛠️ 開発・MCP コミュニティ

shared-tooling-eslint-prettier

ESLintとPrettierというコード整形ツールを、設定ファイル共有やTypeScriptとの連携で効率的に使い、コードの品質を維持・向上させるSkill。

📜 元の英語説明(参考)

ESLint 9/10 flat config with defineConfig(), Prettier v3.0+ shared config, eslint-config-prettier integration, typescript-eslint v8+ projectService

🇯🇵 日本人クリエイター向け解説

一言でいうと

ESLintとPrettierというコード整形ツールを、設定ファイル共有やTypeScriptとの連携で効率的に使い、コードの品質を維持・向上させるSkill。

※ jpskill.com 編集部が日本のビジネス現場向けに補足した解説です。Skill本体の挙動とは独立した参考情報です。

⚡ おすすめ: コマンド1行でインストール(60秒)

下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。

🍎 Mac / 🐧 Linux
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o shared-tooling-eslint-prettier.zip https://jpskill.com/download/10267.zip && unzip -o shared-tooling-eslint-prettier.zip && rm shared-tooling-eslint-prettier.zip
🪟 Windows (PowerShell)
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/10267.zip -OutFile "$d\shared-tooling-eslint-prettier.zip"; Expand-Archive "$d\shared-tooling-eslint-prettier.zip" -DestinationPath $d -Force; ri "$d\shared-tooling-eslint-prettier.zip"

完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。

💾 手動でダウンロードしたい(コマンドが難しい人向け)
  1. 1. 下の青いボタンを押して shared-tooling-eslint-prettier.zip をダウンロード
  2. 2. ZIPファイルをダブルクリックで解凍 → shared-tooling-eslint-prettier フォルダができる
  3. 3. そのフォルダを C:\Users\あなたの名前\.claude\skills\(Win)または ~/.claude/skills/(Mac)へ移動
  4. 4. Claude Code を再起動

⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。

🎯 このSkillでできること

下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。

📦 インストール方法 (3ステップ)

  1. 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
  2. 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
  3. 3. 展開してできたフォルダを、ホームフォルダの .claude/skills/ に置く
    • · macOS / Linux: ~/.claude/skills/
    • · Windows: %USERPROFILE%\.claude\skills\

Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。

詳しい使い方ガイドを見る →
最終更新
2026-05-18
取得日時
2026-05-18
同梱ファイル
1

📖 Skill本文(日本語訳)

※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。

ESLint & Prettier

簡単なガイド: defineConfig()globalIgnores() を使用した ESLint 9+ のフラット設定。projectService: true を使用した typescript-eslint v8+。一貫したフォーマットのための Prettier 共有設定。競合するルールを無効にするための eslint-config-prettier。より良い DX のための eslint-plugin-only-warn。

警告: ESLint 10 は 2026 年 2 月にリリースされ、.eslintrc のサポートを完全に削除しました。今すぐフラット設定に移行してください。


<critical_requirements>

重要: この Skill を使用する前に

すべてのコードは CLAUDE.md のプロジェクト規約に従う必要があります (kebab-case、名前付きエクスポート、インポート順序、import type、名前付き定数)

(ESLint 9+ のフラット設定を eslint/configdefineConfig() と共に使用する必要があります - レガシーな .eslintrc ではありません)

(明示的なグローバル無視パターンには globalIgnores() を使用する必要があります - ベアな ignores プロパティではありません)

(型付きリンティングには projectService: true を使用した typescript-eslint v8+ を使用する必要があります)

(より良い DX のために、エラーを警告に変換する eslint-plugin-only-warn を含める必要があります)

(Prettier と競合するフォーマットルールを無効にするために eslint-config-prettier を使用する必要があります)

</critical_requirements>


自動検出: ESLint 9 フラット設定、defineConfig、globalIgnores、eslint.config.ts、Prettier 設定、prettier.config.mjs、eslint-config-prettier、eslint-plugin-only-warn、typescript-eslint projectService、.eslintrc の移行

使用するタイミング:

  • ESLint 9/10 フラット設定のセットアップ (スタンドアロンまたは共有)
  • 共有設定での Prettier の構成
  • レガシーな .eslintrc からフラット設定への移行
  • ESLint と Prettier の統合 (eslint-config-prettier)
  • projectService を使用した typescript-eslint v8+ の構成
  • カスタム ESLint ルールのセットアップ (名前付きエクスポート、インポート制限、型インポート)

使用しないタイミング:

  • ランタイムコード (これはビルド時のツールのみです)
  • CI/CD パイプライン構成
  • Git フックまたは lint-staged のセットアップ
  • TypeScript コンパイラ構成 (tsconfig)
  • バンドラー構成

詳細なリソース:

  • examples/core.md - 必須のフラット設定 + Prettier のセットアップ
  • examples/eslint.md - 高度な ESLint パターン (共有設定、カスタムルール、ESLint 10 の移行)
  • examples/prettier.md - 高度な Prettier パターン (TS 設定、実験的なオプション、無視ファイル)
  • reference.md - バージョンリファレンスと公式ドキュメントへのリンク

<philosophy>

哲学

リンティングとフォーマットは、高速、一貫性があり、非ブロッキングであるべきです。開発者はツールと戦うべきではありません - ツールは開発中に邪魔にならないようにしながら、早期に問題をキャッチするのに役立つはずです。

コア原則:

  1. エラーではなく警告 - only-warn を使用して、リントエラーを警告に変換し、開発者がブロックされずに反復できるようにします
  2. 信頼できる唯一の情報源 - 共有設定により、パッケージとチームメンバー間のずれを防ぎます
  3. フォーマットの自動化 - Prettier はすべてのフォーマットの決定を処理します。ESLint はコード品質のみを処理します
  4. 競合なし - eslint-config-prettier は、ESLint と Prettier が決して意見の相違を起こさないようにします

</philosophy>


<patterns>

コアパターン

パターン 1: defineConfig() を使用した ESLint 9+ フラット設定

ESLint 9+ はフラット設定を使用します。eslint/configdefineConfig() ヘルパーは、型安全性と自動配列平坦化を提供します。globalIgnores() は、グローバルな無視パターンを明示的にマークします。

// eslint.config.ts — 必須のフラット設定
import js from "@eslint/js";
import { defineConfig, globalIgnores } from "eslint/config";
import tseslint from "typescript-eslint";
import eslintConfigPrettier from "eslint-config-prettier";
import * as onlyWarnPlugin from "eslint-plugin-only-warn";

export default defineConfig(
  globalIgnores(["dist/**", "generated/**", "node_modules/**"]),
  js.configs.recommended,
  eslintConfigPrettier,
  tseslint.configs.recommended,
  { plugins: { "only-warn": onlyWarnPlugin } }, // 最後に配置する必要がある
);

重要なポイント: defineConfig() は配列を自動的に平坦化し (スプレッド演算子は不要)、globalIgnores() はベアな ignores のあいまいな動作を防ぎ、only-warn は先行するすべてのエラーを警告に変換し、eslint-config-prettier は Prettier と競合するフォーマットルールを無効にします。

完全なスタンドアロンおよび共有設定パターンについては、examples/core.md を参照してください。


パターン 2: projectService を使用した typescript-eslint v8+

projectService 機能 (v8 以降安定) は、各ファイルの最も近い tsconfig.json を自動的に検出し、脆弱な手動の project パスを置き換えます。

parserOptions: {
  projectService: true,
  allowDefaultProject: ["*.config.ts", "*.config.mjs"],
},

重要なポイント: tsconfig.eslint.json ファイルの必要性を排除し、手動のプロジェクト構成よりも高速で、allowDefaultProject は tsconfig にない構成ファイルを処理します。

typescript-eslint の完全な構成については、examples/core.md を参照してください。


パターン 3: 共有設定パターン (モノレポ/チーム)

チームまたはモノレポの場合、ずれを防ぐためにリンティング設定を共有パッケージに抽出します。

// packages/eslint-config/base.ts — 共有設定
export const baseConfig = defineConfig(
  globalIgnores(["dist/**", "generated/**"]),
  js.configs.recommended,
  eslintConfigPrettier,
  tseslint.configs.recommended,
  { plugins: { "only-warn": onlyWarnPlugin } },
);

// apps/my-app/eslint.config.ts — 共有設定の使用
export default defineConfig(baseConfig, customRules, {
  rules: { "no-console": "warn" },
});

重要なポイント: defineConfig() は自動的に平坦化するため、スプレッド演算子は不要です。信頼できる唯一の情報源は、構成のずれを防ぎます。型チェックのための TypeScript 構成ファイル。

共有設定とカスタムルールのパターンについては、examples/eslint.md を参照してください。


パターン 4: Prettier 共有設定

Prettier の設定は、すべてのパッケージで一貫している必要があります。チームの場合は、共有設定を使用します。


// prettier.config.mjs
const config = {
  printWidth: 100,
  semi: true,
  singleQuote: false,
  bracketSpacing: t

(原文がここで切り詰められています)
📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開

ESLint & Prettier

Quick Guide: ESLint 9+ flat config with defineConfig() and globalIgnores(). typescript-eslint v8+ with projectService: true. Prettier shared config with consistent formatting. eslint-config-prettier to disable conflicting rules. eslint-plugin-only-warn for better DX.

WARNING: ESLint 10 was released February 2026 and completely removes .eslintrc support. Migrate to flat config now.


<critical_requirements>

CRITICAL: Before Using This Skill

All code must follow project conventions in CLAUDE.md (kebab-case, named exports, import ordering, import type, named constants)

(You MUST use ESLint 9+ flat config with defineConfig() from eslint/config - NOT legacy .eslintrc)

(You MUST use globalIgnores() for explicit global ignore patterns - NOT bare ignores property)

(You MUST use typescript-eslint v8+ with projectService: true for typed linting)

(You MUST include eslint-plugin-only-warn to convert errors to warnings for better DX)

(You MUST use eslint-config-prettier to disable formatting rules that conflict with Prettier)

</critical_requirements>


Auto-detection: ESLint 9 flat config, defineConfig, globalIgnores, eslint.config.ts, Prettier config, prettier.config.mjs, eslint-config-prettier, eslint-plugin-only-warn, typescript-eslint projectService, .eslintrc migration

When to use:

  • Setting up ESLint 9/10 flat config (standalone or shared)
  • Configuring Prettier with shared config
  • Migrating from legacy .eslintrc to flat config
  • Integrating ESLint and Prettier (eslint-config-prettier)
  • Configuring typescript-eslint v8+ with projectService
  • Setting up custom ESLint rules (named exports, import restrictions, type imports)

When NOT to use:

  • Runtime code (this is build-time tooling only)
  • CI/CD pipeline configuration
  • Git hooks or lint-staged setup
  • TypeScript compiler configuration (tsconfig)
  • Bundler configuration

Detailed Resources:


<philosophy>

Philosophy

Linting and formatting should be fast, consistent, and non-blocking. Developers should not fight with tools - tools should help catch issues early while staying out of the way during development.

Core principles:

  1. Warnings, not errors - Use only-warn to convert lint errors to warnings so developers can iterate without being blocked
  2. Single source of truth - Shared configs prevent drift between packages and team members
  3. Automate formatting - Prettier handles all formatting decisions; ESLint handles code quality only
  4. No conflicts - eslint-config-prettier ensures ESLint and Prettier never disagree

</philosophy>


<patterns>

Core Patterns

Pattern 1: ESLint 9+ Flat Config with defineConfig()

ESLint 9+ uses flat config. The defineConfig() helper from eslint/config provides type safety and automatic array flattening. globalIgnores() explicitly marks global ignore patterns.

// eslint.config.ts — the essential flat config
import js from "@eslint/js";
import { defineConfig, globalIgnores } from "eslint/config";
import tseslint from "typescript-eslint";
import eslintConfigPrettier from "eslint-config-prettier";
import * as onlyWarnPlugin from "eslint-plugin-only-warn";

export default defineConfig(
  globalIgnores(["dist/**", "generated/**", "node_modules/**"]),
  js.configs.recommended,
  eslintConfigPrettier,
  tseslint.configs.recommended,
  { plugins: { "only-warn": onlyWarnPlugin } }, // must be last
);

Key points: defineConfig() auto-flattens arrays (no spread operators needed), globalIgnores() prevents ambiguous behavior of bare ignores, only-warn converts all preceding errors to warnings, eslint-config-prettier disables formatting rules that conflict with Prettier.

See examples/core.md for the complete standalone and shared config patterns.


Pattern 2: typescript-eslint v8+ with projectService

The projectService feature (stable since v8) auto-discovers the nearest tsconfig.json for each file, replacing the fragile manual project path.

parserOptions: {
  projectService: true,
  allowDefaultProject: ["*.config.ts", "*.config.mjs"],
},

Key points: Eliminates need for tsconfig.eslint.json files, faster than manual project configuration, allowDefaultProject handles config files not in tsconfig.

See examples/core.md for full typescript-eslint configuration.


Pattern 3: Shared Config Pattern (Monorepos/Teams)

For teams or monorepos, extract linting config into a shared package to prevent drift.

// packages/eslint-config/base.ts — shared config
export const baseConfig = defineConfig(
  globalIgnores(["dist/**", "generated/**"]),
  js.configs.recommended,
  eslintConfigPrettier,
  tseslint.configs.recommended,
  { plugins: { "only-warn": onlyWarnPlugin } },
);

// apps/my-app/eslint.config.ts — consuming shared config
export default defineConfig(baseConfig, customRules, {
  rules: { "no-console": "warn" },
});

Key points: defineConfig() auto-flattens so no spread operators needed, single source of truth prevents config drift, TypeScript config file for type checking.

See examples/eslint.md for shared config and custom rules patterns.


Pattern 4: Prettier Shared Config

Prettier config should be consistent across all packages. Use a shared config for teams.

// prettier.config.mjs
const config = {
  printWidth: 100,
  semi: true,
  singleQuote: false,
  bracketSpacing: true,
  arrowParens: "always",
  endOfLine: "lf",
  bracketSameLine: false,
  // trailingComma: "all" is the default in Prettier 3.0+
};
export default config;

Key points: trailingComma: "all" is the default in v3.0+ (don't set it explicitly), bracketSameLine replaces deprecated jsxBracketSameLine, explicit endOfLine: "lf" prevents cross-platform issues.

See examples/prettier.md for TypeScript config files, experimental options, and ignore patterns.


Pattern 5: Custom ESLint Rules

Common custom rules for enforcing project conventions — named exports, consistent type imports, unused variable detection, and import boundary enforcement:

export const customRules = {
  rules: {
    "import/no-default-export": "warn",
    "@typescript-eslint/consistent-type-imports": [
      "warn",
      { prefer: "type-imports" },
    ],
    "@typescript-eslint/no-unused-vars": [
      "warn",
      { argsIgnorePattern: "^_", varsIgnorePattern: "^_" },
    ],
  },
};

See examples/eslint.md for the full custom rules pattern including import boundary restrictions.


Pattern 6: Using extends Property (ESLint 9.15+)

The extends property in flat config objects simplifies plugin composition — standardizes config merging regardless of plugin format (object, array, or string):

export default defineConfig({
  files: ["**/*.ts", "**/*.tsx"],
  extends: [
    "eslint/recommended",
    tseslint.configs.recommended,
    // Add your framework plugin's flat config here
  ],
  rules: { "no-console": "warn" },
});

See examples/core.md for the full extends pattern.

</patterns>


<decision_framework>

Decision Framework

ESLint + Prettier vs Alternatives

Need linting and formatting?
├─ Speed is critical bottleneck (1000+ files)?
│   └─ YES → Consider a Rust-based unified linter/formatter (not this skill's scope)
└─ Need mature plugin ecosystem?
    └─ YES → ESLint 9/10 + Prettier ✓

ESLint + Prettier strengths: Mature ecosystem, extensive plugin support, framework-specific plugins

ESLint 9 vs ESLint 10

Which ESLint version?
├─ New project?
│   └─ ESLint 10 (latest, cleanest API)
├─ Existing project with flat config?
│   └─ ESLint 10 (straightforward upgrade)
├─ Existing project with .eslintrc?
│   ├─ Can invest time to migrate?
│   │   └─ YES → Migrate to flat config, then ESLint 10
│   └─ NO → ESLint 9.x (still supported, but plan migration)
└─ Node.js < 20.19.0?
    └─ ESLint 9.x (ESLint 10 requires 20.19.0+)

Shared Config vs Local Config

Setting up linting/formatting?
├─ Monorepo with multiple packages?
│   └─ YES → Shared config ✓
├─ Team project (2+ developers)?
│   └─ YES → Shared config (consistency matters)
└─ Single package / solo project?
    └─ YES → Local config is fine

Prettier Config File Format

What Prettier config format to use?
├─ Need type checking in config?
│   ├─ Node.js 22.6.0+? → prettier.config.ts
│   └─ NO → Use .mjs with JSDoc types
├─ ESM project? → prettier.config.mjs
└─ CommonJS project? → prettier.config.cjs

</decision_framework>


<red_flags>

RED FLAGS

High Priority Issues:

  • ❌ Using legacy .eslintrc format instead of ESLint 9+ flat config (BROKEN in ESLint 10)
  • ❌ Using bare ignores property instead of globalIgnores() helper (ambiguous behavior — acts as global ignores when alone, but as local excludes when paired with other properties)
  • ❌ Missing eslint-plugin-only-warn (errors block developers during development)
  • ❌ Missing eslint-config-prettier (ESLint and Prettier rules conflict, creating endless fix cycles)

Medium Priority Issues:

  • ⚠️ Using manual project option instead of projectService: true in typescript-eslint (fragile in monorepos, slower)
  • ⚠️ Using deprecated jsxBracketSameLine option in Prettier (renamed to bracketSameLine in Prettier 2.4)
  • ⚠️ Explicitly setting trailingComma: "all" in Prettier 3.0+ (it is already the default)
  • ⚠️ Using tseslint.config() wrapper (planned for deprecation in favor of ESLint's native defineConfig())
  • ⚠️ Hardcoded config values in each package instead of shared config

Gotchas & Edge Cases:

  • only-warn plugin must be loaded AFTER other plugins to convert their errors to warnings
  • defineConfig() auto-flattens arrays — never use spread operators with it
  • projectService requires typescript-eslint v8+ (was EXPERIMENTAL_useProjectService in v6-v7)
  • ESLint 10 requires Node.js ^20.19.0 || ^22.13.0 || >=24 (v21.x and v23.x explicitly unsupported)
  • ESLint 10 config lookup starts from linted file directory (not cwd) — enables monorepo multi-config
  • Prettier TypeScript config files (.prettierrc.ts) require Node.js 22.6.0+; before Node v24.3.0 run with --experimental-strip-types
  • Prettier 3.0+ APIs are async — plugins using sync APIs need migration (use @prettier/sync for sync wrappers)
  • ESLint 9.15+: eslint.config.ts TypeScript config files and extends property supported natively
  • ESLint 9.34+: Multithreaded linting available via --concurrency flag (30-300% performance boost on large projects)
  • ESLint 10: /* eslint-env */ comments now trigger errors; deprecated Linter methods removed

</red_flags>


<critical_reminders>

CRITICAL REMINDERS

All code must follow project conventions in CLAUDE.md

(You MUST use ESLint 9+ flat config with defineConfig() from eslint/config - NOT legacy .eslintrc)

(You MUST use globalIgnores() for explicit global ignore patterns - NOT bare ignores property)

(You MUST use typescript-eslint v8+ with projectService: true for typed linting)

(You MUST include eslint-plugin-only-warn to convert errors to warnings for better DX)

(You MUST use eslint-config-prettier to disable formatting rules that conflict with Prettier)

Failure to follow these rules will cause inconsistent tooling, conflicting formatting rules, and blocked developers.

WARNING: ESLint 10 (February 2026) completely removes .eslintrc support. Plan migration now.

</critical_reminders>