1
1
// .lintstagedrc.js
2
2
const path = require ( "path" ) ;
3
- const fs = require ( 'fs' )
3
+ const fs = require ( "fs" ) ;
4
4
5
5
// Helper to resolve path to venv executables
6
6
const venvBin = ( command ) => {
@@ -14,7 +14,15 @@ const venvBin = (command) => {
14
14
if ( fs . existsSync ( ".venv" ) ) {
15
15
return path . join ( ".venv" , bin , command ) ;
16
16
}
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
+ } ;
18
26
19
27
module . exports = {
20
28
// Python checks (run from root, using root venv)
@@ -32,12 +40,16 @@ module.exports = {
32
40
path . relative ( path . join ( "components" , "dash-core-components" ) , f )
33
41
) ;
34
42
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
+ ) ,
41
53
] ;
42
54
} ,
43
55
@@ -46,9 +58,12 @@ module.exports = {
46
58
path . relative ( path . join ( "components" , "dash-html-components" ) , f )
47
59
) ;
48
60
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
+ ) ,
52
67
] ;
53
68
} ,
54
69
@@ -57,12 +72,16 @@ module.exports = {
57
72
path . relative ( path . join ( "components" , "dash-table" ) , f )
58
73
) ;
59
74
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
+ ) ,
66
85
] ;
67
86
} ,
68
87
@@ -71,12 +90,16 @@ module.exports = {
71
90
path . relative ( path . join ( "dash" , "dash-renderer" ) , f )
72
91
) ;
73
92
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
+ ) ,
80
103
] ;
81
104
} ,
82
105
} ;
0 commit comments