sindresorhus / atom-editorconfig

Helps developers maintain consistent coding styles between different editors
https://atom.io/packages/editorconfig
MIT License
812 stars 80 forks source link

File type not determined for files without extension #214

Closed stigok closed 6 years ago

stigok commented 6 years ago

In my project I have a JavaScript file without an extension in bin/www that includes a hashbang on top to behave properly on Linux

#!/usr/bin/env node
console.log('Hello, world!')

The file type is correctly determined by Atom itself, but editorconfig can not identify it since it matches on file names and extensions.

Any smart work-arounds for this besides explicitly defining the files? Match on hashbangs or something?

[*.js]
end_of_line = lf
insert_final_newline = true

Involved .editorconfig-files

root = true

[*.js]
trim_trailing_whitespace = true
indent_style = space
indent_size = 2
quote_type = single

Directory structure

./bin/www
./index.js
./.editorconfig
stigok commented 6 years ago

A solution is this:

[{**.js,bin/www}]`
end_of_line = lf
insert_final_newline = true

But it's very explicit.

florianb commented 6 years ago

@stigok - thanks for getting in touch. Editorconfig is completely glob-based, so there is no way defining file-types based on inline information. You could also try adding bin/* or start using symbolic links to js-files.

I close this issue, feel free to come back if there is more to discuss/ask. 😃

stigok commented 6 years ago

I understand. Explicitly specifying the path seems to be the best solution. Or, yes, if everything in my bin/ is JS, your glob is perfect too.