@@ -12,7 +12,37 @@ const run = (cmd) => new Promise((resolve, reject) => exec(
1212const changeset = await run ( 'git diff --cached --name-only --diff-filter=ACMR' ) ;
1313const modifiedFiles = changeset . split ( '\n' ) . filter ( Boolean ) ;
1414
15- // Check if there are any model files staged
15+ // Auto-fix and lint staged JS files
16+ const jsFiles = modifiedFiles . filter ( ( f ) => f . endsWith ( '.js' ) ) ;
17+ if ( jsFiles . length > 0 ) {
18+ const fileList = jsFiles . join ( ' ' ) ;
19+ try {
20+ await run ( `npx eslint --fix ${ fileList } ` ) ;
21+ } catch {
22+ // fix ran; lint check below will surface unfixable errors
23+ }
24+ await run ( `git add ${ fileList } ` ) ;
25+ // Fail the commit if unfixable lint errors remain
26+ const output = await run ( `npx eslint ${ fileList } ` ) ;
27+ if ( output ) console . log ( output ) ;
28+ }
29+
30+ // Auto-fix and lint staged CSS files
31+ const cssFiles = modifiedFiles . filter ( ( f ) => f . endsWith ( '.css' ) ) ;
32+ if ( cssFiles . length > 0 ) {
33+ const fileList = cssFiles . join ( ' ' ) ;
34+ try {
35+ await run ( `npx stylelint --fix ${ fileList } ` ) ;
36+ } catch {
37+ // fix ran; lint check below will surface unfixable errors
38+ }
39+ await run ( `git add ${ fileList } ` ) ;
40+ // Fail the commit if unfixable lint errors remain
41+ const output = await run ( `npx stylelint ${ fileList } ` ) ;
42+ if ( output ) console . log ( output ) ;
43+ }
44+
45+ // Rebuild UE JSON bundles when model files are staged
1646const modifiedPartials = modifiedFiles . filter ( ( file ) => file . match ( / ^ u e \/ m o d e l s \/ .* \. j s o n / ) ) ;
1747if ( modifiedPartials . length > 0 ) {
1848 const output = await run ( 'npm run build:json --silent' ) ;
0 commit comments