Skip to content

Commit 7485172

Browse files
committed
fix(lint): revive socket oxlint plugin in lib — ignore stale tree + comment regexes
The one-dir-per-rule plugin migration (cascading in) left a pre-migration flat tree at .config/fleet/oxlint-plugin/ alongside the new .config/oxlint-plugin/. The stale tree's rule sources + test fixtures contain the bad patterns each rule detects by design, self-flagging (212 false positives); ignore it via the repo overlay until the upstream migration removes it. With the plugin loading again (regjsparser now installed via the workspace fix), socket/require-regex-comment surfaced 15 genuinely-uncommented complex regexes across src/ + scripts/ + .config/ — add a part-by-part breakdown comment to each (checksum-file, paths/_internal, python/pin, checks/primordials, eco/npm/flags, rolldown.config, strings/transform, cover/type, repo/cover). Lint --all: 0 warnings / 0 errors.
1 parent 48ab372 commit 7485172

9 files changed

Lines changed: 30 additions & 1 deletion

File tree

.config/rolldown.config.mts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ for (let i = 0, { length } = entryFiles; i < length; i += 1) {
4646
const abs = entryFiles[i]!
4747
const rel = path
4848
.relative(srcPath, abs)
49+
// Strip a trailing TypeScript extension — `.ts`, `.cts`, or `.mts`.
4950
.replace(/\.(?:c|m)?ts$/, '')
5051
.split(path.sep)
5152
.join('/')
@@ -65,6 +66,8 @@ export const buildConfig: RolldownOptions = {
6566
// this is exactly what esbuild's bundle:false avoided by treating every
6667
// import as external).
6768
external: (id: string) =>
69+
// Treat any path with an `external/` segment as external: bounded by a
70+
// separator (either platform) or string start before, and a separator after.
6871
/(?:[/\\]|^)external[/\\]/.test(id) ||
6972
(!id.startsWith('.') && !path.isAbsolute(id)),
7073
input,

scripts/repo/cover.mts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,9 @@ export function displayCodeCoverage(
127127
logger.log('')
128128
}
129129

130+
// Grab vitest's v8 coverage table header: the `% Coverage report from v8`
131+
// banner, then a separator row (group 1 = the `-|` rule), the header row
132+
// (group 2), and the same separator again via backreference `\1`.
130133
const coverageHeaderMatch = mainOutput.match(
131134
/ % Coverage report from v8\n([-|]+)\n([^\n]+)\n\1/,
132135
)
@@ -198,6 +201,9 @@ export async function updateReadmeBadge(percent: number): Promise<boolean> {
198201
logger.warn(`Failed to read ${readmePath}: ${errorMessage(e)}`)
199202
return false
200203
}
204+
// Match the README shields.io coverage badge so the percentage can be
205+
// swapped: group 1 = the markdown + URL prefix up to `coverage-`, group 2 =
206+
// the current percentage, group 3 = the `%25-<color>)` suffix.
201207
const badgeRegex =
202208
/(!\[Coverage\]\(https:\/\/img\.shields\.io\/badge\/coverage-)([\d.]+)(%25-[a-z]+\))/
203209
if (!badgeRegex.test(content)) {

src/checks/primordials.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,11 +264,14 @@ export function extractPrimordialsNames(src: string): string[] {
264264
*/
265265
export function extractTsExports(src: string): string[] {
266266
const out = new Set<string>()
267+
// `export [declare] const <name>` at line start (multiline): group 1 is the
268+
// identifier (JS ident chars, can't start with a digit). `declare` optional.
267269
for (const m of src.matchAll(
268270
/^export\s+(?:declare\s+)?const\s+([A-Za-z_$][A-Za-z0-9_$]*)/gm,
269271
)) {
270272
out.add(m[1]!)
271273
}
274+
// Same as above for `export [declare] function <name>`: group 1 is the name.
272275
for (const m of src.matchAll(
273276
/^export\s+(?:declare\s+)?function\s+([A-Za-z_$][A-Za-z0-9_$]*)/gm,
274277
)) {

src/cover/type.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,9 @@ export async function getTypeCoverage(
4040
stdio: ['ignore', 'pipe', 'pipe'],
4141
})
4242

43-
// Parse output: "1234 / 5678 48.92%"
4443
const outputText = result.stdout ? result.stdout.toString() : ''
44+
// Parse type-coverage's summary line `1234 / 5678 48.92%`: group 1 =
45+
// covered count, group 2 = total count, group 3 = the percentage.
4546
const match = /(\d+) \/ (\d+) ([\d.]+)%/.exec(outputText)
4647

4748
if (!match || !match[1] || !match[2] || !match[3]) {

src/eco/npm/npm/flags.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
* ```
1717
*/
1818
export function isNpmAuditFlag(cmdArg: string): boolean {
19+
// Matches `--audit`, `--no-audit`, and either with an `=<value>` suffix.
1920
return /^--(?:no-)?audit(?:=.*)?$/.test(cmdArg)
2021
}
2122

@@ -30,6 +31,7 @@ export function isNpmAuditFlag(cmdArg: string): boolean {
3031
* ```
3132
*/
3233
export function isNpmFundFlag(cmdArg: string): boolean {
34+
// Matches `--fund`, `--no-fund`, and either with an `=<value>` suffix.
3335
return /^--(?:no-)?fund(?:=.*)?$/.test(cmdArg)
3436
}
3537

@@ -81,5 +83,6 @@ export function isNpmNodeOptionsFlag(cmdArg: string): boolean {
8183
* ```
8284
*/
8385
export function isNpmProgressFlag(cmdArg: string): boolean {
86+
// Matches `--progress`, `--no-progress`, and either with an `=<value>` suffix.
8487
return /^--(?:no-)?progress(?:=.*)?$/.test(cmdArg)
8588
}

src/external-tools/python/pin.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,9 @@ export function specDistName(spec: string): string {
266266
if (eggIdx !== -1) {
267267
return spec.slice(eggIdx + '#egg='.length)
268268
}
269+
// Pull the package name off the front of a pip requirement spec: group 1 is
270+
// the name (letters/digits/`._-`), stopping at the first version/URL operator
271+
// — `@` (PEP 508 URL/extra) or a comparator (`==`, `>=`, `<`, `!=`, `~=`).
269272
const match = /^([A-Za-z0-9._-]+)\s*(?:@|[=<>!~]=?)/.exec(spec)
270273
return match ? match[1]! : spec
271274
}

src/http-request/checksum-file.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@ import { httpRequest } from './request'
2222

2323
import type { ChecksumFile, FetchChecksumFileOptions } from './download-types'
2424

25+
// BSD `shasum -a 256` line: `SHA256 (<filename>) = <64-hex digest>`.
26+
// Group 1 = filename (anything inside the parens), group 2 = the 64-char hex.
2527
const CHECKSUM_BSD_RE = /^SHA256\s+\((.+)\)\s+=\s+([a-fA-F0-9]{64})$/
28+
// GNU `sha256sum` line: `<64-hex digest> <filename>`.
29+
// Group 1 = the 64-char hex digest, group 2 = the filename (rest of line).
2630
const CHECKSUM_GNU_RE = /^([a-fA-F0-9]{64})\s+(.+)$/
2731

2832
/**

src/paths/_internal.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ export const CHAR_UPPERCASE_Z = 90
4242
// `.toUpperCase()` would throw on Windows MSYS-style paths like `/c/foo`.
4343
// oxlint-disable-next-line socket/prefer-non-capturing-group -- both groups are read by the replace callback in paths/normalize.ts:msysDriveToNative
4444
export const msysDriveRegExp = /^\/([a-zA-Z])($|\/)/
45+
// Matches a `node_modules` path segment: bounded by a slash (either separator)
46+
// or string start before, and a slash or string end after — so it hits
47+
// `node_modules` as a whole segment, not a substring like `my_node_modules`.
4548
export const nodeModulesPathRegExp = /(?:[/\\]|^)node_modules(?:$|[/\\])/
4649
export const slashRegExp = /[/\\]/
4750

src/strings/transform.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ export function toKebabCase(str: string): string {
7070
return str
7171
}
7272
return (
73+
// camelCase→kebab boundary: group 1 = a lowercase run (optional trailing
74+
// digits), group 2 = the following uppercase letter; insert `-` between
75+
// them (`fooBar` → `foo-Bar`, later lowercased).
7376
StringPrototypeReplace(str, /([a-z]+[0-9]*)([A-Z])/g, '$1-$2')
7477
// Convert underscores to hyphens
7578
.replace(/_/g, '-')

0 commit comments

Comments
 (0)