11// .lintstagedrc.js
22const path = require ( "path" ) ;
3- const fs = require ( 'fs' )
3+ const fs = require ( "fs" ) ;
44
55// Helper to resolve path to venv executables
66const venvBin = ( command ) => {
@@ -14,7 +14,15 @@ const venvBin = (command) => {
1414 if ( fs . existsSync ( ".venv" ) ) {
1515 return path . join ( ".venv" , bin , command ) ;
1616 }
17- }
17+ } ;
18+
19+ // Allow to cd into a subdirectory
20+ const sh_cd = ( directory , command ) => {
21+ if ( process . platform == "win32" ) {
22+ return `cmd /k 'cd ${ directory } && ${ command } '` ;
23+ }
24+ return `sh -c 'cd ${ directory } && ${ command } '` ;
25+ } ;
1826
1927module . exports = {
2028 // Python checks (run from root, using root venv)
@@ -32,12 +40,16 @@ module.exports = {
3240 path . relative ( path . join ( "components" , "dash-core-components" ) , f )
3341 ) ;
3442 return [
35- `cd components/dash-core-components && npx eslint --no-error-on-unmatched-pattern ${ relativeFilePaths . join (
36- " "
37- ) } `,
38- `cd components/dash-core-components && npx prettier --check ${ relativeFilePaths . join (
39- " "
40- ) } `,
43+ sh_cd (
44+ "components/dash-core-components" ,
45+ `npx eslint --no-error-on-unmatched-pattern ${ relativeFilePaths . join (
46+ " "
47+ ) } `
48+ ) ,
49+ sh_cd (
50+ "components/dash-core-components" ,
51+ `npx prettier --check ${ relativeFilePaths . join ( " " ) } `
52+ ) ,
4153 ] ;
4254 } ,
4355
@@ -46,9 +58,12 @@ module.exports = {
4658 path . relative ( path . join ( "components" , "dash-html-components" ) , f )
4759 ) ;
4860 return [
49- `cd components/dash-html-components && npx eslint --no-error-on-unmatched-pattern ${ relativeFilePaths . join (
50- " "
51- ) } `,
61+ sh_cd (
62+ "components/dash-html-components" ,
63+ `npx eslint --no-error-on-unmatched-pattern ${ relativeFilePaths . join (
64+ " "
65+ ) } `
66+ ) ,
5267 ] ;
5368 } ,
5469
@@ -57,12 +72,16 @@ module.exports = {
5772 path . relative ( path . join ( "components" , "dash-table" ) , f )
5873 ) ;
5974 return [
60- `cd components/dash-table && npx eslint --no-error-on-unmatched-pattern ${ relativeFilePaths . join (
61- " "
62- ) } `,
63- `cd components/dash-table && npx prettier --check ${ relativeFilePaths . join (
64- " "
65- ) } `,
75+ sh_cd (
76+ "components/dash-table" ,
77+ `npx eslint --no-error-on-unmatched-pattern ${ relativeFilePaths . join (
78+ " "
79+ ) } `
80+ ) ,
81+ sh_cd (
82+ "components/dash-table" ,
83+ `npx prettier --check ${ relativeFilePaths . join ( " " ) } `
84+ ) ,
6685 ] ;
6786 } ,
6887
@@ -71,12 +90,16 @@ module.exports = {
7190 path . relative ( path . join ( "dash" , "dash-renderer" ) , f )
7291 ) ;
7392 return [
74- `cd dash/dash-renderer && npx eslint --no-error-on-unmatched-pattern ${ relativeFilePaths . join (
75- " "
76- ) } `,
77- `cd dash/dash-renderer && npx prettier --check ${ relativeFilePaths . join (
78- " "
79- ) } `,
93+ sh_cd (
94+ "dash/dash-renderer" ,
95+ `npx eslint --no-error-on-unmatched-pattern ${ relativeFilePaths . join (
96+ " "
97+ ) } `
98+ ) ,
99+ sh_cd (
100+ "dash/dash-renderer" ,
101+ `npx prettier --check ${ relativeFilePaths . join ( " " ) } `
102+ ) ,
80103 ] ;
81104 } ,
82105} ;
0 commit comments