maplibre-style-spec
maplibre-style-spec copied to clipboard
Add .editorconfig config
EditorConfig is very popular and helpful in helping maintain consistent code formatting. I think it'd be a good idea to add an .editorconfig file to the projects root. I suggest something like this:
# https://editorconfig.org
root = true
[*]
charset = utf-8
end_of_line = lf
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true
EditorConfig is one of the most downloaded VS Code extensions so if this config was present then it will ensure that there aren't unnecessary trailing whitespaces and files are saved with the correct line endings etc. It could be added to the recommended extensions file too in .vscode/extensions.json.
Launch Checklist
- [x] Confirm your changes do not include backports from Mapbox projects (unless with compliant license) - if you are not sure about this, please ask!
- [x] Briefly describe the changes in this PR.
- [ ] Link to related issues.
- [ ] Include before/after visuals or gifs if this PR includes visual changes.
- [ ] Write tests for all new functionality.
- [ ] Document any changes to public APIs.
- [ ] Post benchmark scores.
- [ ] Add an entry to
CHANGELOG.mdunder the## mainsection.
Codecov Report
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 92.70%. Comparing base (
1235449) to head (951073b).
Additional details and impacted files
@@ Coverage Diff @@
## main #821 +/- ##
=======================================
Coverage 92.70% 92.70%
=======================================
Files 105 105
Lines 4646 4646
Branches 1312 1312
=======================================
Hits 4307 4307
Misses 339 339
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
Can't we simply use more lint rules instead of adding a tool that is not used in CI and needs to be aligned with the existing lint configurations?
Can't we simply use more lint rules...
no, not really. There isn't a 'trim trailing spaces' rule for all linters and there aren't linters for all file-types setup in this repo already (such as YML, Markdown etc). Furthermore, most linters work with Editorconfig and don't cause conflicts - they are different things really. I removed the indent_size = 4 setting though as .json files are using 2 spaces instead. Without this config included in the repo you are more likely to have issues with inconsistent line endings and trailing spaces.
I'm looking for a better integration between those two. Otherwise it's duplication on one hand and not really enforced in CI on the other hand.
I'm looking for a better integration between those two. Otherwise it's duplication on one hand and not really enforced in CI on the other hand.
I'm not sure what sort of thing you're thinking of. Prettier could used to be format all files for consistency, but even that works with Editorconfig. What do you think about adding that to CI/CD? Or Perhaps GitHub's Super Linter Action (which includes Prettier).
I realize I may be in the minority, but I really do not like Prettier. I don't mind the EditorConfig idea, but it does seem more useful for things that aren't linted, and it really provides hints more than anything.
I don't like prittier as well... The problem, from my point of view, with editor config is that it changes only the files you touch, which creates PRs that change the file content without changing the logic, and simply creates noise when I want to review a PR. More over, CI should take care of these validations and an automated fix should run when introducing this configuration to make sure all files now follow the new rules. Without those, I can't accept this PR...
I'll be closing this, I'm looking for a better solution. I've just updated lint to latest version, so feel free to update it to allow the relevant definitions.