15

I'm looking for a coding style checker for QML code. Something like Checkstyle or Artistic Style. What do people use to define coding style checks for their DSL of choice?

Clarification: I'm looking for something that can be used in build automation not a GUI tool.

cellcortex
  • 3,166
  • 1
  • 24
  • 34

3 Answers3

4

As far as I know QtCreator works well enough with QML. You can specify a coding style you'd like the editor to adhere to. Then use Tools > Reformat File to format the style.

Jason Chan
  • 183
  • 1
  • 4
  • 2
    That's nice. However I want to automate this (auto-check style on commit, etc). So a GUI tool doesn't kick it, unfortunately. – cellcortex Dec 11 '13 at 18:21
  • Hmmm in that case maybe look for QtCreator plugins? There's an [Artistic Style plugin](http://histomatics.de/proasp.php) for it. You could also refer to this [list](http://qt-project.org/wiki/Qt_Creator_Plug-in_Gallery). – Jason Chan Dec 11 '13 at 18:31
3

Since Qt 5.15, a new tool qmlformat is shipped which automatically formats any QML file according to the QML Coding Conventions.

Source: Qt 5.15 release notes

Denis Rouzaud
  • 2,412
  • 2
  • 26
  • 45
1

There seems to be a new code formatter called qmlfmt.

See on github: https://github.com/jesperhh/qmlfmt

Sadly, it doesn't seem to offer a lot of options for now.

Denis Rouzaud
  • 2,412
  • 2
  • 26
  • 45