@sarj/eslint-plugin 16.36.3 → 16.36.5

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/dist/index.cjs CHANGED
@@ -1928,7 +1928,7 @@ var NO_TEST_COMMENTS_DOCUMENTATION = {
1928
1928
  autofix: "safe",
1929
1929
  limitations: [
1930
1930
  "Checks actual line and block comment tokens in recognized maintained test files, including test fixtures; strings and template text remain unchanged. Generated/vendor files are excluded.",
1931
- "Legal notices, shebangs, TypeScript triple-slash references, coverage/build annotations and explicit lint/type/test/formatter directives remain allowed. Ordinary prose embedded in a directive remains the owning tool's responsibility.",
1931
+ "Legal notices, shebangs, TypeScript triple-slash references, coverage/build annotations and explicit lint/type/test/formatter directives remain allowed. Executable detect-secrets 1.5.0 allowlist/whitelist pragmas retain its case-sensitive delimiter, spacing, physical-line and next-line grammar; arbitrary pragma prose remains ordinary commentary. Rationale on an executable directive remains the owning tool's responsibility.",
1932
1932
  "The automatic fix removes comments and adjacent padding while retaining every line ending and necessary token boundary; it does not rename tests or remove executable statements. Bare integration/e2e directories and ambiguous hyphen/underscore test basenames require another concrete test-path signal or a runtime testing-framework import; ordinary production integration modules and rule implementations ending in -test are preserved."
1933
1933
  ],
1934
1934
  examples: [
@@ -1939,6 +1939,52 @@ var NO_TEST_COMMENTS_DOCUMENTATION = {
1939
1939
  var DIRECTIVE = /^(?:eslint(?:-\S+)?\b|(?:biome|oxlint|jshint|jslint|c8|v8|istanbul|vitest|prettier|dprint)\b|@(?:ts-(?:check|nocheck|expect-error|ignore)|vitest-environment|jest-environment|jsx\w*|license|preserve)\b|[#!]\s*__(?:PURE|NO_SIDE_EFFECTS)__|\/\s*<(?:reference|amd-module|amd-dependency)\b)/u;
1940
1940
  var LEGAL = /(?:^|\n)\s*\*?\s*(?:Copyright\b|SPDX-License-Identifier:|Licensed under\b|@license\b|@preserve\b)/iu;
1941
1941
  var TYPE_CONTRACT = /@(?:type|typedef|template|param|returns?|satisfies|callback|overload|implements|extends|augments|enum|this|import)\b/u;
1942
+ var DETECT_SECRETS_COMMENT_MARKERS = [
1943
+ { start: "#", end: "" },
1944
+ { start: "//", end: "" },
1945
+ { start: "/\\*", end: " *\\*/" },
1946
+ { start: "'", end: "" },
1947
+ { start: "--", end: "" },
1948
+ { start: "<!--[# \\t]*?", end: " *?-->" }
1949
+ ];
1950
+ var DETECT_SECRETS_PRAGMAS = DETECT_SECRETS_COMMENT_MARKERS.flatMap(({ start, end }) => [
1951
+ { nextLine: false, pattern: new RegExp(`[ \\t]*${start} *pragma: ?(?:allow|white)list[ -]secret[^\\n]*?${end}[ \\t]*(?![\\s\\S])`, "u") },
1952
+ { nextLine: true, pattern: new RegExp(`^[ \\t]*${start} *pragma: ?allowlist[ -]nextline[ -]secret[^\\n]*?${end}[ \\t]*(?![\\s\\S])`, "u") }
1953
+ ]);
1954
+ var PYTHON_WHITESPACE = new RegExp("\\p{White_Space}", "u");
1955
+ var PYTHON_EXTRA_WHITESPACE = /* @__PURE__ */ new Set(["", "", "", ""]);
1956
+ function hasDetectSecretsPragma(comment, text) {
1957
+ if (!comment.value.includes("pragma:")) return false;
1958
+ let lineStart = Math.max(text.lastIndexOf("\r", comment.range[0] - 1), text.lastIndexOf("\n", comment.range[0] - 1)) + 1;
1959
+ while (lineStart < comment.range[1]) {
1960
+ const nextCr = text.indexOf("\r", lineStart);
1961
+ const nextLf = text.indexOf("\n", lineStart);
1962
+ const lineEnd = Math.min(nextCr < 0 ? text.length : nextCr, nextLf < 0 ? text.length : nextLf);
1963
+ if (hasPragmaInReaderLine(comment, text.slice(lineStart, lineEnd), lineStart)) return true;
1964
+ lineStart = lineEnd + (text[lineEnd] === "\r" && text[lineEnd + 1] === "\n" ? 2 : 1);
1965
+ }
1966
+ return false;
1967
+ }
1968
+ function hasPragmaInReaderLine(comment, rawLine, lineStart) {
1969
+ const sameLine = stripPythonTrailingWhitespace(rawLine);
1970
+ for (const { nextLine, pattern } of DETECT_SECRETS_PRAGMAS) {
1971
+ const column = nextLine ? 0 : Math.max(0, comment.range[0] - lineStart);
1972
+ const match = pattern.exec((nextLine ? rawLine : sameLine).slice(column));
1973
+ if (match === null) continue;
1974
+ const pragmaStart = lineStart + column + match.index + match[0].indexOf("pragma:");
1975
+ if (pragmaStart >= comment.range[0] && pragmaStart < comment.range[1]) return true;
1976
+ }
1977
+ return false;
1978
+ }
1979
+ function stripPythonTrailingWhitespace(value) {
1980
+ let end = value.length;
1981
+ while (end > 0) {
1982
+ const character = value.charAt(end - 1);
1983
+ if (!PYTHON_WHITESPACE.test(character) && !PYTHON_EXTRA_WHITESPACE.has(character)) break;
1984
+ end--;
1985
+ }
1986
+ return value.slice(0, end);
1987
+ }
1942
1988
  var no_test_comments_default = createRule({
1943
1989
  name: "no-test-comments",
1944
1990
  documentation: NO_TEST_COMMENTS_DOCUMENTATION,
@@ -1975,7 +2021,7 @@ var no_test_comments_default = createRule({
1975
2021
  }
1976
2022
  for (const [index, comment] of comments.entries()) {
1977
2023
  const body3 = comment.value.trim().replace(/^\*\s*/u, "");
1978
- if (DIRECTIVE.test(body3) || LEGAL.test(comment.value) || legalLines.has(index) || TYPE_CONTRACT.test(comment.value)) continue;
2024
+ if (DIRECTIVE.test(body3) || LEGAL.test(comment.value) || legalLines.has(index) || TYPE_CONTRACT.test(comment.value) || hasDetectSecretsPragma(comment, context.sourceCode.text)) continue;
1979
2025
  context.report({
1980
2026
  node: comment,
1981
2027
  messageId: "testComment",
@@ -3961,7 +4007,7 @@ function isSearchParamReceiver(call, services) {
3961
4007
  // package.json
3962
4008
  var package_default = {
3963
4009
  name: "@sarj/eslint-plugin",
3964
- version: "16.36.3",
4010
+ version: "16.36.5",
3965
4011
  packageManager: "npm@12.2.1",
3966
4012
  description: "Custom ESLint rules for hypermodern TypeScript / React / Next.js projects",
3967
4013
  type: "module",
package/dist/index.js CHANGED
@@ -1877,7 +1877,7 @@ var NO_TEST_COMMENTS_DOCUMENTATION = {
1877
1877
  autofix: "safe",
1878
1878
  limitations: [
1879
1879
  "Checks actual line and block comment tokens in recognized maintained test files, including test fixtures; strings and template text remain unchanged. Generated/vendor files are excluded.",
1880
- "Legal notices, shebangs, TypeScript triple-slash references, coverage/build annotations and explicit lint/type/test/formatter directives remain allowed. Ordinary prose embedded in a directive remains the owning tool's responsibility.",
1880
+ "Legal notices, shebangs, TypeScript triple-slash references, coverage/build annotations and explicit lint/type/test/formatter directives remain allowed. Executable detect-secrets 1.5.0 allowlist/whitelist pragmas retain its case-sensitive delimiter, spacing, physical-line and next-line grammar; arbitrary pragma prose remains ordinary commentary. Rationale on an executable directive remains the owning tool's responsibility.",
1881
1881
  "The automatic fix removes comments and adjacent padding while retaining every line ending and necessary token boundary; it does not rename tests or remove executable statements. Bare integration/e2e directories and ambiguous hyphen/underscore test basenames require another concrete test-path signal or a runtime testing-framework import; ordinary production integration modules and rule implementations ending in -test are preserved."
1882
1882
  ],
1883
1883
  examples: [
@@ -1888,6 +1888,52 @@ var NO_TEST_COMMENTS_DOCUMENTATION = {
1888
1888
  var DIRECTIVE = /^(?:eslint(?:-\S+)?\b|(?:biome|oxlint|jshint|jslint|c8|v8|istanbul|vitest|prettier|dprint)\b|@(?:ts-(?:check|nocheck|expect-error|ignore)|vitest-environment|jest-environment|jsx\w*|license|preserve)\b|[#!]\s*__(?:PURE|NO_SIDE_EFFECTS)__|\/\s*<(?:reference|amd-module|amd-dependency)\b)/u;
1889
1889
  var LEGAL = /(?:^|\n)\s*\*?\s*(?:Copyright\b|SPDX-License-Identifier:|Licensed under\b|@license\b|@preserve\b)/iu;
1890
1890
  var TYPE_CONTRACT = /@(?:type|typedef|template|param|returns?|satisfies|callback|overload|implements|extends|augments|enum|this|import)\b/u;
1891
+ var DETECT_SECRETS_COMMENT_MARKERS = [
1892
+ { start: "#", end: "" },
1893
+ { start: "//", end: "" },
1894
+ { start: "/\\*", end: " *\\*/" },
1895
+ { start: "'", end: "" },
1896
+ { start: "--", end: "" },
1897
+ { start: "<!--[# \\t]*?", end: " *?-->" }
1898
+ ];
1899
+ var DETECT_SECRETS_PRAGMAS = DETECT_SECRETS_COMMENT_MARKERS.flatMap(({ start, end }) => [
1900
+ { nextLine: false, pattern: new RegExp(`[ \\t]*${start} *pragma: ?(?:allow|white)list[ -]secret[^\\n]*?${end}[ \\t]*(?![\\s\\S])`, "u") },
1901
+ { nextLine: true, pattern: new RegExp(`^[ \\t]*${start} *pragma: ?allowlist[ -]nextline[ -]secret[^\\n]*?${end}[ \\t]*(?![\\s\\S])`, "u") }
1902
+ ]);
1903
+ var PYTHON_WHITESPACE = new RegExp("\\p{White_Space}", "u");
1904
+ var PYTHON_EXTRA_WHITESPACE = /* @__PURE__ */ new Set(["", "", "", ""]);
1905
+ function hasDetectSecretsPragma(comment, text) {
1906
+ if (!comment.value.includes("pragma:")) return false;
1907
+ let lineStart = Math.max(text.lastIndexOf("\r", comment.range[0] - 1), text.lastIndexOf("\n", comment.range[0] - 1)) + 1;
1908
+ while (lineStart < comment.range[1]) {
1909
+ const nextCr = text.indexOf("\r", lineStart);
1910
+ const nextLf = text.indexOf("\n", lineStart);
1911
+ const lineEnd = Math.min(nextCr < 0 ? text.length : nextCr, nextLf < 0 ? text.length : nextLf);
1912
+ if (hasPragmaInReaderLine(comment, text.slice(lineStart, lineEnd), lineStart)) return true;
1913
+ lineStart = lineEnd + (text[lineEnd] === "\r" && text[lineEnd + 1] === "\n" ? 2 : 1);
1914
+ }
1915
+ return false;
1916
+ }
1917
+ function hasPragmaInReaderLine(comment, rawLine, lineStart) {
1918
+ const sameLine = stripPythonTrailingWhitespace(rawLine);
1919
+ for (const { nextLine, pattern } of DETECT_SECRETS_PRAGMAS) {
1920
+ const column = nextLine ? 0 : Math.max(0, comment.range[0] - lineStart);
1921
+ const match = pattern.exec((nextLine ? rawLine : sameLine).slice(column));
1922
+ if (match === null) continue;
1923
+ const pragmaStart = lineStart + column + match.index + match[0].indexOf("pragma:");
1924
+ if (pragmaStart >= comment.range[0] && pragmaStart < comment.range[1]) return true;
1925
+ }
1926
+ return false;
1927
+ }
1928
+ function stripPythonTrailingWhitespace(value) {
1929
+ let end = value.length;
1930
+ while (end > 0) {
1931
+ const character = value.charAt(end - 1);
1932
+ if (!PYTHON_WHITESPACE.test(character) && !PYTHON_EXTRA_WHITESPACE.has(character)) break;
1933
+ end--;
1934
+ }
1935
+ return value.slice(0, end);
1936
+ }
1891
1937
  var no_test_comments_default = createRule({
1892
1938
  name: "no-test-comments",
1893
1939
  documentation: NO_TEST_COMMENTS_DOCUMENTATION,
@@ -1924,7 +1970,7 @@ var no_test_comments_default = createRule({
1924
1970
  }
1925
1971
  for (const [index, comment] of comments.entries()) {
1926
1972
  const body3 = comment.value.trim().replace(/^\*\s*/u, "");
1927
- if (DIRECTIVE.test(body3) || LEGAL.test(comment.value) || legalLines.has(index) || TYPE_CONTRACT.test(comment.value)) continue;
1973
+ if (DIRECTIVE.test(body3) || LEGAL.test(comment.value) || legalLines.has(index) || TYPE_CONTRACT.test(comment.value) || hasDetectSecretsPragma(comment, context.sourceCode.text)) continue;
1928
1974
  context.report({
1929
1975
  node: comment,
1930
1976
  messageId: "testComment",
@@ -3914,7 +3960,7 @@ function isSearchParamReceiver(call, services) {
3914
3960
  // package.json
3915
3961
  var package_default = {
3916
3962
  name: "@sarj/eslint-plugin",
3917
- version: "16.36.3",
3963
+ version: "16.36.5",
3918
3964
  packageManager: "npm@12.2.1",
3919
3965
  description: "Custom ESLint rules for hypermodern TypeScript / React / Next.js projects",
3920
3966
  type: "module",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sarj/eslint-plugin",
3
- "version": "16.36.3",
3
+ "version": "16.36.5",
4
4
  "packageManager": "npm@12.2.1",
5
5
  "description": "Custom ESLint rules for hypermodern TypeScript / React / Next.js projects",
6
6
  "type": "module",