Socket
Socket
Sign inDemoInstall

tiny-editorconfig

Package Overview
Dependencies
3
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    tiny-editorconfig

A tiny isomorphic parser and resolver for EditorConfig.


Version published
Maintainers
1
Created

Readme

Source

Tiny EditorConfig

A tiny isomorphic parser and resolver for EditorConfig.

Install

npm install --save tiny-editorconfig

Usage

import * as EditorConfig from 'tiny-editorconfig';

// It can parse an .editorconfig string

const INPUT1 = `
  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 parsed1 = EditorConfig.parse ( INPUT );
// {
//   root: true,
//   overrides: {
//     '*': {
//       charset: 'utf-8',
//       endOfLine: 'lf',
//       indentSize: 2,
//       indentStyle: 'space',
//       insertFinalNewline: true,
//       trimTrailingWhitespace: true
//     },
//     '*.md': {
//       trimTrailingWhitespace: false
//     }
//   }
// }

const INPUT2 = `
  [*]
  end_of_line = crlf
  indent_size = 4
`;

const parsed2 = EditorConfig.parse ( INPUT );
// {
//   overrides: {
//     '*': {
//       endOfLine: 'crlf',
//       indentSize: 4
//     }
//   }
// }

// It can resolve multiple configurations for a given path

const resolved = resolve ( [PARSED1, PARSED2], '/path/to/test.md' );
// {
//   root: true,
//   charset: 'utf-8',
//   endOfLine: 'crlf',
//   indentSize: 4,
//   indentStyle: 'space',
//   insertFinalNewline: true,
//   trimTrailingWhitespace: false
// }

License

MIT © Fabio Spampinato

Keywords

FAQs

Last updated on 15 Nov 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc