Skip to content

Commit 5b0e31c

Browse files
Fix cert bind mount: detect WSL2 and use /tmp elsewhere for staging
Root cause: MSYS2 (Git Bash) cannot resolve 8.3 shortname directories (e.g. FRANCO~1.MOR) via its POSIX layer, so touch/cp would fail when cygpath converted Windows TEMP to /c/Users/FRANCO~1.MOR/.... Key insight: in Git Bash, /tmp is MSYS2's mapping of Windows TEMP itself, so writing to /tmp already creates the file at the Windows TEMP path that Docker Desktop uses for the bind mount source. New logic: - WSL2 (/proc/version contains "microsoft"): wslpath converts Windows TEMP to /mnt/c/... so the file is written to the Windows filesystem - Git Bash + Linux/macOS: write directly to /tmp (Git Bash maps this to Windows TEMP; Linux/macOS /tmp is Docker-accessible directly) Also make postCreateCommand skip the cert file if it is a directory (defensive against any future bind mount failure). Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
1 parent 07af81d commit 5b0e31c

File tree

4 files changed

+40
-26
lines changed

4 files changed

+40
-26
lines changed

.claude/rules.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,27 @@ export const rule: Rule.RuleModule = {
5252
},
5353
};
5454
```
55+
56+
## Testing
57+
58+
### RuleTesters
59+
60+
| RuleTester | Use When |
61+
| -------------------------- | ------------------------------------------- |
62+
| `DefaultParserRuleTester` | Pure JavaScript rules, no TS syntax |
63+
| `NoTypeCheckingRuleTester` | JS/TS rules that don't need type info |
64+
| `RuleTester` | Rules requiring TypeScript type information |
65+
66+
### Running Tests
67+
68+
```bash
69+
npx tsx --test packages/jsts/src/rules/S1234/**/*.test.ts
70+
```
71+
72+
## Shared Helpers
73+
74+
Check `packages/jsts/src/rules/helpers/` before writing utilities:
75+
76+
- `ast.ts` - AST traversal and node type checking
77+
- `module.ts` - Module detection, `getFullyQualifiedName`
78+
- `package-jsons/dependencies.ts` - Dependency detection

.claude/skills/build/SKILL.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ description: Build pipeline for SonarJS. Use when asked to build the project, re
66
## Quick Reference
77

88
```bash
9+
npm ci # Install dependencies
910
npm run bbf # Fast JS/TS build (no tests): clear lib + generate-meta + compile
1011
npm run generate-meta # Regenerate generated-meta.ts files from RSPEC JSON
1112
npm run generate-java-rule-classes # Regenerate Java check classes

.claude/skills/ruling/SKILL.md

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,17 @@ disable-model-invocation: true
66

77
## Overview
88

9-
Ruling tests analyze large third-party codebases and compare issues against expected output. Run them when adding or modifying rules to verify real-world behavior.
9+
Ruling tests analyze large third-party codebases (JS/TS and CSS) and compare issues against expected output. Run them when adding or modifying rules to verify real-world behavior.
1010

1111
> **Warning:** Running ruling tests removes `node_modules` from the project root. Run `npm ci` afterward.
1212
13-
## JS/TS Ruling
13+
## Running Ruling
1414

