88 readFileSync ,
99} from 'fs' ;
1010import defaultsDeep from 'lodash.defaultsdeep' ;
11+ import {
12+ parseArgs ,
13+ } from 'node:util' ;
1114import {
1215 join ,
1316} from 'path' ;
@@ -31,7 +34,33 @@ const main = async () => {
3134 throw new Error ( 'TypeScript guard' ) ;
3235 }
3336
34- for ( const ruleName of process . env . npm_config_rule ? process . env . npm_config_rule . split ( ',' ) : ruleNames ) {
37+ /**
38+ * @satisfies {import('node:util').ParseArgsOptionsConfig }
39+ */
40+ const options = {
41+ invalid : {
42+ type : 'string' ,
43+ } ,
44+ rule : {
45+ type : 'string' ,
46+ } ,
47+ valid : {
48+ type : 'string' ,
49+ } ,
50+ } ;
51+
52+ const {
53+ values : {
54+ invalid,
55+ rule : rules ,
56+ valid,
57+ } ,
58+ } = parseArgs ( {
59+ allowPositionals : true ,
60+ options,
61+ } ) ;
62+
63+ for ( const ruleName of rules ? rules . split ( / [ , ] / v) : ruleNames ) {
3564 if ( semver . gte ( ESLint . version , '8.0.0' ) && ruleName === 'check-examples' ) {
3665 // Uses the processor instead for higher versions
3766 continue ;
@@ -124,24 +153,24 @@ const main = async () => {
124153 return assertion ;
125154 } ) ;
126155
127- if ( process . env . npm_config_invalid ) {
128- const indexes = process . env . npm_config_invalid . split ( ',' ) ;
156+ if ( invalid ) {
157+ const indexes = invalid . split ( / [ , ] / v ) ;
129158 assertions . invalid = assertions . invalid . filter ( ( _assertion , idx ) => {
130159 return indexes . includes ( String ( idx ) ) ||
131160 indexes . includes ( String ( idx - assertions . invalid . length ) ) ;
132161 } ) ;
133- if ( ! process . env . npm_config_valid ) {
162+ if ( ! valid ) {
134163 assertions . valid = [ ] ;
135164 }
136165 }
137166
138- if ( process . env . npm_config_valid ) {
139- const indexes = process . env . npm_config_valid . split ( ',' ) ;
167+ if ( valid ) {
168+ const indexes = valid . split ( / [ , ] / v ) ;
140169 assertions . valid = assertions . valid . filter ( ( _assertion , idx ) => {
141170 return indexes . includes ( String ( idx ) ) ||
142171 indexes . includes ( String ( idx - assertions . valid . length ) ) ;
143172 } ) ;
144- if ( ! process . env . npm_config_invalid ) {
173+ if ( ! invalid ) {
145174 assertions . invalid = [ ] ;
146175 }
147176 }
0 commit comments