Registry / testing / textlint-message-to-codemirror

textlint-message-to-codemirror

JSON →
library1.0.0jsnpmunverified

Convert textlint's messages to CodeMirror lint annotations. Current stable version is 1.0.0. This package is a small utility with no active release cadence (last release is original). It provides a simple function to transform textlint result objects into CodeMirror-compatible lint objects, mapping severity numbers (1 warning, 2 error) and converting from 1-based line/column to 0-based positions. It is a niche tool for integrating textlint linting output into CodeMirror editors.

npm install textlint-message-to-codemirror
INSTALL
IMPORT
SIG · TEXTLINT-MESSAGE-T
T
textlint-message-to-codemirror
testingjavascriptv1.0.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

textlintToCodeMirror
✓ const textlintToCodeMirror = require('textlint-message-to-codemirror')
✗ import textlintToCodeMirror from 'textlint-message-to-codemirror'
This package uses CommonJS exports (module.exports). It does not support ES modules. In Node.js, use require(). If you need ESM, consider using createRequire or a bundler.
default import
✓ const textlintToCodeMirror = require('textlint-message-to-codemirror')
✗ import { textlintToCodeMirror } from 'textlint-message-to-codemirror'
The package exports a single function as default. Named import will not work. Use default require.
no TypeScript
✓ No TypeScript types provided. Use @types/ or create your own.
✗ import textlintToCodeMirror from 'textlint-message-to-codemirror' with @types/
There are no TypeScript type definitions. You may need to declare module or use require with any type.

Shows how to convert a single textlint message object into a CodeMirror lint annotation using CommonJS require and logging the result.

const textlintToCodeMirror = require('textlint-message-to-codemirror'); const textlintResult = { message: "This is a warning", severity: 1, line: 2, column: 5 }; const codemirrorAnnotation = textlintToCodeMirror(textlintResult); console.log(codemirrorAnnotation); // Output: // { // from: { ch: 4, line: 1 }, // to: { ch: 5, line: 1 }, // message: "This is a warning", // severity: "warning" // }
Debug
Known issues
gotchaLine and column are 1-based in textlint but CodeMirror expects 0-based. The conversion subtracts 1, but only from line and column for 'from', and adds 1 to column for 'to'. Ensure your textlint messages are 1-based.
fix
Verify that input line/column are 1-based. The function handles conversion internally.
affects: <=1.0.0
gotchaThe 'to' position is always set to column (1-based) and line (1-based) but incremented only on column? Actually 'to' is { ch: column, line: line }, where column is the original input column (1-based). That means the range covers exactly one character starting at (line-1, column-1).
fix
Understand that the range length is always 1 character. For multi-character ranges, you need to handle yourself or use a different approach.
affects: <=1.0.0
Errors
Common errors & fixes
TypeError: textlintToCodeMirror is not a function
Using ES module import syntax (import ... from) on a CommonJS module without default interop.
fix
Use require('textlint-message-to-codemirror') or configure bundler to handle CommonJS.
Cannot find module 'textlint-message-to-codemirror'
Package not installed or not in node_modules.
fix
Run 'npm install textlint-message-to-codemirror' or add it to package.json dependencies.
Upgrade
Version history
1.0.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
14 hits · last 30 days
node
14
Resources
textlint-message-to-codemirror — npm install textlint-message-to-codemirror · libregistry