Closed jamesarosen closed 7 years ago
Thanks @jamesarosen - i think this is a bug but i fear it belongs to https://github.com/editorconfig/editorconfig-core-js since we're belonging on it. I would like to advice you opening your issue there.
Sorry that i couldn't help so far. 💝
Moved to editorconfig/editorconfig-core-js#41
@jamesarosen thanks a lot & good luck. Let me know if you need help.
I don't think this is an issue with editorconfig/editorconfig-core-js. At least as of the latest version, I get the following:
var editorconfig = require('editorconfig');
editorconfig.parse('foo.js').then(function onFulfilled(result) {
console.log(result.insert_final_newline);
}); // true
editorconfig.parse('foo.hbs').then(function onFulfilled(result) {
console.log(result.insert_final_newline);
}); // false
Thanks @jamesarosen - i will take a look.
Hi @jamesarosen - sorry for replying that late.
I spend now a fair hour to get behind what your problem might be.
At first, i can't reproduce the described behavior -- not within Atom, nor with the editorconfig
-binary from the command line.
I also tried to dig into the editorconfig-core-js but, well i guess i'm too tired to get a quick insight. However, i have the suspicion that calling editorconfig.parse()
with relative paths may not lead to any expected behavior. As far as i understood the implementation, absolute paths are needed at this point.
Without any additional information i can only guess. This behavior may probably be caused by the fact you didn't define a root = true
and/or any symlinks are interfering the editorconfig-resolvement.
I would really like to know what this causes. So if you want do further investigations let me know.
@jamesarosen
When I save foo.js, the configuration below correctly inserts a newline at the end. When I save foo.hbs, it incorrectly inserts a newline at the end.
I couldn't reproduce this behavior in with atom-editorconfig v2.2.0.
I don't think this is an issue with editorconfig/editorconfig-core-js. At least as of the latest version, I get the following:
var editorconfig = require('editorconfig');
editorconfig.parse('foo.js').then(function onFulfilled(result) {
console.log(result.insert_final_newline);
}); // true
editorconfig.parse('foo.hbs').then(function onFulfilled(result) {
console.log(result.insert_final_newline);
}); // false
Are you running this in node.js REPL or in Console tab of Developer Tools (within Atom)? Are the results above different from what you would see after you run EditorConfig: Show State
from Command Palette?
@florianb
i have the suspicion that calling
editorconfig.parse()
with relative paths may not lead to any expected behavior. As far as i understood the implementation, absolute paths are needed at this point.
The current version of editorconfig-core (0.13.2) would pass the path through path.resolve()
during editorcinfig.parse()
(code), which would deal with .
and ..
in the path, and prepend current working directory if the path is not absolute. I don't think this is documented anywhere. Relative paths may work well when working directory is set appropriately, because of the details of the current implementation, but it is not guaranteed to stay this way. They advise to use absolute paths with the CLI tool (FAQ).
@tundal45 @amyrlam could one of you provide any extra details here?
Thanks for the hint @orgkhnargh - i took that away from the cli and consequently overlooked path.resolve
s normalization step.
I close this issue due to missing response -- feel free to come back if you think this issue needs more attention.
Thank you for contribution! 💝
I think the issue was having atom's whitespace package installed.
Later rules for
insert_final_newline
aren't overriding earlier ones in the same file. According to https://github.com/editorconfig/editorconfig/issues/278, they should. Note that the spec states that later rules override earlier ones and not more specific rules override more general ones.When I save
foo.js
, the configuration below correctly inserts a newline at the end. When I savefoo.hbs
, it incorrectly inserts a newline at the end.Involved .editorconfig-files
Directory structure
Installed packages