Skip to content

Fix pre-commit cd and no revert #3328

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

Merged
merged 1 commit into from
Jun 9, 2025
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
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npx lint-staged
npx lint-staged --no-revert
69 changes: 46 additions & 23 deletions .lintstagedrc.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// .lintstagedrc.js
const path = require("path");
const fs = require('fs')
const fs = require("fs");

// Helper to resolve path to venv executables
const venvBin = (command) => {
Expand All @@ -14,7 +14,15 @@ const venvBin = (command) => {
if (fs.existsSync(".venv")) {
return path.join(".venv", bin, command);
}
}
};

// Allow to cd into a subdirectory
const sh_cd = (directory, command) => {
if (process.platform == "win32") {
return `cmd /k 'cd ${directory} && ${command}'`;
}
return `sh -c 'cd ${directory} && ${command}'`;
};

module.exports = {
// Python checks (run from root, using root venv)
Expand All @@ -32,12 +40,16 @@ module.exports = {
path.relative(path.join("components", "dash-core-components"), f)
);
return [
`cd components/dash-core-components && npx eslint --no-error-on-unmatched-pattern ${relativeFilePaths.join(
" "
)}`,
`cd components/dash-core-components && npx prettier --check ${relativeFilePaths.join(
" "
)}`,
sh_cd(
"components/dash-core-components",
`npx eslint --no-error-on-unmatched-pattern ${relativeFilePaths.join(
" "
)}`
),
sh_cd(
"components/dash-core-components",
`npx prettier --check ${relativeFilePaths.join(" ")}`
),
];
},

Expand All @@ -46,9 +58,12 @@ module.exports = {
path.relative(path.join("components", "dash-html-components"), f)
);
return [
`cd components/dash-html-components && npx eslint --no-error-on-unmatched-pattern ${relativeFilePaths.join(
" "
)}`,
sh_cd(
"components/dash-html-components",
`npx eslint --no-error-on-unmatched-pattern ${relativeFilePaths.join(
" "
)}`
),
];
},

Expand All @@ -57,12 +72,16 @@ module.exports = {
path.relative(path.join("components", "dash-table"), f)
);
return [
`cd components/dash-table && npx eslint --no-error-on-unmatched-pattern ${relativeFilePaths.join(
" "
)}`,
`cd components/dash-table && npx prettier --check ${relativeFilePaths.join(
" "
)}`,
sh_cd(
"components/dash-table",
`npx eslint --no-error-on-unmatched-pattern ${relativeFilePaths.join(
" "
)}`
),
sh_cd(
"components/dash-table",
`npx prettier --check ${relativeFilePaths.join(" ")}`
),
];
},

Expand All @@ -71,12 +90,16 @@ module.exports = {
path.relative(path.join("dash", "dash-renderer"), f)
);
return [
`cd dash/dash-renderer && npx eslint --no-error-on-unmatched-pattern ${relativeFilePaths.join(
" "
)}`,
`cd dash/dash-renderer && npx prettier --check ${relativeFilePaths.join(
" "
)}`,
sh_cd(
"dash/dash-renderer",
`npx eslint --no-error-on-unmatched-pattern ${relativeFilePaths.join(
" "
)}`
),
sh_cd(
"dash/dash-renderer",
`npx prettier --check ${relativeFilePaths.join(" ")}`
),
];
},
};