stylelint-plugin-rhythmguard 3.20.0 → 3.20.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -6,6 +6,12 @@ The format follows Keep a Changelog principles and semantic versioning.
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [3.20.1] - 2026-11-16
10
+
11
+ ### Fixed
12
+
13
+ - Windows: `rhythmguard audit --staged` and `--since` found no files when the project path held an 8.3 short name (`C:\Users\RUNNER~1\...`, the form Windows gives temporary directories), because git prints the long form; baseline keys from such a path climbed out of the repository. Paths are now compared after `fs.realpathSync.native`. `prefer-token` names a token's file with `/` (`src/tokens.css`), and `init --agents` prints the files it wrote with `/`. The suite now passes on Windows: 777 tests, none failing (#174).
14
+
9
15
  ## [3.20.0] - 2026-11-11
10
16
 
11
17
  ### Changed
package/README.md CHANGED
@@ -7,7 +7,7 @@
7
7
  Nobody chose 13px. Rhythmguard catches off-scale spacing in CSS and Tailwind class strings, tells you the nearest steps on your scale, and snaps to them or to your tokens when you ask.
8
8
 
9
9
  [![CI](https://img.shields.io/github/actions/workflow/status/petrilahdelma/stylelint-plugin-rhythmguard/ci.yml?branch=main&label=ci)](https://github.com/petrilahdelma/stylelint-plugin-rhythmguard/actions/workflows/ci.yml)
10
- [![npm version](https://img.shields.io/npm/v/stylelint-plugin-rhythmguard?label=npm&color=1f6feb&r=3200)](https://www.npmjs.com/package/stylelint-plugin-rhythmguard)
10
+ [![npm version](https://img.shields.io/npm/v/stylelint-plugin-rhythmguard?label=npm&color=1f6feb&r=3201)](https://www.npmjs.com/package/stylelint-plugin-rhythmguard)
11
11
  [![npm downloads](https://img.shields.io/npm/dm/stylelint-plugin-rhythmguard.svg)](https://www.npmjs.com/package/stylelint-plugin-rhythmguard)
12
12
  [![License: MIT](https://img.shields.io/badge/license-MIT-white.svg)](./LICENSE)
13
13
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "stylelint-plugin-rhythmguard",
3
- "version": "3.20.0",
3
+ "version": "3.20.1",
4
4
  "description": "Nobody chose 13px. Catches off-scale spacing in CSS and Tailwind class strings and snaps it to your scale or tokens. Stylelint rules, an ESLint companion, and an audit CLI.",
5
5
  "bin": {
6
6
  "rhythmguard": "src/cli/index.js"
@@ -34,7 +34,7 @@ function createBaselineScope(report, scope = {}) {
34
34
  const scanRoot = path.resolve(scope.scanRoot || report.directory || '.');
35
35
  let realScanRoot = scanRoot;
36
36
  try {
37
- realScanRoot = fs.realpathSync(scanRoot);
37
+ realScanRoot = fs.realpathSync.native(scanRoot);
38
38
  } catch {
39
39
  // The directory was audited, so it exists; keep the given form if not.
40
40
  }
@@ -143,7 +143,7 @@ function runCodemod({ baseFontSize = 16, dir, ignorePatterns = [], includeNonAut
143
143
  const skipped = walked.linksOutsideRoot
144
144
  .filter((link) => !isTemplateFile(link))
145
145
  .map((link) => ({ file: formatPath(path.join(rootDir, link)), reason: 'symbolic link to a path outside the directory; not followed' }));
146
- const realRoot = fs.realpathSync(rootDir);
146
+ const realRoot = fs.realpathSync.native(rootDir);
147
147
  const rewritten = new Set();
148
148
  let nonAuthoredSkipped = 0;
149
149
  for (const filePath of files) {
@@ -200,7 +200,7 @@ function writableRealPath(filePath, rootDir, realRoot) {
200
200
  if (fs.lstatSync(filePath).isSymbolicLink()) {
201
201
  return null;
202
202
  }
203
- realPath = fs.realpathSync(filePath);
203
+ realPath = fs.realpathSync.native(filePath);
204
204
  } catch {
205
205
  // A path that cannot be resolved is not a file to rewrite.
206
206
  return null;
@@ -122,7 +122,9 @@ function preferPath(candidate, current) {
122
122
 
123
123
  function realPathOf(filePath) {
124
124
  try {
125
- return fs.realpathSync(filePath);
125
+ // The native call expands Windows 8.3 short names (C:\Users\RUNNER~1),
126
+ // which git never prints; the JS one does not, and nothing then matched (#174).
127
+ return fs.realpathSync.native(filePath);
126
128
  } catch {
127
129
  // A path that cannot be resolved has no real path.
128
130
  return null;
@@ -145,14 +147,15 @@ function getScanFiles(rootDir, ignorePatterns, parsed) {
145
147
  function getGitChangedScanFiles(rootDir, ignorePatterns, parsed) {
146
148
  // Git runs in the scanned directory, so the repository is the one that holds
147
149
  // the files, whichever directory the command was started from.
148
- const topLevel = runGit(rootDir, ['rev-parse', '--show-toplevel']).replace(/\r?\n$/, '');
150
+ const gitTopLevel = path.resolve(runGit(rootDir, ['rev-parse', '--show-toplevel']).replace(/\r?\n$/, ''));
151
+ const topLevel = realPathOf(gitTopLevel) || gitTopLevel;
149
152
  const changed = parsed.staged
150
153
  ? listStagedFiles(rootDir)
151
154
  : listFilesChangedSince(rootDir, parsed.since);
152
155
 
153
156
  // git reports the top level with symlinks resolved (/private/var on macOS);
154
157
  // compare in that form, then name files under the directory as it was given.
155
- const realRootDir = fs.realpathSync(rootDir);
158
+ const realRootDir = fs.realpathSync.native(rootDir);
156
159
  const ignoreMatchers = createIgnoreMatchers(ignorePatterns);
157
160
  const seen = new Set();
158
161
  const found = [];
@@ -189,7 +192,8 @@ function getGitChangedScanFiles(rootDir, ignorePatterns, parsed) {
189
192
  }
190
193
 
191
194
  seen.add(fullPath);
192
- const fileRealPath = realPathOf(fullPath) || fullPath;
195
+ // A staged file gone from the working tree has no real path on disk; git's own path is the real form.
196
+ const fileRealPath = realPathOf(fullPath) || realPath;
193
197
  // A link that resolves outside the scanned directory is not followed (#289).
194
198
  if (!isPathInside(realRootDir, fileRealPath)) {
195
199
  linksOutsideRoot.push(relativePath);
@@ -353,7 +357,7 @@ function findGitTopLevel(dir) {
353
357
  encoding: 'utf8',
354
358
  stdio: ['ignore', 'pipe', 'ignore'],
355
359
  }).replace(/\r?\n$/, '');
356
- return output ? path.resolve(output) : null;
360
+ return output ? realPathOf(path.resolve(output)) || path.resolve(output) : null;
357
361
  } catch {
358
362
  // Not a git repository, or no git: there is no repository root.
359
363
  return null;
package/src/cli/init.js CHANGED
@@ -253,7 +253,7 @@ function parseInitArgs(argv) {
253
253
  * which this command wrote and owns, is taken out to leave one copy.
254
254
  */
255
255
  function removeLegacyCopilotBlock(cwd) {
256
- const legacy = path.join('.github', 'copilot-instructions.md');
256
+ const legacy = '.github/copilot-instructions.md';
257
257
  const legacyPath = path.join(cwd, legacy);
258
258
  if (!fs.existsSync(legacyPath)) return null;
259
259
  const existing = fs.readFileSync(legacyPath, 'utf8');
@@ -289,7 +289,8 @@ function installAgents(selection, cwd = process.cwd()) {
289
289
  fs.mkdirSync(path.dirname(targetPath), { recursive: true });
290
290
 
291
291
  fs.writeFileSync(targetPath, content);
292
- written.push(target);
292
+ // Named with / on every platform, as the docs name these files (#174).
293
+ written.push(target.split(path.sep).join('/'));
293
294
  if (name === 'copilot') {
294
295
  const moved = removeLegacyCopilotBlock(cwd);
295
296
  if (moved) written.push(`${moved} (the block an older version appended there was removed)`);
@@ -48,8 +48,9 @@ function displayOrigin(file) {
48
48
  if (!file) {
49
49
  return null;
50
50
  }
51
+ // Named with / on every platform, as the audit names files (#174).
51
52
  const relative = path.relative(process.cwd(), file);
52
- return relative && !relative.startsWith('..') && !path.isAbsolute(relative) ? relative : file;
53
+ return relative && !relative.startsWith('..') && !path.isAbsolute(relative) ? relative.split(path.sep).join('/') : file;
53
54
  }
54
55
 
55
56
  /**