@noctcore/lint-meta-rules 0.6.1 → 0.6.2

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.
@@ -6,6 +6,11 @@ function baseName(pathLike) {
6
6
  const parts = pathLike.split("/").filter(Boolean);
7
7
  return parts[parts.length - 1] ?? pathLike;
8
8
  }
9
+ function stripTrailingSlashes(path) {
10
+ let end = path.length;
11
+ while (end > 0 && path[end - 1] === "/") end -= 1;
12
+ return path.slice(0, end);
13
+ }
9
14
  function escapeRegExp(value) {
10
15
  return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
11
16
  }
@@ -58,6 +63,7 @@ function readSourceText(read, rel) {
58
63
  export {
59
64
  dirOf,
60
65
  baseName,
66
+ stripTrailingSlashes,
61
67
  escapeRegExp,
62
68
  countLines,
63
69
  recursiveGlobs,
package/dist/i18n.js CHANGED
@@ -2,7 +2,7 @@ import {
2
2
  DEFAULT_SKIP_DIRS,
3
3
  escapeRegExp,
4
4
  globFiles
5
- } from "./chunk-OYFQKSJN.js";
5
+ } from "./chunk-KZ3NYHLH.js";
6
6
 
7
7
  // src/i18n/translation-dead-keys.ts
8
8
  import path from "path";
package/dist/index.cjs CHANGED
@@ -1312,7 +1312,7 @@ function createUiPrimitiveShapeRule(options = {}) {
1312
1312
  run(ctx) {
1313
1313
  const violations = [];
1314
1314
  for (const barrel of ctx.glob(`${uiRoot}/*/${barrelFile}`)) {
1315
- const dir = barrel.replace(new RegExp(`/${barrelFile}$`), "");
1315
+ const dir = dirOf(barrel, barrelFile);
1316
1316
  const name = baseName(dir);
1317
1317
  for (const role of roles) {
1318
1318
  const rel = `${dir}/${name}.${role}${extension}`;
@@ -1326,7 +1326,7 @@ function createUiPrimitiveShapeRule(options = {}) {
1326
1326
  }
1327
1327
  }
1328
1328
  for (const flat of ctx.glob(`${uiRoot}/[A-Z]*${extension}`)) {
1329
- const name = baseName(flat).replace(new RegExp(`${extension.replace(/\./g, "\\.")}$`), "");
1329
+ const name = baseName(flat).replace(new RegExp(`${escapeRegExp(extension)}$`), "");
1330
1330
  for (const role of roles) {
1331
1331
  const sibling = `${uiRoot}/${name}.${role}${extension}`;
1332
1332
  if (ctx.exists(sibling)) {
package/dist/index.js CHANGED
@@ -10,7 +10,7 @@ import {
10
10
  recursiveGlobs,
11
11
  stripYamlComment,
12
12
  unquote
13
- } from "./chunk-OYFQKSJN.js";
13
+ } from "./chunk-KZ3NYHLH.js";
14
14
 
15
15
  // src/rules/agents-doc-presence.ts
16
16
  function createAgentsDocPresenceRule(options = {}) {
@@ -1228,7 +1228,7 @@ function createUiPrimitiveShapeRule(options = {}) {
1228
1228
  run(ctx) {
1229
1229
  const violations = [];
1230
1230
  for (const barrel of ctx.glob(`${uiRoot}/*/${barrelFile}`)) {
1231
- const dir = barrel.replace(new RegExp(`/${barrelFile}$`), "");
1231
+ const dir = dirOf(barrel, barrelFile);
1232
1232
  const name = baseName(dir);
1233
1233
  for (const role of roles) {
1234
1234
  const rel = `${dir}/${name}.${role}${extension}`;
@@ -1242,7 +1242,7 @@ function createUiPrimitiveShapeRule(options = {}) {
1242
1242
  }
1243
1243
  }
1244
1244
  for (const flat of ctx.glob(`${uiRoot}/[A-Z]*${extension}`)) {
1245
- const name = baseName(flat).replace(new RegExp(`${extension.replace(/\./g, "\\.")}$`), "");
1245
+ const name = baseName(flat).replace(new RegExp(`${escapeRegExp(extension)}$`), "");
1246
1246
  for (const role of roles) {
1247
1247
  const sibling = `${uiRoot}/${name}.${role}${extension}`;
1248
1248
  if (ctx.exists(sibling)) {
package/dist/prisma.cjs CHANGED
@@ -41,6 +41,11 @@ module.exports = __toCommonJS(prisma_exports);
41
41
  var import_eslint_plugin_prisma = require("@noctcore/eslint-plugin-prisma");
42
42
 
43
43
  // src/rules/shared.ts
44
+ function stripTrailingSlashes(path2) {
45
+ let end = path2.length;
46
+ while (end > 0 && path2[end - 1] === "/") end -= 1;
47
+ return path2.slice(0, end);
48
+ }
44
49
  function globFiles(glob, globs, skipDirs = []) {
45
50
  const skip = new Set(skipDirs);
46
51
  const found = /* @__PURE__ */ new Set();
@@ -59,7 +64,21 @@ var DEFAULT_CLIENT_GLOBS = [
59
64
  "node_modules/.prisma/client/index.d.ts"
60
65
  ];
61
66
  function blankComments(source) {
62
- return source.replace(/\/\*[\s\S]*?\*\//gu, (comment) => comment.replace(/[^\n]/gu, " ")).replace(/(^|[^:])\/\/.*$/gmu, "$1");
67
+ let out = "";
68
+ let from = 0;
69
+ for (let open = source.indexOf("/*"); open !== -1; open = source.indexOf("/*", from)) {
70
+ const close = source.indexOf("*/", open + 2);
71
+ if (close === -1) break;
72
+ out += source.slice(from, open) + source.slice(open, close + 2).replace(/[^\n]/gu, " ");
73
+ from = close + 2;
74
+ }
75
+ return (out + source.slice(from)).split("\n").map(stripLineComment).join("\n");
76
+ }
77
+ function stripLineComment(line) {
78
+ for (let at = line.indexOf("//"); at !== -1; at = line.indexOf("//", at + 1)) {
79
+ if (at === 0 || line[at - 1] !== ":") return line.slice(0, at) + (line.endsWith("\r") ? "\r" : "");
80
+ }
81
+ return line;
63
82
  }
64
83
  function parseDelegateSurfaces(source, file = "") {
65
84
  const lines = blankComments(source).split("\n");
@@ -271,7 +290,7 @@ function parseObjectLiteralKeys(source, exportName) {
271
290
  return null;
272
291
  }
273
292
  function readSchema(ctx, schemaPath) {
274
- const base = schemaPath.replace(/\/+$/u, "");
293
+ const base = stripTrailingSlashes(schemaPath);
275
294
  const files = ctx.glob(`${base}/**/*.prisma`).sort();
276
295
  const texts = files.length > 0 ? files.map((file) => ctx.read(file) ?? "") : [ctx.read(base)];
277
296
  if (texts.some((text) => text === null)) return null;
package/dist/prisma.js CHANGED
@@ -4,8 +4,9 @@ import {
4
4
  severityOf
5
5
  } from "./chunk-VFCX3QKZ.js";
6
6
  import {
7
- globFiles
8
- } from "./chunk-OYFQKSJN.js";
7
+ globFiles,
8
+ stripTrailingSlashes
9
+ } from "./chunk-KZ3NYHLH.js";
9
10
 
10
11
  // src/prisma/prisma-method-surface.ts
11
12
  import { PRISMA_READ_METHODS, PRISMA_WRITE_METHODS } from "@noctcore/eslint-plugin-prisma";
@@ -15,7 +16,21 @@ var DEFAULT_CLIENT_GLOBS = [
15
16
  "node_modules/.prisma/client/index.d.ts"
16
17
  ];
17
18
  function blankComments(source) {
18
- return source.replace(/\/\*[\s\S]*?\*\//gu, (comment) => comment.replace(/[^\n]/gu, " ")).replace(/(^|[^:])\/\/.*$/gmu, "$1");
19
+ let out = "";
20
+ let from = 0;
21
+ for (let open = source.indexOf("/*"); open !== -1; open = source.indexOf("/*", from)) {
22
+ const close = source.indexOf("*/", open + 2);
23
+ if (close === -1) break;
24
+ out += source.slice(from, open) + source.slice(open, close + 2).replace(/[^\n]/gu, " ");
25
+ from = close + 2;
26
+ }
27
+ return (out + source.slice(from)).split("\n").map(stripLineComment).join("\n");
28
+ }
29
+ function stripLineComment(line) {
30
+ for (let at = line.indexOf("//"); at !== -1; at = line.indexOf("//", at + 1)) {
31
+ if (at === 0 || line[at - 1] !== ":") return line.slice(0, at) + (line.endsWith("\r") ? "\r" : "");
32
+ }
33
+ return line;
19
34
  }
20
35
  function parseDelegateSurfaces(source, file = "") {
21
36
  const lines = blankComments(source).split("\n");
@@ -186,7 +201,7 @@ function parseObjectLiteralKeys(source, exportName) {
186
201
  return null;
187
202
  }
188
203
  function readSchema(ctx, schemaPath) {
189
- const base = schemaPath.replace(/\/+$/u, "");
204
+ const base = stripTrailingSlashes(schemaPath);
190
205
  const files = ctx.glob(`${base}/**/*.prisma`).sort();
191
206
  const texts = files.length > 0 ? files.map((file) => ctx.read(file) ?? "") : [ctx.read(base)];
192
207
  if (texts.some((text) => text === null)) return null;
@@ -34,6 +34,13 @@ __export(resolved_config_exports, {
34
34
  });
35
35
  module.exports = __toCommonJS(resolved_config_exports);
36
36
 
37
+ // src/rules/shared.ts
38
+ function stripTrailingSlashes(path2) {
39
+ let end = path2.length;
40
+ while (end > 0 && path2[end - 1] === "/") end -= 1;
41
+ return path2.slice(0, end);
42
+ }
43
+
37
44
  // src/resolved-config/resolve.ts
38
45
  var import_node_fs = require("fs");
39
46
  var import_node_path = __toESM(require("path"), 1);
@@ -84,7 +91,7 @@ var DEFAULT_PROBES = [
84
91
  function findConfigDirs(ctx, packages, configFiles) {
85
92
  const byDir = /* @__PURE__ */ new Map();
86
93
  for (const pattern of packages) {
87
- const base = pattern.replace(/\/+$/u, "");
94
+ const base = stripTrailingSlashes(pattern);
88
95
  for (const name of configFiles) {
89
96
  const matches = base === "." || base === "" ? ctx.exists(name) ? [name] : [] : ctx.glob(`${base}/${name}`);
90
97
  for (const configFile of matches) {
@@ -2,6 +2,9 @@ import {
2
2
  resolveRules,
3
3
  severityOf
4
4
  } from "./chunk-VFCX3QKZ.js";
5
+ import {
6
+ stripTrailingSlashes
7
+ } from "./chunk-KZ3NYHLH.js";
5
8
 
6
9
  // src/resolved-config/eslint-config-no-warn.ts
7
10
  var DEFAULT_ID = "eslint-config-no-warn";
@@ -16,7 +19,7 @@ var DEFAULT_PROBES = [
16
19
  function findConfigDirs(ctx, packages, configFiles) {
17
20
  const byDir = /* @__PURE__ */ new Map();
18
21
  for (const pattern of packages) {
19
- const base = pattern.replace(/\/+$/u, "");
22
+ const base = stripTrailingSlashes(pattern);
20
23
  for (const name of configFiles) {
21
24
  const matches = base === "." || base === "" ? ctx.exists(name) ? [name] : [] : ctx.glob(`${base}/${name}`);
22
25
  for (const configFile of matches) {
package/dist/session.js CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  escapeRegExp,
4
4
  globFiles,
5
5
  readSourceText
6
- } from "./chunk-OYFQKSJN.js";
6
+ } from "./chunk-KZ3NYHLH.js";
7
7
 
8
8
  // src/session/scan.ts
9
9
  var DEFAULT_EXCLUDE_SUFFIXES = [
package/dist/trpc.js CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  escapeRegExp,
4
4
  globFiles,
5
5
  readSourceText
6
- } from "./chunk-OYFQKSJN.js";
6
+ } from "./chunk-KZ3NYHLH.js";
7
7
 
8
8
  // src/trpc/idempotency-key-parity.ts
9
9
  var DEFAULT_ID = "idempotency-key-parity";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@noctcore/lint-meta-rules",
3
- "version": "0.6.1",
3
+ "version": "0.6.2",
4
4
  "description": "Portable, parameterized lint-meta rules — whole-repo / cross-file invariants ESLint cannot reach — for the @noctcore/harness lint-meta runner.",
5
5
  "license": "MIT",
6
6
  "type": "module",