Initial commit
This commit is contained in:
11
.claude-plugin/plugin.json
Normal file
11
.claude-plugin/plugin.json
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"name": "formatter",
|
||||||
|
"description": "Auto-format code files after editing using hooks",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"author": {
|
||||||
|
"name": "Jeremy Longshore"
|
||||||
|
},
|
||||||
|
"hooks": [
|
||||||
|
"./hooks/hooks.json"
|
||||||
|
]
|
||||||
|
}
|
||||||
3
README.md
Normal file
3
README.md
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
# formatter
|
||||||
|
|
||||||
|
Auto-format code files after editing using hooks
|
||||||
124
hooks/hooks.json
Normal file
124
hooks/hooks.json
Normal file
@@ -0,0 +1,124 @@
|
|||||||
|
{
|
||||||
|
"description": "Automatically formats code files after editing using Prettier, demonstrating best practices for PostToolUse hooks and event-driven automation",
|
||||||
|
"version": "2.0.0",
|
||||||
|
"author": "claude-code-examples",
|
||||||
|
"lastUpdated": "2025-10-11",
|
||||||
|
"hooks": {
|
||||||
|
"PostToolUse": [
|
||||||
|
{
|
||||||
|
"description": "Auto-format code files after Write or Edit operations",
|
||||||
|
"matcher": "Write|Edit",
|
||||||
|
"priority": 100,
|
||||||
|
"enabled": true,
|
||||||
|
"hooks": [
|
||||||
|
{
|
||||||
|
"type": "command",
|
||||||
|
"command": "${CLAUDE_PLUGIN_ROOT}/scripts/format.sh",
|
||||||
|
"description": "Runs Prettier formatter on supported file types (JS, TS, JSON, CSS, MD)",
|
||||||
|
"timeout": 5000,
|
||||||
|
"continueOnError": true,
|
||||||
|
"environment": {
|
||||||
|
"NODE_ENV": "production",
|
||||||
|
"PRETTIER_CONFIG": "${CLAUDE_PLUGIN_ROOT}/config/.prettierrc"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"PreToolUse": [
|
||||||
|
{
|
||||||
|
"description": "Optional: Validate file format before editing (disabled by default)",
|
||||||
|
"matcher": "Edit",
|
||||||
|
"priority": 50,
|
||||||
|
"enabled": false,
|
||||||
|
"hooks": [
|
||||||
|
{
|
||||||
|
"type": "command",
|
||||||
|
"command": "${CLAUDE_PLUGIN_ROOT}/scripts/validate-format.sh",
|
||||||
|
"description": "Checks if file is already formatted to avoid unnecessary changes",
|
||||||
|
"timeout": 3000,
|
||||||
|
"continueOnError": true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"configuration": {
|
||||||
|
"supportedExtensions": [
|
||||||
|
".js", ".jsx", ".ts", ".tsx", ".json",
|
||||||
|
".css", ".scss", ".less", ".md", ".mdx",
|
||||||
|
".yaml", ".yml", ".html", ".vue", ".svelte"
|
||||||
|
],
|
||||||
|
"prettierOptions": {
|
||||||
|
"semi": true,
|
||||||
|
"singleQuote": true,
|
||||||
|
"tabWidth": 2,
|
||||||
|
"trailingComma": "es5",
|
||||||
|
"printWidth": 100,
|
||||||
|
"bracketSpacing": true,
|
||||||
|
"arrowParens": "avoid"
|
||||||
|
},
|
||||||
|
"excludePatterns": [
|
||||||
|
"node_modules/**",
|
||||||
|
"dist/**",
|
||||||
|
"build/**",
|
||||||
|
"*.min.js",
|
||||||
|
"*.min.css",
|
||||||
|
"vendor/**"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"troubleshooting": {
|
||||||
|
"commonIssues": [
|
||||||
|
{
|
||||||
|
"issue": "Formatter not running",
|
||||||
|
"solutions": [
|
||||||
|
"Ensure Node.js is installed: node --version",
|
||||||
|
"Check if npx is available: which npx",
|
||||||
|
"Verify script permissions: ls -la scripts/format.sh",
|
||||||
|
"Check hook is enabled in this config"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"issue": "Files not formatting correctly",
|
||||||
|
"solutions": [
|
||||||
|
"Check if Prettier is installed globally or locally",
|
||||||
|
"Verify file type is supported",
|
||||||
|
"Check for .prettierignore file blocking formatting",
|
||||||
|
"Look for syntax errors preventing formatting"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"issue": "Performance issues",
|
||||||
|
"solutions": [
|
||||||
|
"Consider disabling for large files",
|
||||||
|
"Adjust timeout value if needed",
|
||||||
|
"Use excludePatterns to skip unnecessary files"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"debugMode": {
|
||||||
|
"enable": "export FORMATTER_DEBUG=true",
|
||||||
|
"logLocation": "${CLAUDE_PLUGIN_ROOT}/logs/formatter.log"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"examples": [
|
||||||
|
{
|
||||||
|
"scenario": "Format JavaScript file after editing",
|
||||||
|
"trigger": "Claude uses Edit tool on app.js",
|
||||||
|
"action": "PostToolUse hook triggers format.sh",
|
||||||
|
"result": "app.js is formatted with Prettier"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"scenario": "Create new React component",
|
||||||
|
"trigger": "Claude uses Write tool to create Button.jsx",
|
||||||
|
"action": "PostToolUse hook triggers after file creation",
|
||||||
|
"result": "Button.jsx is automatically formatted"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"scenario": "Edit configuration file",
|
||||||
|
"trigger": "Claude edits package.json",
|
||||||
|
"action": "PostToolUse hook formats JSON",
|
||||||
|
"result": "package.json has consistent formatting"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
45
plugin.lock.json
Normal file
45
plugin.lock.json
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
{
|
||||||
|
"$schema": "internal://schemas/plugin.lock.v1.json",
|
||||||
|
"pluginId": "gh:jeremylongshore/claude-code-plugins-plus:plugins/examples/formatter",
|
||||||
|
"normalized": {
|
||||||
|
"repo": null,
|
||||||
|
"ref": "refs/tags/v20251128.0",
|
||||||
|
"commit": "0de18019c097059b83c9e3165543ee4adf58738e",
|
||||||
|
"treeHash": "e45077928d3fd08c8ed0b8c94028b571b89be85eeafd0b1319a8d7c28ab44369",
|
||||||
|
"generatedAt": "2025-11-28T10:18:27.826598Z",
|
||||||
|
"toolVersion": "publish_plugins.py@0.2.0"
|
||||||
|
},
|
||||||
|
"origin": {
|
||||||
|
"remote": "git@github.com:zhongweili/42plugin-data.git",
|
||||||
|
"branch": "master",
|
||||||
|
"commit": "aa1497ed0949fd50e99e70d6324a29c5b34f9390",
|
||||||
|
"repoRoot": "/Users/zhongweili/projects/openmind/42plugin-data"
|
||||||
|
},
|
||||||
|
"manifest": {
|
||||||
|
"name": "formatter",
|
||||||
|
"description": "Auto-format code files after editing using hooks",
|
||||||
|
"version": "1.0.0"
|
||||||
|
},
|
||||||
|
"content": {
|
||||||
|
"files": [
|
||||||
|
{
|
||||||
|
"path": "README.md",
|
||||||
|
"sha256": "e422947bc422ed013b98bda021d3ef55a2a3e870155d2bb4682f8f1522a6b84e"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "hooks/hooks.json",
|
||||||
|
"sha256": "857111b98d67033b2f4cf90ffc82d3bfdb516dd9a669db8d73e4471655f48d78"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": ".claude-plugin/plugin.json",
|
||||||
|
"sha256": "6f3ecf57414a89ab43f659f41efd868d527d478a5d76b77b23467569c87a902d"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"dirSha256": "e45077928d3fd08c8ed0b8c94028b571b89be85eeafd0b1319a8d7c28ab44369"
|
||||||
|
},
|
||||||
|
"security": {
|
||||||
|
"scannedAt": null,
|
||||||
|
"scannerVersion": null,
|
||||||
|
"flags": []
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user