limitLineLength
Breaks the lines of a bundle that are longer than a line limit.
A line is broken after the first , or ; token past the limit, and nothing else changes. A line terminator after either of them never changes what the code means: automatic semicolon insertion only acts where the next token could not continue, which in code that parses without the line break it can, and none of the productions that forbid a line terminator (after return, throw, break, continue and yield, before a postfix ++ / -- and before =>) has one of them on its left. The tokens come from a full parse, so a , or ; inside a string, a template or a regular expression is never taken for one.
A bundle that references a source map is returned unchanged, since a line break would put the map out of step, and so is one that does not parse, with a warning.
Import:
import { limitLineLength } from '@mnaoumov/obsidian-dev-toolkit/bundlers/obsidian-plugin-line-limit';Signature:
function limitLineLength(code: string, lineLimit: number): stringParameters:
| Parameter | Type | Description |
|---|---|---|
code |
string | The bundle. |
lineLimit |
number | The line length to break at. |
Returns: string — The bundle with its long lines broken, or code itself when nothing needed to change.
Links to this page: