55 * so a config/dep that slipped in before the hook existed (or via
66 * --no-verify) is caught at `check --all` time. The hook is the edit-time
77 * block; this is the committed-state gate;
8- * `socket/no-eslint-biome-config-ref` reports source refs. Fails (exit 1) on:
8+ * `socket/no-eslint-biome-config-ref` reports source refs. Fails (exit 1) on
99 * a tracked biome.json(c) / .eslintrc* / eslint.config.* / .prettierrc* /
10- * prettier.config.* / .dprint.json* config, or a tracked package.json with
11- * @biomejs /biome / eslint / @eslint /* / @typescript -eslint/* / prettier /
12- * dprint / rome (+ the eslint-config-* / eslint-plugin-* / prettier-plugin-*
13- * / @<scope>/eslint-* families) in any dependency block. EXEMPT: vendored
14- * upstream trees (upstream/, vendor/, third_party/, external/, a path segment
15- * ending `-upstream`). We never touch upstream files.
10+ * prettier.config.* / .dprint.json* config, or a tracked package.json
11+ * declaring any of the biome / eslint / @eslint/* / @typescript-eslint/* /
12+ * prettier / dprint / rome packages (plus the eslint-config-* /
13+ * eslint-plugin-* / prettier-plugin-* / @scope/eslint-* families) in any
14+ * dependency block. EXEMPT: vendored upstream trees (upstream/, vendor/,
15+ * third_party/, external/, a path segment ending in -upstream). We never
16+ * touch upstream files.
1617 */
1718
1819import { readFileSync } from 'node:fs'
@@ -26,23 +27,36 @@ import { REPO_ROOT } from '../paths.mts'
2627
2728const logger = getDefaultLogger ( )
2829
30+ // Foreign linter/formatter CONFIG filenames, alternation sorted per
31+ // socket/sort-regex-alternations: dprint config, eslintrc (any ext),
32+ // prettierrc (any ext), biome json(c), eslint flat config (.[cm]?[jt]s),
33+ // prettier config (.[cm]?[jt]s).
2934const CONFIG_FILE_RE =
30- / ^ (?: b i o m e \. j s o n c ? | \. e s l i n t r c (?: \. [ a - z ] + ) ? | e s l i n t \. c o n f i g \. [ c m ] ? [ j t ] s | \. p r e t t i e r r c (?: \. [ a - z ] + ) ? | p r e t t i e r \. c o n f i g \. [ c m ] ? [ j t ] s | \. d p r i n t \. j s o n c ? ) $ /
35+ / ^ (?: \. d p r i n t \. j s o n c ? | \. e s l i n t r c (?: \. [ a - z ] + ) ? | \. p r e t t i e r r c (?: \. [ a - z ] + ) ? | b i o m e \. j s o n c ? | e s l i n t \. c o n f i g \. [ c m ] ? [ j t ] s | p r e t t i e r \. c o n f i g \. [ c m ] ? [ j t ] s ) $ /
3136
3237function isForeignToolPackage ( name : string ) : boolean {
38+ // This is the DETECTOR for foreign linter/formatter deps, so it must name
39+ // them; socket/no-eslint-biome-config-ref (which flags those very strings) is
40+ // disabled per-line here — these aren't stale refs, they're the patterns the
41+ // check matches against. Operands sorted per socket/sort-equality-disjunctions.
3342 if (
43+ // oxlint-disable-next-line socket/no-eslint-biome-config-ref -- detector literal, not a stale ref
3444 name === '@biomejs/biome' ||
45+ name === 'dprint' ||
46+ // oxlint-disable-next-line socket/no-eslint-biome-config-ref -- detector literal, not a stale ref
3547 name === 'eslint' ||
3648 name === 'prettier' ||
37- name === 'dprint' ||
3849 name === 'rome'
3950 ) {
4051 return true
4152 }
4253 return (
54+ // oxlint-disable-next-line socket/no-eslint-biome-config-ref -- detector prefix, not a stale ref
4355 name . startsWith ( '@eslint/' ) ||
4456 name . startsWith ( '@typescript-eslint/' ) ||
57+ // oxlint-disable-next-line socket/no-eslint-biome-config-ref -- detector prefix, not a stale ref
4558 name . startsWith ( 'eslint-config-' ) ||
59+ // oxlint-disable-next-line socket/no-eslint-biome-config-ref -- detector prefix, not a stale ref
4660 name . startsWith ( 'eslint-plugin-' ) ||
4761 name . startsWith ( 'prettier-plugin-' ) ||
4862 / ^ @ [ ^ / ] + \/ e s l i n t - / . test ( name )
@@ -52,7 +66,10 @@ function isForeignToolPackage(name: string): boolean {
5266export function isVendoredUpstream ( relPath : string ) : boolean {
5367 const p = relPath . replace ( / \\ / g, '/' )
5468 return (
55- / (?: ^ | \/ ) (?: u p s t r e a m | v e n d o r | t h i r d _ p a r t y | e x t e r n a l ) (?: \/ | $ ) / . test ( p ) ||
69+ // A path segment that is exactly a vendored-tree dir name (start-of-string
70+ // or after a `/`, then `/` or end-of-string). Alternation sorted.
71+ / (?: ^ | \/ ) (?: e x t e r n a l | t h i r d _ p a r t y | u p s t r e a m | v e n d o r ) (?: \/ | $ ) / . test ( p ) ||
72+ // …or a segment ending in `-upstream` (e.g. `acme-upstream/`).
5673 / (?: ^ | \/ ) [ ^ / ] + - u p s t r e a m (?: \/ | $ ) / . test ( p )
5774 )
5875}
@@ -112,7 +129,9 @@ function main(): void {
112129 }
113130 const found = foreignToolDeps ( text )
114131 if ( found . length ) {
115- failures . push ( `${ rel } : foreign tool dep(s) ${ found . sort ( ) . join ( ', ' ) } ` )
132+ failures . push (
133+ `${ rel } : foreign tool dep(s) ${ found . toSorted ( ) . join ( ', ' ) } ` ,
134+ )
116135 }
117136 }
118137 }
0 commit comments