jsx-loc-plugin 0.2.20 → 0.2.22

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.
@@ -74,10 +74,11 @@ function shouldSkipElement(elementName) {
74
74
  if (!elementName) return true;
75
75
  return SKIP_ELEMENTS.has(elementName);
76
76
  }
77
- function hasDataLocAttribute(node) {
77
+ var DATA_ATTR = "data-loc";
78
+ function hasDataAttribute(node) {
78
79
  if (!node.attributes) return false;
79
80
  return node.attributes.some(
80
- (attr) => attr.type === "JSXAttribute" && attr.name?.type === "JSXIdentifier" && attr.name.name === "data-loc"
81
+ (attr) => attr.type === "JSXAttribute" && attr.name?.type === "JSXIdentifier" && attr.name.name === DATA_ATTR
81
82
  );
82
83
  }
83
84
  function findInsertionPoint(node, source) {
@@ -123,14 +124,14 @@ function transformJsxCode(source, filePath, options = {}) {
123
124
  if (!node || typeof node !== "object") return;
124
125
  if (node.type === "JSXOpeningElement") {
125
126
  const elementName = getElementName(node);
126
- if (!shouldSkipElement(elementName) && !hasDataLocAttribute(node)) {
127
+ if (!shouldSkipElement(elementName) && !hasDataAttribute(node)) {
127
128
  const loc = node.loc;
128
129
  if (loc && loc.start) {
129
130
  const line = loc.start.line;
130
131
  const column = loc.start.column;
131
132
  const locValue = `${normalizedPath}:${line}:${column}`;
132
133
  const insertPos = findInsertionPoint(node, source);
133
- magicString.appendLeft(insertPos, ` data-loc="${locValue}"`);
134
+ magicString.appendLeft(insertPos, ` ${DATA_ATTR}="${locValue}"`);
134
135
  hasChanges = true;
135
136
  }
136
137
  }
package/dist/loader.cjs CHANGED
@@ -110,10 +110,11 @@ function shouldSkipElement(elementName) {
110
110
  if (!elementName) return true;
111
111
  return SKIP_ELEMENTS.has(elementName);
112
112
  }
113
- function hasDataLocAttribute(node) {
113
+ var DATA_ATTR = "data-loc";
114
+ function hasDataAttribute(node) {
114
115
  if (!node.attributes) return false;
115
116
  return node.attributes.some(
116
- (attr) => attr.type === "JSXAttribute" && attr.name?.type === "JSXIdentifier" && attr.name.name === "data-loc"
117
+ (attr) => attr.type === "JSXAttribute" && attr.name?.type === "JSXIdentifier" && attr.name.name === DATA_ATTR
117
118
  );
118
119
  }
119
120
  function findInsertionPoint(node, source) {
@@ -159,14 +160,14 @@ function transformJsxCode(source, filePath, options = {}) {
159
160
  if (!node || typeof node !== "object") return;
160
161
  if (node.type === "JSXOpeningElement") {
161
162
  const elementName = getElementName(node);
162
- if (!shouldSkipElement(elementName) && !hasDataLocAttribute(node)) {
163
+ if (!shouldSkipElement(elementName) && !hasDataAttribute(node)) {
163
164
  const loc = node.loc;
164
165
  if (loc && loc.start) {
165
166
  const line = loc.start.line;
166
167
  const column = loc.start.column;
167
168
  const locValue = `${normalizedPath}:${line}:${column}`;
168
169
  const insertPos = findInsertionPoint(node, source);
169
- magicString.appendLeft(insertPos, ` data-loc="${locValue}"`);
170
+ magicString.appendLeft(insertPos, ` ${DATA_ATTR}="${locValue}"`);
170
171
  hasChanges = true;
171
172
  }
172
173
  }
package/dist/loader.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  shouldProcessFile,
3
3
  transformJsxCode
4
- } from "./chunk-QPTFKQPZ.js";
4
+ } from "./chunk-QKGIN5XY.js";
5
5
 
6
6
  // src/loader.ts
7
7
  import fs from "fs";
package/dist/vite.cjs CHANGED
@@ -111,10 +111,11 @@ function shouldSkipElement(elementName) {
111
111
  if (!elementName) return true;
112
112
  return SKIP_ELEMENTS.has(elementName);
113
113
  }
114
- function hasDataLocAttribute(node) {
114
+ var DATA_ATTR = "data-loc";
115
+ function hasDataAttribute(node) {
115
116
  if (!node.attributes) return false;
116
117
  return node.attributes.some(
117
- (attr) => attr.type === "JSXAttribute" && attr.name?.type === "JSXIdentifier" && attr.name.name === "data-loc"
118
+ (attr) => attr.type === "JSXAttribute" && attr.name?.type === "JSXIdentifier" && attr.name.name === DATA_ATTR
118
119
  );
119
120
  }
120
121
  function findInsertionPoint(node, source) {
@@ -160,14 +161,14 @@ function transformJsxCode(source, filePath, options = {}) {
160
161
  if (!node || typeof node !== "object") return;
161
162
  if (node.type === "JSXOpeningElement") {
162
163
  const elementName = getElementName(node);
163
- if (!shouldSkipElement(elementName) && !hasDataLocAttribute(node)) {
164
+ if (!shouldSkipElement(elementName) && !hasDataAttribute(node)) {
164
165
  const loc = node.loc;
165
166
  if (loc && loc.start) {
166
167
  const line = loc.start.line;
167
168
  const column = loc.start.column;
168
169
  const locValue = `${normalizedPath}:${line}:${column}`;
169
170
  const insertPos = findInsertionPoint(node, source);
170
- magicString.appendLeft(insertPos, ` data-loc="${locValue}"`);
171
+ magicString.appendLeft(insertPos, ` ${DATA_ATTR}="${locValue}"`);
171
172
  hasChanges = true;
172
173
  }
173
174
  }
package/dist/vite.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  shouldProcessFile,
3
3
  transformJsxCode
4
- } from "./chunk-QPTFKQPZ.js";
4
+ } from "./chunk-QKGIN5XY.js";
5
5
 
6
6
  // src/vite.ts
7
7
  function stripQuery(id) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jsx-loc-plugin",
3
- "version": "0.2.20",
3
+ "version": "0.2.22",
4
4
  "description": "Next.js plugin that adds data-loc attributes to JSX elements for UILint inspection",
5
5
  "author": "Peter Suggate",
6
6
  "license": "MIT",