diffplug / spotless

Keep your code spotless
Apache License 2.0
4.34k stars 441 forks source link

[Feature] Support editorconfig #734

Open xenoterracide opened 3 years ago

xenoterracide commented 3 years ago

Support https://editorconfig.org

instead of this

spotless {
  // optional: limit format enforcement to just the files changed by this feature branch
  ratchetFrom 'origin/main'

  format 'misc', {
    // define the files to apply `misc` to
    target '*.gradle', '*.md', '.gitignore'

    // define the steps to apply to those files
    trimTrailingWhitespace()
    indentWithTabs() // or spaces. Takes an integer argument if you don't like 4
    endWithNewline()
}

you could simply do

spotless {
  editorConfig()
}

which would simply figure out all the same information, and also presumably pass it to other things like

spotless {
   java {
}

would inherit it.

possibly code or coordination of a general library for editor config in java here.

https://github.com/ec4j/editorconfig-gradle-plugin

nedtwigg commented 3 years ago

Partial dupe of #142, but each issue is unique enough to stand on its own.

JavierSegoviaCordoba commented 3 years ago

I would like to see this. My use case is using the official Android XML format, and should be easy to just export the editorconfig from IntelliJ and that Spotless read it to know how to sort the xml fields for example.

andriewski commented 2 years ago

That would be really convinient to have such thing in spotless. .editorconfig is widely spread amoung Java community, which uses Intellij Idea Basically, it's placed in the root of the project

I would be great if you add this support for Maven and Gradle :)

archongum commented 11 months ago

Need this for using .editorconfig for all file types (.yml, .sh, etc.)

sharath2106 commented 10 months ago

This would really solve a lot of headaches for our team's overall formatting style as we rely on .editorconfig. Would be nice to see an update coming supporting this.

sonus21 commented 7 months ago

Need this feature to solve all the headache we've due to different formatting style used in .editorconfig and spotless. Please add support for this.

derekobrien27 commented 3 months ago

+1 for this feature!

mhagnumdw commented 2 months ago

Certainly, it's definitely a valuable feature!

Initially, I even tried to configure Spotless to comply with the .editorconfig, but I already stumbled upon <includes><include>**</include></includes> which doesn't respect the .gitignore. Another obstacle is that with **, Spotless tried to process the .mvn/wrapper/maven-wrapper.jar binary file while the editorconfig disregards it. I know it's possible to be more specific with <include> and <exclude>, but depending on the project, it can get quite verbose, and files may be added or excluded from folders not referenced in the <include> and <exclude>.

0BuRner commented 1 week ago

Any news on this long-awaited feature?