@diegovelasquezweb/a11y-engine 0.11.41 → 0.11.42

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.
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@diegovelasquezweb/a11y-engine",
3
- "version": "0.11.41",
3
+ "version": "0.11.42",
4
4
  "description": "WCAG 2.2 accessibility audit engine — scanner, analyzer, and report builders",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -32,9 +32,6 @@
32
32
  "CHANGELOG.md",
33
33
  "LICENSE"
34
34
  ],
35
- "scripts": {
36
- "test": "vitest run"
37
- },
38
35
  "dependencies": {
39
36
  "@axe-core/playwright": "^4.11.1",
40
37
  "axe-core": "^4.11.1",
@@ -44,5 +41,7 @@
44
41
  "devDependencies": {
45
42
  "vitest": "^4.0.18"
46
43
  },
47
- "packageManager": "pnpm@10.22.0+sha512.bf049efe995b28f527fd2b41ae0474ce29186f7edcb3bf545087bd61fbbebb2bf75362d1307fda09c2d288e1e499787ac12d4fcb617a974718a6051f2eee741c"
48
- }
44
+ "scripts": {
45
+ "test": "vitest run"
46
+ }
47
+ }
File without changes
@@ -157,14 +157,28 @@ function buildPatternAiInput({ finding, candidate, projectHints }) {
157
157
  const originalLine = typeof finding.line === "number" ? finding.line : null;
158
158
  const rawMatch = typeof finding.match === "string" ? finding.match.trim() : "";
159
159
 
160
+ // rawMatch is often just the regex prefix (e.g. 'placeholder="') and is not unique
161
+ // when multiple elements match the same pattern in the same file.
162
+ // Use finding.context to build a more specific anchor so sequential fixes on the
163
+ // same file don't end up targeting an already-patched sibling element.
164
+ const contextLines = typeof finding.context === "string"
165
+ ? finding.context.split("\n").map((l) => l.trim()).filter(Boolean)
166
+ : [];
167
+ const matchPrefix = rawMatch.slice(0, 30);
168
+ const contextAnchor = contextLines.reduce((best, line) => {
169
+ if (!matchPrefix || !line.includes(matchPrefix)) return best;
170
+ return !best || line.length > best.length ? line : best;
171
+ }, null);
172
+ const anchor = contextAnchor || matchPrefix;
173
+
160
174
  // The file may have been modified by a previous sequential fix (lines shifted).
161
- // Search for the actual current line containing the match string instead of
175
+ // Search for the actual current line containing the anchor instead of
162
176
  // relying solely on the original line number from the scan.
163
177
  let effectiveLineIndex = originalLine !== null ? originalLine - 1 : -1;
164
- if (rawMatch && effectiveLineIndex >= 0) {
178
+ if (anchor && effectiveLineIndex >= 0) {
165
179
  const lineAtOriginal = (fileLines[effectiveLineIndex] || "").trim();
166
- if (!lineAtOriginal.includes(rawMatch.slice(0, 30))) {
167
- const found = fileLines.findIndex((l) => l.trim().includes(rawMatch.slice(0, 30)));
180
+ if (!lineAtOriginal.includes(anchor)) {
181
+ const found = fileLines.findIndex((l) => l.trim().includes(anchor));
168
182
  if (found !== -1) effectiveLineIndex = found;
169
183
  }
170
184
  }
File without changes
File without changes