1515
```bash
1616
# Prerequisite: rebuild the jar first
1717
mvn install -DskipTests
1818

19-
# Run ruling
19+
# Run ruling (JS/TS and CSS)
2020
npm run ruling
2121

2222
# Sync actual → expected (after reviewing output)
@@ -28,43 +28,31 @@ sh tools/ruling-debug-script.sh
2828

2929
Results:
3030
- Actual: `packages/ruling/actual/`
31-
- Expected: `its/ruling/src/test/resources/expected/`
31+
- Expected: `its/ruling/src/test/expected/`
3232

33-
## CSS Ruling
33+
## Java Ruling (Old Way)
3434

3535
```bash
3636
cd its/ruling
37-
mvn verify -Dtest=CssRulingTest -Dmaven.test.redirectTestOutputToFile=false
38-
```
39-
40-
Then copy actual to expected:
41-
```bash
42-
cp -R target/actual/css/ src/test/expected/css
43-
```
44-
45-
## Old JS/TS Way (Maven)
46-
47-
```bash
48-
cd its/ruling
49-
mvn verify -Dtest=JsTsRulingTest -Dmaven.test.redirectTestOutputToFile=false
37+
mvn verify -Dtest=RulingTest -Dmaven.test.redirectTestOutputToFile=false
5038
```
5139

5240
Copy actual to expected:
5341
```bash
54-
cp -R target/actual/jsts/ src/test/expected/jsts
42+
cp -R target/actual/ src/test/expected/
5543
```
5644

5745
Review diff:
5846
```bash
59-
diff -rq src/test/expected/jsts target/actual/jsts
47+
diff -rq src/test/expected target/actual
6048
```
6149

6250
## Custom Source Files for New Rules
6351

6452
If a new rule raises no issues on existing sources, add test code:
6553

66-
- `its/sources/jsts/custom/S1234.js` — regular code
67-
- `its/sources/jsts/custom/tests/S1234.js` — test code
54+
- `its/sources/custom/jsts/S1234.js` — regular code
55+
- `its/sources/custom/jsts/tests/S1234.js` — test code
6856

6957
Copy from RSPEC HTML description (compliant/non-compliant examples).
7058

.devcontainer/devcontainer.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,13 @@
1717
"remoteUser": "node",
1818
// initializeCommand runs on the host before container creation (before the repo is cloned).
1919
// It stages the corporate CA cert and ~/.npmrc so Docker can bind-mount them.
20-
// On Windows (TEMP starts with a drive letter): uses cmd.exe, which resolves 8.3 shortnames
21-
// natively via %TEMP% — avoiding the MSYS2 limitation that blocks cygpath-converted paths.
22-
// On Linux/macOS (TEMP is a Unix path or unset): uses bash directly with /tmp.
20+
// On WSL2: /tmp is the distro's /tmp (not accessible to Docker Desktop), so wslpath converts
21+
// Windows TEMP to a /mnt/c/... path that Docker Desktop can reach.
22+
// On Git Bash: /tmp is MSYS2's mapping of Windows TEMP — no conversion needed.
23+
// On Linux/macOS: /tmp is directly accessible to Docker.
2324
"initializeCommand": [
2425
"bash", "-c",
25-
"T='${localEnv:TEMP:/tmp}'; if [[ \"$T\" != /* ]]; then cmd.exe /c \"(if defined NODE_EXTRA_CA_CERTS (copy /Y \\\"%NODE_EXTRA_CA_CERTS%\\\" \\\"%TEMP%\\dc-cert.crt\\\") else (type nul >\\\"%TEMP%\\dc-cert.crt\\\")) & (if exist \\\"%USERPROFILE%\\.npmrc\\\" (copy /Y \\\"%USERPROFILE%\\.npmrc\\\" \\\"%TEMP%\\dc-npmrc\\\") else (type nul >\\\"%TEMP%\\dc-npmrc\\\"))\"; else (cp \"${NODE_EXTRA_CA_CERTS:-}\" \"$T/dc-cert.crt\" 2>/dev/null || touch \"$T/dc-cert.crt\") && (cp ~/.npmrc \"$T/dc-npmrc\" 2>/dev/null || touch \"$T/dc-npmrc\"); fi"
26+
"if grep -qi microsoft /proc/version 2>/dev/null; then STAGING=$(wslpath -u '${localEnv:TEMP:/tmp}' 2>/dev/null || echo /tmp); else STAGING=/tmp; fi && (cp \"${NODE_EXTRA_CA_CERTS:-}\" \"$STAGING/dc-cert.crt\" 2>/dev/null || touch \"$STAGING/dc-cert.crt\") && (cp ~/.npmrc \"$STAGING/dc-npmrc\" 2>/dev/null || touch \"$STAGING/dc-npmrc\")"
2627
],
2728
"mounts": [
2829
"source=${localEnv:TEMP:/tmp}/dc-cert.crt,target=/tmp/corporate-ca.crt,type=bind,consistency=cached,readonly",

0 commit comments

Comments
 (0)