editorconfig-core-js
editorconfig-core-js copied to clipboard
Ability to retrieve the current configuration file path
Currently, there is no way to know which .editorconfig
file is used when getting the configuration using parseSync
: if we try to load the configuration from a path when there is no .editorconfig
file, the package will travel through the file system to search for another .editorconfig
file and finally retrieve the read configuration.
It should be great to be able to retrieve the configuration file name or file path to know which file is currently used.
There may be more than one .editorconfig
file that was merged into the final configuration, so it would have to be a list of files.
Hi @jedmao,
You are right, I am OK with that :wink: Thanks for the fix.
@xavierfoucrier see https://github.com/cto-af/editorconfig-core-js/pull/7 and see if this API would work for you. I put an array of applied file paths in a editorconfig.FILES
symbol on the returned object. Many uses of the object will just ignore the symbol, and you can look for it if you want it:
> ec.parseSync('foo')
{
indent_style: 'space',
indent_size: 2,
end_of_line: 'lf',
charset: 'utf-8',
trim_trailing_whitespace: true,
insert_final_newline: true,
block_comment_start: '/**',
block_comment: '*',
block_comment_end: '*/',
tab_width: 2,
[Symbol(FILES)]: [ '<my path>/.editorconfig' ]
}
I'd be happy to make a dedicated API instead (to guarantee backward-compat), but this seems like a good compromise to me.
@hildjj thanks for the fix, unfortunately I have no time right now to check.
I will also prefer to check implementation on the official editorconfig project instead. Feel free to make a PR on the editorconfig-core-js repo :wink:
I'll prepare a PR for this repo after I've gotten a few other things cleared up.
@xavierfoucrier See #107 please. I'm interested in feedback before I merge it.
@hildjj unfortunately no time on my side for that right now, sorry.
@hildjj Finally, I took the time to have a look: it works great! Thanks for the fix :tada: