@arcgis/node-toolkit 6.0.0-next.36 → 6.0.0-next.38

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/glob.d.ts CHANGED
@@ -1,8 +1,21 @@
1
+ export interface GitIgnoreFileToGlobsOptions {
2
+ /**
3
+ * Names of `#region name` / `#endregion` comment regions to skip from the
4
+ * parsed output.
5
+ * Example use case:
6
+ * - .prettierignore file can be read by Prettier, ESLint, and standalone CLI
7
+ * scripts. Most ignores are shared between tools, but some ignores are only
8
+ * applicable for Prettier (files that prettier doesn't support), and can
9
+ * be gated behind prettier-only region.
10
+ */
11
+ ignoreRegions?: string[];
12
+ }
1
13
  /**
2
14
  * Read `.gitignore` files and convert it to globs that are accepted by ESLint
3
15
  *
4
16
  * @public
5
17
  * @param filePath
18
+ * @param options
6
19
  * @example
7
20
  * ```ts
8
21
  * // eslint.config.js
@@ -12,10 +25,10 @@
12
25
  * export default [
13
26
  * globalIgnores([
14
27
  * ...gitIgnoreFileToGlobs(import.meta.dirname + "/.gitignore"),
15
- * ...gitIgnoreFileToGlobs(import.meta.dirname + "/.prettierignore"),
28
+ * ...gitIgnoreFileToGlobs(import.meta.dirname + "/.prettierignore", { ignoreRegions: ["prettier-only"] }),
16
29
  * ]),
17
30
  * // ...
18
31
  * ];
19
32
  * ```
20
33
  */
21
- export declare function gitIgnoreFileToGlobs(filePath: string): string[];
34
+ export declare function gitIgnoreFileToGlobs(filePath: string, { ignoreRegions }?: GitIgnoreFileToGlobsOptions): string[];
package/dist/glob.js CHANGED
@@ -1,6 +1,15 @@
1
1
  import { readFileSync } from "node:fs";
2
- function gitIgnoreFileToGlobs(filePath) {
3
- return readFileSync(filePath, "utf8").split("\n").filter((line) => line.trim().length > 0 && !line.trim().startsWith("#")).map((pattern) => fixAbsoluteSyntax(fixMatchFilesSyntax(pattern.trim())));
2
+ function gitIgnoreFileToGlobs(filePath, { ignoreRegions = [] } = {}) {
3
+ const regions = [];
4
+ return readFileSync(filePath, "utf8").split("\n").map((line) => line.trim()).filter((line) => {
5
+ const region = /^#region\s+(.+)$/u.exec(line)?.[1];
6
+ if (region) {
7
+ regions.push(region);
8
+ } else if (line === "#endregion") {
9
+ regions.pop();
10
+ }
11
+ return line.length > 0 && !line.startsWith("#") && !regions.some((name) => ignoreRegions.includes(name));
12
+ }).map((pattern) => fixAbsoluteSyntax(fixMatchFilesSyntax(pattern)));
4
13
  }
5
14
  function fixAbsoluteSyntax(pattern) {
6
15
  if (pattern.startsWith("/")) {
package/dist/markdown.js CHANGED
@@ -25,6 +25,7 @@ function getBoundary(content, limit, initialBlocks, atLineStart) {
25
25
  const blocks = [...initialBlocks];
26
26
  let best;
27
27
  let skipEnd = 0;
28
+ let afterHeading = false;
28
29
  for (const match of content.matchAll(/[^\n]*(?:\n|$)/gu)) {
29
30
  const index = match.index;
30
31
  if (index > limit) {
@@ -41,8 +42,12 @@ function getBoundary(content, limit, initialBlocks, atLineStart) {
41
42
  const activeFence = blocks.at(-1)?.fence;
42
43
  const heading = aligned && activeFence === void 0 ? /^ {0,3}(#{1,6})\s/u.exec(line) : null;
43
44
  const opening = aligned && activeFence === void 0 ? /^[ \t]*<details\b[^>]*>(?:\s*<summary\b[^>]*>[\s\S]*?<\/summary\s*>)?/iu.exec(content.slice(index)) : null;
44
- const kind = !aligned ? "text" : activeFence !== void 0 ? "line" : opening !== null || fence !== null ? "block" : heading !== null ? "heading" : /^\s*$/u.test(line) ? "blank" : "line";
45
- consider(textStart, kind, heading?.[1].length);
45
+ const blankLine = /^\s*$/u.test(line);
46
+ const kind = !aligned ? "text" : activeFence !== void 0 ? "line" : opening !== null || fence !== null ? "block" : heading !== null ? "heading" : blankLine ? "blank" : "line";
47
+ if (!afterHeading) {
48
+ consider(textStart, kind, heading?.[1].length);
49
+ }
50
+ afterHeading = heading !== null || afterHeading && blankLine;
46
51
  if (activeFence !== void 0) {
47
52
  if (fence !== null && fence[1].startsWith(activeFence[0]) && fence[1].length >= activeFence.length && fence[2].trim() === "") {
48
53
  blocks.pop();
@@ -66,7 +71,7 @@ function getBoundary(content, limit, initialBlocks, atLineStart) {
66
71
  textStart = end;
67
72
  }
68
73
  skipEnd = textStart;
69
- if (textStart <= end) {
74
+ if (textStart <= end && (!afterHeading || end > limit)) {
70
75
  consider(end, line.endsWith("\n") ? "line" : "text");
71
76
  let exact = Math.min(end, limit - closeBlocks(blocks).length);
72
77
  if (/[\uD800-\uDBFF]/u.test(content[exact - 1]) && /[\uDC00-\uDFFF]/u.test(content[exact])) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcgis/node-toolkit",
3
- "version": "6.0.0-next.36",
3
+ "version": "6.0.0-next.38",
4
4
  "description": "Collection of common internal build-time patterns and utilities for ArcGIS Maps SDK for JavaScript components.",
5
5
  "homepage": "https://developers.arcgis.com/javascript/latest/",
6
6
  "type": "module",