Skip to content

Commit 849de2d

Browse files
committed
feat(lint): add es lint and git hook
1 parent 34e5b4c commit 849de2d

File tree

7 files changed

+645
-34
lines changed

7 files changed

+645
-34
lines changed

.husky/pre-commit

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env sh
2+
. "$(dirname -- "$0")/_/husky.sh"
3+
4+
npx lint-staged
5+
6+
echo 'run pre commit'
7+
8+
npx lint-staged

Makefile

+3
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ endif
1717
docs:
1818
pnpm run docs
1919

20+
lint:
21+
cd packages/core && pnpm run lint
22+
2023
commit:
2124
git add . && pnpm run commit
2225

package.json

+10-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
"release": "commit-and-tag-version",
88
"docs": "cd document && pnpm run dev",
99
"dev": "cd packages/core && pnpm run dev",
10-
"test": "echo \"Error: no test specified\" && exit 0"
10+
"test": "echo \"Error: no test specified\" && exit 0",
11+
"prepare": "husky"
1112
},
1213
"engines": {
1314
"node": "16.15.0",
@@ -17,6 +18,11 @@
1718
"commit-and-tag-version": "^12.4.1",
1819
"cross-env": "^7.0.3",
1920
"cz-conventional-changelog": "^3.3.0",
21+
"husky": "^9.0.11",
22+
"lint-staged": "^15.2.7",
23+
"@eslint/js": "^9.6.0",
24+
"eslint": "9.x",
25+
"typescript-eslint": "^7.15.0",
2026
"nx": "16.10.0",
2127
"rimraf": "^5.0.7",
2228
"ts-node": "^10.9.1",
@@ -28,6 +34,9 @@
2834
"path": "cz-conventional-changelog"
2935
}
3036
},
37+
"lint-staged": {
38+
"src/**/*.ts": "eslint --fix"
39+
},
3140
"keywords": [],
3241
"author": "",
3342
"license": "ISC"

packages/core/eslint.config.mjs

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import globals from "globals";
2+
import pluginJs from "@eslint/js";
3+
import tseslint from "typescript-eslint";
4+
5+
6+
export default [
7+
{files: ["**/*.{js,mjs,cjs,ts}"]},
8+
{languageOptions: { globals: globals.browser }},
9+
pluginJs.configs.recommended,
10+
...tseslint.configs.recommended,
11+
];

packages/core/package.json

+5
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"dev": "vite",
2626
"build": "vite build",
2727
"serve": "vite preview",
28+
"lint": "eslint ./src",
2829
"preview:umd": "npm run build && npm run copy-umd && npm run serve",
2930
"preview:esm": "npm run build && npm run copy-esm && npm run serve",
3031
"copy-umd": "node ./script/copy-files.js ./examples/index.umd.html ./dist/index.html",
@@ -40,6 +41,10 @@
4041
},
4142
"devDependencies": {
4243
"@types/node": "^20.14.9",
44+
"@eslint/js": "^9.6.0",
45+
"eslint": "9.x",
46+
"typescript-eslint": "^7.15.0",
47+
"globals": "^15.8.0",
4348
"typescript": "^5.5.3",
4449
"vite": "^5.3.2",
4550
"vite-plugin-dts": "^3.9.1"

packages/core/src/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ class CollaGrid {
1919
private gridOptions: GridOptions<IRow>;
2020

2121
constructor(option: CollaGridOption) {
22+
console.log('option is', option);
2223
this.gridOptions = {
2324
rowData: [
2425
{make: "Tesla", model: "Model Y", price: 64950, electric: true},

0 commit comments

Comments
 (0)