Real time rules with ktlint

白昼怎懂夜的黑 提交于 2019-12-25 01:13:28

问题


I am trying to use ktlint on my android project.

Currently I am using these gradle plugins:

org.jlleitschuh.gradle.ktlint
org.jlleitschuh.gradle.ktlint-idea

I can check the code using a manual gradle task, where the warnings will be displayed by the terminal.

Is it possible to achive something like eslint in javascript? Example:


回答1:


You will not get an error message like in eslint but using following method you won't need to deal with ktlint styling issues manually. Is not it much better than manually fixing things up?

  1. Install ktlint commandline tools as described here.
  2. Set IntelliJ IDEA's code styles to align with ktlint's code styles as described here.

So when you make a commit using IntelliJ IDEA's commit window (CTRL + K or Command + K) and you have reformat code before commit enabled then your commit will be made with correct code styles.



来源:https://stackoverflow.com/questions/59387783/real-time-rules-with-ktlint

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!