@@ -9,10 +9,7 @@ import { fileURLToPath } from 'node:url'
99
1010import { isQuiet } from '@socketsecurity/lib/argv/flags'
1111import { parseArgs } from '@socketsecurity/lib/argv/parse'
12- import {
13- getChangedFiles ,
14- getStagedFiles ,
15- } from '@socketsecurity/lib/git'
12+ import { getChangedFiles , getStagedFiles } from '@socketsecurity/lib/git'
1613import { logger } from '@socketsecurity/lib/logger'
1714import { printHeader } from '@socketsecurity/lib/stdio/header'
1815
@@ -89,7 +86,7 @@ function filterLintableFiles(files) {
8986}
9087
9188/**
92- * Run ESLint on specific files.
89+ * Run linters on specific files.
9390 */
9491async function runLintOnFiles ( files , options = { } ) {
9592 const { fix = false , quiet = false } = options
@@ -103,45 +100,70 @@ async function runLintOnFiles(files, options = {}) {
103100 logger . progress ( `Linting ${ files . length } file(s)` )
104101 }
105102
106- const args = [
107- 'exec' ,
108- 'eslint' ,
109- '-c' ,
110- '.config/eslint.config.mjs' ,
111- '--report-unused-disable-directives' ,
112- '--ignore-pattern' ,
113- 'build/' ,
114- '--ignore-pattern' ,
115- 'binaries/' ,
116- '--ignore-pattern' ,
117- 'dist/' ,
118- '--ignore-pattern' ,
119- 'external/' ,
120- '--ignore-pattern' ,
121- '.cache/' ,
122- '--ignore-pattern' ,
123- '.claude/' ,
124- '--ignore-pattern' ,
125- 'pkg-binaries/' ,
126- ...( fix ? [ '--fix' ] : [ ] ) ,
127- ...files ,
103+ // Build the linter configurations.
104+ const linters = [
105+ {
106+ args : [
107+ 'exec' ,
108+ 'biome' ,
109+ 'check' ,
110+ '--log-level=none' ,
111+ ...( fix ? [ '--write' , '--unsafe' ] : [ ] ) ,
112+ ...files ,
113+ ] ,
114+ name : 'biome' ,
115+ enabled : true ,
116+ } ,
117+ {
118+ args : [
119+ 'exec' ,
120+ 'eslint' ,
121+ '-c' ,
122+ '.config/eslint.config.mjs' ,
123+ '--report-unused-disable-directives' ,
124+ '--ignore-pattern' ,
125+ 'build/' ,
126+ '--ignore-pattern' ,
127+ 'binaries/' ,
128+ '--ignore-pattern' ,
129+ 'dist/' ,
130+ '--ignore-pattern' ,
131+ 'external/' ,
132+ '--ignore-pattern' ,
133+ '.cache/' ,
134+ '--ignore-pattern' ,
135+ '.claude/' ,
136+ '--ignore-pattern' ,
137+ 'pkg-binaries/' ,
138+ ...( fix ? [ '--fix' ] : [ ] ) ,
139+ ...files ,
140+ ] ,
141+ name : 'eslint' ,
142+ enabled : true ,
143+ } ,
128144 ]
129145
130- const result = await runCommandQuiet ( 'pnpm' , args )
146+ for ( const { args, enabled } of linters ) {
147+ if ( ! enabled ) {
148+ continue
149+ }
131150
132- if ( result . exitCode !== 0 ) {
133- // When fixing, non-zero exit codes are normal if fixes were applied
134- if ( ! fix || ( result . stderr && result . stderr . trim ( ) . length > 0 ) ) {
135- if ( ! quiet ) {
136- logger . error ( 'Linting failed' )
137- }
138- if ( result . stderr ) {
139- console . error ( result . stderr )
140- }
141- if ( result . stdout && ! fix ) {
142- console . log ( result . stdout )
151+ const result = await runCommandQuiet ( 'pnpm' , args )
152+
153+ if ( result . exitCode !== 0 ) {
154+ // When fixing, non-zero exit codes are normal if fixes were applied.
155+ if ( ! fix || ( result . stderr && result . stderr . trim ( ) . length > 0 ) ) {
156+ if ( ! quiet ) {
157+ logger . error ( 'Linting failed' )
158+ }
159+ if ( result . stderr ) {
160+ console . error ( result . stderr )
161+ }
162+ if ( result . stdout && ! fix ) {
163+ console . log ( result . stdout )
164+ }
165+ return result . exitCode
143166 }
144- return result . exitCode
145167 }
146168 }
147169
@@ -154,7 +176,7 @@ async function runLintOnFiles(files, options = {}) {
154176}
155177
156178/**
157- * Run ESLint on all files.
179+ * Run linters on all files.
158180 */
159181async function runLintOnAll ( options = { } ) {
160182 const { fix = false , quiet = false } = options
@@ -163,49 +185,66 @@ async function runLintOnAll(options = {}) {
163185 logger . progress ( 'Linting all files' )
164186 }
165187
166- const args = [
167- 'exec' ,
168- 'eslint' ,
169- '-c' ,
170- '.config/eslint.config.mjs' ,
171- '--report-unused-disable-directives' ,
172- '--no-warn-ignored' ,
173- '--ignore-pattern' ,
174- 'build/' ,
175- '--ignore-pattern' ,
176- 'binaries/' ,
177- '--ignore-pattern' ,
178- 'dist/' ,
179- '--ignore-pattern' ,
180- 'external/' ,
181- '--ignore-pattern' ,
182- '.cache/' ,
183- '--ignore-pattern' ,
184- '.claude/' ,
185- '--ignore-pattern' ,
186- 'pkg-binaries/' ,
187- ...( fix ? [ '--fix' ] : [ ] ) ,
188- 'src/' ,
189- 'scripts/' ,
190- 'test/' ,
191- '.config/' ,
188+ const linters = [
189+ {
190+ args : [
191+ 'exec' ,
192+ 'biome' ,
193+ 'check' ,
194+ ...( fix ? [ '--write' , '--unsafe' ] : [ ] ) ,
195+ '.' ,
196+ ] ,
197+ name : 'biome' ,
198+ } ,
199+ {
200+ args : [
201+ 'exec' ,
202+ 'eslint' ,
203+ '-c' ,
204+ '.config/eslint.config.mjs' ,
205+ '--report-unused-disable-directives' ,
206+ '--no-warn-ignored' ,
207+ '--ignore-pattern' ,
208+ 'build/' ,
209+ '--ignore-pattern' ,
210+ 'binaries/' ,
211+ '--ignore-pattern' ,
212+ 'dist/' ,
213+ '--ignore-pattern' ,
214+ 'external/' ,
215+ '--ignore-pattern' ,
216+ '.cache/' ,
217+ '--ignore-pattern' ,
218+ '.claude/' ,
219+ '--ignore-pattern' ,
220+ 'pkg-binaries/' ,
221+ ...( fix ? [ '--fix' ] : [ ] ) ,
222+ 'src/' ,
223+ 'scripts/' ,
224+ 'test/' ,
225+ '.config/' ,
226+ ] ,
227+ name : 'eslint' ,
228+ } ,
192229 ]
193230
194- const result = await runCommandQuiet ( 'pnpm' , args )
231+ for ( const { args } of linters ) {
232+ const result = await runCommandQuiet ( 'pnpm' , args )
195233
196- if ( result . exitCode !== 0 ) {
197- // When fixing, non-zero exit codes are normal if fixes were applied
198- if ( ! fix || ( result . stderr && result . stderr . trim ( ) . length > 0 ) ) {
199- if ( ! quiet ) {
200- logger . error ( 'Linting failed' )
201- }
202- if ( result . stderr ) {
203- console . error ( result . stderr )
204- }
205- if ( result . stdout && ! fix ) {
206- console . log ( result . stdout )
234+ if ( result . exitCode !== 0 ) {
235+ // When fixing, non-zero exit codes are normal if fixes were applied.
236+ if ( ! fix || ( result . stderr && result . stderr . trim ( ) . length > 0 ) ) {
237+ if ( ! quiet ) {
238+ logger . error ( 'Linting failed' )
239+ }
240+ if ( result . stderr ) {
241+ console . error ( result . stderr )
242+ }
243+ if ( result . stdout && ! fix ) {
244+ console . log ( result . stdout )
245+ }
246+ return result . exitCode
207247 }
208- return result . exitCode
209248 }
210249 }
211250
0 commit comments