
Security News
Axios Supply Chain Attack Reaches OpenAI macOS Signing Pipeline, Forces Certificate Rotation
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.
editorconfig-parser
Advanced tools
Parse and serialize .editorconfig files.
npm install editorconfig-parser
The following fuctions are available for general use:
parse({String} str) → {Object}: parse an editorconfig file to an object.serialize({Object} obj) → {String}: serialize an object to an editorconfig file.var fs = require('fs');
var ec = require('editorconfig-parser');
// read a file from disk
var file = fs.readFileSync('.editorconfig', 'utf8');
var obj = ec.parse(file);
// modify object
var str = ec.serialize(obj);
// write the new file
fs.writeFileSync('.editorconfig', str);
Example of a parsed editorconfig object:
{
root: 'true',
'*': {
indent_style: 'space',
indent_size: '4',
end_of_line: 'lf',
charset: 'utf-8',
insert_final_newline: 'true'
},
'{package.json,*.yml}': {
indent_style: 'space',
indent_size: '2',
insert_final_newline: 'true'
}
};
Editorconfig itself uses a modified parser that provides the content in an array instead of an object. Theoretically, this is safer, since it absolutely guaranteed order. Unless you are doing something crazy though, the object above will do just fine and will be much easier to manipulate than the array. However, this module will support parsing and serializing the array-based version as well, though the following methods:
parseRaw({String} str) → {Array}: parse an editorconfig file to an array.serializeRaw({Array} arr) → {String}: serialize an array to an editorconfig file.var fs = require('fs');
var ec = require('editorconfig-parser');
// read a file from disk
var file = fs.readFileSync('.editorconfig', 'utf8');
var arr = ec.parseRaw(file);
// modify array
var str = ec.serializeRaw(arr);
// write the new file
fs.writeFileSync('.editorconfig', str);
Example of a parsed editorconfig array:
[
[ null, { root: 'true' } ],
[ '*', {
indent_style: 'space',
indent_size: '4',
end_of_line: 'lf',
charset: 'utf-8',
insert_final_newline: 'true'
}],
[ '{package.json,*.yml}', {
indent_style: 'space',
indent_size: '2',
insert_final_newline: 'true'
}]
]
FAQs
parse and serialize editorconfog files
We found that editorconfig-parser demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
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.

Security News
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

Security News
Open source is under attack because of how much value it creates. It has been the foundation of every major software innovation for the last three decades. This is not the time to walk away from it.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.