Skip to content
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

feat(sage-monorepo): configure pre-commit hooks to format and lint files #2801

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .husky/post-checkout
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

node tools/prepare-nodejs-envs.js
node tools/prepare-java-envs.js
node tools/prepare-python-envs.js
Expand Down
3 changes: 0 additions & 3 deletions .husky/post-merge
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

# Install the Node.js dependencies.
# rm -rf node_modules && yarn install --immutable
node tools/prepare-nodejs-envs.js
Expand Down
3 changes: 0 additions & 3 deletions .husky/post-rewrite
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

node tools/prepare-nodejs-envs.js
node tools/prepare-java-envs.js
node tools/prepare-python-envs.js
Expand Down
7 changes: 3 additions & 4 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"
# Run formatters and linters against staged git files
pnpm dlx lint-staged --relative

nx affected --uncommitted --target=format
nx affected --uncommitted --target=lint
# nx affected --uncommitted --target=lint

# Re-index the staged files after they have been formatted
# git diff --name-only --cached | xargs -l git add
3 changes: 0 additions & 3 deletions .husky/pre-push
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

# yarn nx affected --target=test
# yarn nx affected --target=integration-test
14 changes: 14 additions & 0 deletions lint-staged.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// lint-staged.config.js

module.exports = {
// Format JavaScript, TypeScript, and JSX/TSX files first, then lint
'**/*.{js,jsx,ts,tsx}': (filenames) => [
// Format files with Prettier first
`prettier --write ${filenames.join(' ')}`,
// Then run ESLint on the formatted files
`nx affected --target=lint --files=${filenames.join(',')}`,
],

// Format JSON, Markdown, and YAML files
'**/*.{json,md,yaml,yml}': (filenames) => [`nx format:write --files=${filenames.join(',')}`],
};
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,13 @@
"eslint-plugin-playwright": "^0.15.3",
"eslint-plugin-promise": "6.1.1",
"glob": "8.0.3",
"google-java-format": "1.1.0",
"hint": "7.1.3",
"husky": "8.0.2",
"husky": "9.1.5",
"ibm-openapi-validator": "1.7.0",
"jest": "29.4.3",
"jest-environment-jsdom": "29.4.3",
"jest-preset-angular": "14.1.1",
"lint-staged": "15.2.10",
"ng-packagr": "18.0.0",
"ngx-echarts": "16.0.0",
"nock": "13.2.9",
Expand Down
Loading
Loading