{"id":16242,"library":"tiny-editorconfig","title":"Tiny EditorConfig","description":"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.","status":"active","version":"1.0.2","language":"javascript","source_language":"en","source_url":"https://github.com/fabiospampinato/tiny-editorconfig","tags":["javascript","editorconfig","parser","resolver","typescript"],"install":[{"cmd":"npm install tiny-editorconfig","lang":"bash","label":"npm"},{"cmd":"yarn add tiny-editorconfig","lang":"bash","label":"yarn"},{"cmd":"pnpm add tiny-editorconfig","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"CommonJS `require` should access named exports directly.","wrong":"const parse = require('tiny-editorconfig').parse;","symbol":"parse","correct":"import { parse } from 'tiny-editorconfig';"},{"note":"CommonJS `require` should access named exports directly.","wrong":"const resolve = require('tiny-editorconfig').resolve;","symbol":"resolve","correct":"import { resolve } from 'tiny-editorconfig';"},{"note":"The namespace import bundles all exports under a single object. For CommonJS, `require` returns an object directly.","wrong":"const EditorConfig = require('tiny-editorconfig');","symbol":"EditorConfig (namespace)","correct":"import * as EditorConfig from 'tiny-editorconfig';"}],"quickstart":{"code":"import { parse, resolve } from 'tiny-editorconfig';\n\nconst editorConfigString1 = `\n  root=true\n\n  [*]\n  charset = UTF-8\n  end_of_line = lf\n  indent_size = 2\n  indent_style = \"space\"\n  insert_final_newline = true\n  trim_trailing_whitespace = true\n\n  [*.md]\n  trim_trailing_whitespace = false\n`;\n\nconst editorConfigString2 = `\n  [*]\n  end_of_line = crlf\n  indent_size = 4\n`;\n\nconst parsed1 = parse(editorConfigString1);\nconst parsed2 = parse(editorConfigString2);\n\n// Resolve the configurations for a specific path, applying EditorConfig rules\nconst resolvedConfig = resolve([parsed1, parsed2], '/path/to/my-document.md');\n\nconsole.log(resolvedConfig);\n/* Expected Output:\n{\n  root: true,\n  charset: 'utf-8',\n  endOfLine: 'crlf',\n  indentSize: 4,\n  indentStyle: 'space',\n  insertFinalNewline: true,\n  trimTrailingWhitespace: false\n}\n*/","lang":"typescript","description":"Demonstrates parsing two EditorConfig strings and then resolving them for a given file path to get the final effective configuration."},"warnings":[{"fix":"Manually read `.editorconfig` file content using Node.js `fs` module or browser file APIs before passing to `parse`.","message":"The 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.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Always interact with the parsed object using normalized keys (e.g., `indentSize` instead of `indent_size`) and expect lowercase values.","message":"EditorConfig 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.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-21T00:00:00.000Z","next_check":"2026-07-20T00:00:00.000Z","problems":[{"fix":"Ensure the input string adheres to the EditorConfig format. Check for missing sections, invalid key-value pairs, or unescaped characters.","cause":"The input string passed to `parse` is malformed and cannot be interpreted as valid EditorConfig syntax.","error":"Error: Invalid EditorConfig string provided."},{"fix":"EditorConfig properties are only present in the resolved object if explicitly defined. Check if the property is expected or provide a fallback value.","cause":"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.","error":"TypeError: Cannot read properties of undefined (reading 'charset')"}],"ecosystem":"npm"}