Registry / serialization / tiny-editorconfig

tiny-editorconfig

JSON →
library1.0.2jsnpmunverified

tiny-editorconfig is an isomorphic JavaScript/TypeScript library designed to parse and resolve EditorConfig configurations. It provides functionality to take a raw `.editorconfig` string and convert it into a structured JavaScript object, as well as to resolve multiple parsed configurations for a given file path, applying the cascading rules of EditorConfig. The current stable version is 1.0.2. Being isomorphic, it can run seamlessly in both Node.js and browser environments without specific environment dependencies. Its primary differentiator is its minimal footprint and focused scope, offering a lightweight alternative to larger configuration processing tools. Release cadence is expected to be infrequent, primarily for bug fixes or minor specification updates, due to the stability of the EditorConfig specification itself.

npm install tiny-editorconfig
INSTALL
IMPORT
SIG · TINY-EDITORCONFIG
T
tiny-editorconfig
serializationjavascriptv1.0.2
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18–226 runs
build_error
glibc
node 18–226 runs
build_error
Code
Verified usage

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

parse
✓ import { parse } from 'tiny-editorconfig';
✗ const parse = require('tiny-editorconfig').parse;
CommonJS `require` should access named exports directly.
resolve
✓ import { resolve } from 'tiny-editorconfig';
✗ const resolve = require('tiny-editorconfig').resolve;
CommonJS `require` should access named exports directly.
EditorConfig (namespace)
✓ import * as EditorConfig from 'tiny-editorconfig';
✗ const EditorConfig = require('tiny-editorconfig');
The namespace import bundles all exports under a single object. For CommonJS, `require` returns an object directly.

Demonstrates parsing two EditorConfig strings and then resolving them for a given file path to get the final effective configuration.

import { parse, resolve } from 'tiny-editorconfig'; const editorConfigString1 = ` root=true [*] charset = UTF-8 end_of_line = lf indent_size = 2 indent_style = "space" insert_final_newline = true trim_trailing_whitespace = true [*.md] trim_trailing_whitespace = false `; const editorConfigString2 = ` [*] end_of_line = crlf indent_size = 4 `; const parsed1 = parse(editorConfigString1); const parsed2 = parse(editorConfigString2); // Resolve the configurations for a specific path, applying EditorConfig rules const resolvedConfig = resolve([parsed1, parsed2], '/path/to/my-document.md'); console.log(resolvedConfig); /* Expected Output: { root: true, charset: 'utf-8', endOfLine: 'crlf', indentSize: 4, indentStyle: 'space', insertFinalNewline: true, trimTrailingWhitespace: false } */
Debug
Known issues
gotchaThe library primarily works with string inputs and does not handle file system operations (like reading `.editorconfig` files from disk) itself. Users must provide the content of the `.editorconfig` files as strings.
fix
Manually read `.editorconfig` file content using Node.js `fs` module or browser file APIs before passing to `parse`.
affects: >=1.0.0
gotchaEditorConfig property names and values are typically case-insensitive according to the spec, but `tiny-editorconfig` normalizes keys to camelCase and values to lowercase. Be aware of this transformation when working with the parsed output.
fix
Always interact with the parsed object using normalized keys (e.g., `indentSize` instead of `indent_size`) and expect lowercase values.
affects: >=1.0.0
Errors
Common errors & fixes
Error: Invalid EditorConfig string provided.
The input string passed to `parse` is malformed and cannot be interpreted as valid EditorConfig syntax.
fix
Ensure the input string adheres to the EditorConfig format. Check for missing sections, invalid key-value pairs, or unescaped characters.
TypeError: Cannot read properties of undefined (reading 'charset')
Attempting to access a property (e.g., `charset`) from the resolved configuration that was not defined in any of the provided EditorConfig inputs for the given path.
fix
EditorConfig properties are only present in the resolved object if explicitly defined. Check if the property is expected or provide a fallback value.
Upgrade
Version history
1.0.2latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
11 hits · last 30 days
node
10
OpenAI (training)
1
Resources
tiny-editorconfig — npm install tiny-editorconfig · libregistry