Java, XML, JSON and YAML formatter based on Intellij CE formatter, inspired by ktlint.
Distributed as command-line cli tool and a Linter
implementation compatible with
editorconfig-maven-plugin,
editorconfig-gradle-plugin.
.editorconfig
support- Compatibility with all settings present in Intellij CE
- Maven and Gradle integration with
editorconfig-maven-plugin
,editorconfig-gradle-plugin
- Executable jar
- No configuration required
CLI provides similar API as Ktlint
CLI.
Basic usage:
$ javalint # checks formatting for all the files in this directory
$ javalint src/**/*.java # checks all *.java files in src directory
$ javalint -F # fixes formatting for all the files in this directory
$ javalint --help # print detailed usage information
Following configuration will check all files formatting
(except target
, build
, node_modules
folders).
<project>
<!-- Add ec4j maven plugin -->
<plugins>
<plugin>
<groupId>org.ec4j.maven</groupId>
<artifactId>editorconfig-maven-plugin</artifactId>
<version>0.1.3</version>
<!-- Add javalint-ec4j-linter -->
<dependencies>
<dependency>
<groupId>io.github.kamil-perczynski</groupId>
<artifactId>javalint-ec4j-linter</artifactId>
<version>1.3</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>check</id>
<phase>validate</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
<!-- Disable default linters from ec4j -->
<configuration>
<linters>
<linter>
<id>org.ec4j.linters.TextLinter</id>
<enabled>false</enabled>
</linter>
<linter>
<id>org.ec4j.linters.XmlLinter</id>
<enabled>false</enabled>
</linter>
</linters>
</configuration>
</plugin>
</plugins>
</project>
// build.gradle.kts
// add editorconfig plugin
plugins {
java
application
id("org.ec4j.editorconfig") version "0.1.0"
}
dependencies {
// other dependencies...
// add javalint-ec4j-linter dependency in editorconfig scope
editorconfig("io.github.kamil-perczynski:javalint-ec4j-linter:1.3")
}
// disable default ec4j linters
// optional: disable linting of the .profileconfig.json file
editorconfig {
excludes = listOf(".profileconfig.json")
linters = listOf(
LinterConfig().also {
it.isEnabled = false
it.className = "org.ec4j.linters.TextLinter"
},
LinterConfig().also {
it.isEnabled = false
it.className = "org.ec4j.linters.XmlLinter"
}
)
}
tasks.check {
dependsOn("editorconfigCheck")
}
This software includes code from IntelliJ IDEA CE Copyright (C) JetBrains s.r.o. https://www.jetbrains.com/idea/
This project is not affiliated with JetBrains.