pickier 0.1.21 → 0.1.23

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.
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Compute, for each line of a TS/JS source, whether the line begins inside
3
+ * a template-literal body (i.e. between an unclosed backtick and its
4
+ * matching close).
5
+ *
6
+ * Used by rules like `prefer-const` and `pickier/no-unused-vars` to skip
7
+ * generated code embedded in template strings — declarations and function
8
+ * bodies inside a `\`<script>...\`` blob aren't real top-level code, and
9
+ * applying lint rules to them produces false positives that fixers will
10
+ * happily turn into broken runtime code.
11
+ *
12
+ * Tracks: single-quoted strings, double-quoted strings, template-literal
13
+ * bodies + their `${}` expressions (with brace depth), regex literals
14
+ * (with character-class awareness), line and block comments.
15
+ *
16
+ * Regex-vs-division disambiguation uses the previous "significant"
17
+ * character on the logical statement: `/` after operators / punctuation
18
+ * starts a regex; `/` after an identifier or closing bracket is division.
19
+ */
20
+ export declare function computeLineStartsInTemplate(text: string): boolean[];
21
+ /**
22
+ * On a single line, return [start, end] ranges of characters that fall
23
+ * inside a backtick-bounded template literal. If a backtick opens but
24
+ * doesn't close on this line, the range extends to the line's end (it's
25
+ * the first line of a multi-line template).
26
+ *
27
+ * Used by per-line fixers to refuse to rewrite identifiers that fall
28
+ * inside an embedded code blob whose other usages live in the same
29
+ * template string and aren't visible to the syntactic rename.
30
+ */
31
+ export declare function backtickRangesOnLine(line: string): Array<[number, number]>;
@@ -0,0 +1,32 @@
1
+ /**
2
+ * CommonMark-compliant code-block detection for markdown.
3
+ *
4
+ * Returns a Set of 0-indexed line numbers that are inside any code block —
5
+ * fenced (` ``` ... ``` ` / `~~~ ... ~~~`) or indented (4-space prefix). The
6
+ * fence boundary lines themselves are also included.
7
+ *
8
+ * Per the CommonMark spec, a fenced code block:
9
+ * - Opens with at least 3 backticks or tildes, optionally followed by an
10
+ * "info string" (e.g. ` ```js `).
11
+ * - Closes only with the SAME fence character, AT LEAST as many of them
12
+ * as the opener, and an EMPTY info string (just the run of backticks
13
+ * or tildes plus optional trailing whitespace).
14
+ * - Anything else inside the block — including ` ```js ` lines — is
15
+ * content, not a fence boundary.
16
+ *
17
+ * The naive tracker that toggles on every `^`{3,}|~{3,}` confuses
18
+ * `` ```js `` with a close and corrupts state for the rest of the file.
19
+ * Use this helper instead.
20
+ *
21
+ * Indented code blocks: a line is treated as inside an indented code block
22
+ * when it has 4+ leading spaces and the previous non-blank line is also
23
+ * indented (or blank with another indented line above it). Lines inside a
24
+ * fenced block don't double-count as indented.
25
+ */
26
+ export declare function getCodeBlockLines(lines: string[]): Set<number>;
27
+ /**
28
+ * Like `getCodeBlockLines` but returns whether a single line index is
29
+ * inside ANY kind of code block — handy for one-shot checks where you
30
+ * don't already have the set computed.
31
+ */
32
+ export declare function isInsideCodeBlock(lines: string[], targetIdx: number): boolean;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Identify genuine GFM table rows in a markdown document. A row counts as
3
+ * a table row when it is part of a block that includes a separator row of
4
+ * the form `|---|---|` (pipes + dashes, optional colons for alignment).
5
+ * Stray `|` characters inside paragraphs are ignored. Lines inside fenced
6
+ * or indented code blocks are ignored — `| Foo | Bar |` lines inside a
7
+ * `` ```markdown `` example are content, not real tables.
8
+ */
9
+ export declare function findTableRows(lines: string[]): Set<number>;