-
-
Notifications
You must be signed in to change notification settings - Fork 2
chore: support code lint and commit lint #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#!/usr/bin/env sh | ||
pnpm run commitlint | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#!/usr/bin/env sh | ||
pnpm run lint && pnpm run test |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"trailingComma": "es5", | ||
"tabWidth": 2, | ||
"semi": true, | ||
"singleQuote": true | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export default { extends: ['@commitlint/config-conventional'] }; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import reactPlugin from 'eslint-plugin-react'; | ||
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended'; | ||
import eslintConfigPrettier from 'eslint-config-prettier/flat'; | ||
import { defineConfig } from 'eslint/config'; | ||
import tseslint from 'typescript-eslint'; | ||
|
||
export default defineConfig( | ||
tseslint.configs.recommended, | ||
reactPlugin.configs.flat.recommended, | ||
reactPlugin.configs.flat['jsx-runtime'], | ||
eslintPluginPrettierRecommended, | ||
eslintConfigPrettier | ||
); | ||
Comment on lines
+1
to
+13
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Invalid ESLint flat config composition (defineConfig usage and array/object mixing) The current export won’t work as intended:
Use a single array and spread TS configs: -import reactPlugin from 'eslint-plugin-react';
-import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';
-import eslintConfigPrettier from 'eslint-config-prettier/flat';
-import { defineConfig } from 'eslint/config';
-import tseslint from 'typescript-eslint';
-
-export default defineConfig(
- tseslint.configs.recommended,
- reactPlugin.configs.flat.recommended,
- reactPlugin.configs.flat['jsx-runtime'],
- eslintPluginPrettierRecommended,
- eslintConfigPrettier
-);
+import reactPlugin from 'eslint-plugin-react';
+import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';
+import eslintConfigPrettier from 'eslint-config-prettier/flat';
+import { defineConfig } from 'eslint/config';
+import tseslint from 'typescript-eslint';
+
+export default defineConfig([
+ // TypeScript ESLint recommended (array)
+ ...tseslint.configs.recommended,
+ // React plugin (objects)
+ reactPlugin.configs.flat.recommended,
+ reactPlugin.configs.flat['jsx-runtime'],
+ // Prettier plugin + Prettier config (keep last)
+ eslintPluginPrettierRecommended,
+ eslintConfigPrettier,
+]); Optional: If you want auto React version detection, you can append a small config object: { settings: { react: { version: 'detect' } } } 🤖 Prompt for AI Agents
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,15 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Interactive Video React Wrapper Example</title> | ||
</head> | ||
|
||
<body> | ||
<div id="root"></div> | ||
<script type="module" src="./dist/index.js"></script> | ||
</body> | ||
|
||
</html> |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -13,6 +13,12 @@ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"require": "./dist/index.cjs" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"lint-staged": { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"*.{js,jsx,ts,tsx}": [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"eslint --fix", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"prettier --write --cache" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"files": [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"dist" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -21,7 +27,9 @@ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"dev": "tsup --watch", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"test": "vitest run", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"clean": "rm -rf dist", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"prepare": "pnpm build", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"prepare": "husky", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"lint": "lint-staged", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"commitlint": "commitlint --edit", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"serve-examples": "pnpm build-examples && http-server examples -c-1", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+30
to
33
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Verification agent 🧩 Analysis chainVerify Husky hooks call the right scripts (commit-msg must pass the file to commitlint) The scripts look good. Please confirm that:
Run this script to verify hook presence and contents: 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "Checking Husky hooks..."
if [ ! -d ".husky" ]; then
echo "❌ .husky directory not found"; exit 1
fi
echo "== .husky/pre-commit =="
if [ -f ".husky/pre-commit" ]; then
sed -n '1,120p' .husky/pre-commit
echo
rg -n "lint-staged|pnpm lint" .husky/pre-commit || echo "⚠️ pre-commit may not run lint-staged"
else
echo "❌ .husky/pre-commit not found"
fi
echo
echo "== .husky/commit-msg =="
if [ -f ".husky/commit-msg" ]; then
sed -n '1,120p' .husky/commit-msg
echo
rg -n "commitlint\s+--edit\s+\$1|pnpm\s+commitlint\s+--edit\s+\$1" .husky/commit-msg || echo "⚠️ commit-msg may not pass the commit file to commitlint"
else
echo "❌ .husky/commit-msg not found"
fi Length of output: 780 Ensure Husky commit-msg hook passes the commit file to commitlint The pre-commit hook is correctly invoking lint-staged via # .husky/commit-msg
- pnpm run commitlint
+ pnpm run commitlint -- "$1" Or, if you prefer calling the CLI directly: # .husky/commit-msg
- pnpm run commitlint
+ pnpm commitlint --edit "$1" This will ensure your commit messages are actually passed to commitlint for validation. 🤖 Prompt for AI Agents
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"build-examples": "esbuild examples/index.tsx --bundle --outfile=examples/dist/index.js --jsx=automatic" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -59,9 +67,22 @@ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"vitest": "^3.2.4" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"devDependencies": { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"@commitlint/cli": "^19.8.1", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"@commitlint/config-conventional": "^19.8.1", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"@testing-library/jest-dom": "^6.6.4", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"@testing-library/react": "^16.0.0", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"@types/react": "^19.1.9", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"http-server": "^14.1.1" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"@typescript-eslint/eslint-plugin": "^8.39.0", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"@typescript-eslint/parser": "^8.39.0", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"eslint": "^9.33.0", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"eslint-config-prettier": "^10.1.8", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"eslint-plugin-prettier": "^5.5.4", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"eslint-plugin-react": "^7.37.5", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"exbuild": "^0.2.2", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"http-server": "^14.1.1", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"husky": "^9.1.7", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"lint-staged": "^16.1.5", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"prettier": "^3.6.2", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"typescript-eslint": "^8.39.0" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+70
to
87
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Verification agent 🧩 Analysis chainFix devDependency typo: use esbuild (not exbuild) to match your build script The examples script uses esbuild, but devDependencies add exbuild. This will break pnpm run build-examples with pnpm because pnpm doesn’t link transitive bins to the root. Replace exbuild with esbuild: - "exbuild": "^0.2.2",
+ "esbuild": "^0.24.0", Note: Adjust the version if your CI constraints differ; any recent 0.2x should work. Ensure esbuild is a direct devDependency so its CLI is available at node_modules/.bin/esbuild under pnpm. You can validate locally with:
🏁 Script executed: #!/bin/bash
set -eo pipefail
# Display the "scripts" section of package.json to confirm build-examples usage
sed -n '1,200p' package.json | sed -n '/"scripts"/,/\}/p'
# Check for the typo "exbuild" in devDependencies
grep -R '"exbuild"' -n package.json || echo "No exbuild found outside snippet."
# Search the entire repo for any references to esbuild in code or scripts
grep -R 'esbuild' -n . || echo "No esbuild references found." Length of output: 266639 Fix typo in devDependencies: replace exbuild with esbuild The "devDependencies": {
- "exbuild": "^0.2.2",
+ "esbuild": "^0.25.0",
// …other deps
} Pick a recent 0.x version (your lockfile shows 0.25.8), then run:
📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Pass the commit message to commitlint and source husky.sh
Without --edit "$1", commitlint may not validate the message file. Also source husky.sh for environment setup.
Suggested hook:
📝 Committable suggestion
🤖 Prompt for AI Agents