~/bend-docscommunity

layout/format.bend fails

raw source on the hub · import bend-lint-rules@0.1.0.0/layout/format.bend as Format

layout/format: a file that differs from its formatted text, where it first differs. One formatter owns indentation, spacing, declaration gaps and wrapping. Fix: writes the formatted text. Options: tabWidth (2); wrapAtWidth (100, or "never": no optional wrapping); endOfLine ("lf", "crlf", or "preserve": the file's first, or LF if it has none). Heuristics: it reads tokens, not Bend's syntax, and changes only blanks, line breaks and the space after a comment's #, so a fix keeps the program. A form its token rules do not know can come out laid out oddly.

A String is a JS string at run time: ++ is native, and a match on SCon reads one character and slices off the rest. So the lexer reads the text once, tokens carry what the layout asks of them, and docs carry widths.

Each loop is go(input, state): a step that does not recurse makes the next state, so every loop recurses on a smaller part of its input. The lexer and the printer recurse on fuel instead: more steps than they can need.

3 imports
import Base
import bend-lint-api@0.1.0.0/linter/lint.bend as Lint
import bend-lint-api@0.1.0.0/shared/strings.bend as Strings