editorconfig-get-indent

Given a path, find .editorconfig and get the indent for JavaScript files

Usage no npm install needed!

<script type="module">
  import editorconfigGetIndent from 'https://cdn.skypack.dev/editorconfig-get-indent';
</script>

README

editorconfig-get-indent

Given a path on a filesystem, crawl the parent directories, looking for the first ancestor that contains an .editorconfig file. Once that file is found, parse it and determine the indentation for a file extension (default: 'js');

Usage

var editorConfigGetIndent = require('editorconfig-get-indent');

var options = {
    defaultIndent: 2,
    extension: 'js'
};

editorConfigGetIndent(__dirname, options, function onIndent(err, indent) {
    if (err) {
        return console.error(err);
    }
    console.log(indent);
});