Skip to content
This repository was archived by the owner on Jun 25, 2026. It is now read-only.

Commit 8f924fc

Browse files
committed
Match all strings in js/ts
1 parent 075f928 commit 8f924fc

3 files changed

Lines changed: 7 additions & 11 deletions

File tree

rules/src/generic/npx-usage/npx-usage-js.yml

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,7 @@ rules:
3737
as a dependency / devDependency and invoke it using your package manager to ensure version pinning
3838
and reproducibility.
3939
patterns:
40-
- pattern-either:
41-
- pattern: "$CMD"
42-
- pattern: |
43-
`$CMD`
44-
- metavariable-pattern:
45-
metavariable: $CMD
46-
language: sh
47-
pattern: npx ...
40+
- pattern: "$STRING"
41+
- metavariable-regex:
42+
metavariable: $STRING
43+
regex: '.*\bnpx\s'

rules/test/generic/npx-usage/npx-usage-js.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ function lintCode() {
1717
}
1818

1919
// String literal in error message (like global.setup.ts:72)
20-
// This won't be caught because "Example: npx..." doesn't parse as shell command starting with npx
20+
// Now caught with regex - flags npx usage anywhere in strings including docs/examples
2121
function throwError() {
2222
throw new Error(
23-
// ok: npx-usage-js
23+
// ruleid: npx-usage-js
2424
'Please specify a project name with --project flag. Example: npx playwright test --project dummy-test-local'
2525
);
2626
}

rules/test/generic/npx-usage/npx-usage-js.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ function runPlaywrightTests(): void {
1313
// Error message with npx example
1414
function throwConfigError(): never {
1515
throw new Error(
16-
// This may or may not be caught depending on shell parsing
16+
// ruleid: npx-usage-js
1717
'Please specify a project name with --project flag. Example: npx playwright test --project dummy-test-local'
1818
);
1919
}

0 commit comments

Comments
 (0)