@@ -250,15 +250,15 @@ export async function main(extraArgs = process.argv.slice(2), runtimeEnv = proce
250250 } )
251251 : ( ) => { } ;
252252
253- const shards = createOxlintShards ( {
254- cwd : process . cwd ( ) ,
255- env,
256- platform : process . platform ,
257- splitCore : shardArgs . splitCore ,
258- } ) ;
259- const selectedShards = filterOxlintShards ( shards , shardArgs . only ) ;
260-
261253 try {
254+ const shards = createOxlintShards ( {
255+ cwd : process . cwd ( ) ,
256+ env,
257+ platform : process . platform ,
258+ splitCore : shardArgs . splitCore ,
259+ } ) ;
260+ const selectedShards = filterOxlintShards ( shards , shardArgs . only ) ;
261+
262262 ensureRepoToolNodeModulesLink ( resolveRepoToolBinPath ( "oxlint" ) ) ;
263263 const prepareResult = spawnSync (
264264 process . execPath ,
@@ -331,20 +331,12 @@ export function parseShardRunnerArgs(args) {
331331 continue ;
332332 }
333333 if ( arg === "--only" ) {
334- const value = args [ index + 1 ] ;
335- if ( ! value || value . startsWith ( "-" ) ) {
336- throw new Error ( "--only requires a shard name" ) ;
337- }
338- only . add ( value ) ;
334+ only . add ( requireShardSelector ( args [ index + 1 ] ) ) ;
339335 index += 1 ;
340336 continue ;
341337 }
342338 if ( arg . startsWith ( "--only=" ) ) {
343- const value = arg . slice ( "--only=" . length ) ;
344- if ( ! value ) {
345- throw new Error ( "--only requires a shard name" ) ;
346- }
347- only . add ( value ) ;
339+ only . add ( requireShardSelector ( arg . slice ( "--only=" . length ) ) ) ;
348340 continue ;
349341 }
350342 oxlintArgs . push ( arg ) ;
@@ -354,14 +346,37 @@ export function parseShardRunnerArgs(args) {
354346}
355347
356348/**
357- * Filters shards by an optional comma-separated shard name list .
349+ * Filters shards by optional shard names and rejects unknown selectors .
358350 */
359351export function filterOxlintShards ( shards , only ) {
360352 if ( only . size === 0 ) {
361353 return shards ;
362354 }
363355
364- return shards . filter ( ( shard ) => only . has ( shard . name ) || only . has ( shard . name . split ( ":" ) [ 0 ] ) ) ;
356+ const selectors = [ ...only ] ;
357+ const unknownSelectors = selectors . filter (
358+ ( selector ) => ! shards . some ( ( shard ) => matchesShardSelector ( shard , selector ) ) ,
359+ ) ;
360+ if ( unknownSelectors . length > 0 ) {
361+ throw new Error (
362+ `Unknown oxlint shard selector${ unknownSelectors . length === 1 ? "" : "s" } : ${ unknownSelectors . join ( ", " ) } ` ,
363+ ) ;
364+ }
365+
366+ return shards . filter ( ( shard ) =>
367+ selectors . some ( ( selector ) => matchesShardSelector ( shard , selector ) ) ,
368+ ) ;
369+ }
370+
371+ function requireShardSelector ( value ) {
372+ if ( ! value || value . startsWith ( "-" ) ) {
373+ throw new Error ( "--only requires a shard name" ) ;
374+ }
375+ return value ;
376+ }
377+
378+ function matchesShardSelector ( shard , selector ) {
379+ return selector === shard . name || selector === shard . name . split ( ":" ) [ 0 ] ;
365380}
366381
367382/**
0 commit comments