Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-116778

qmlformat: unnecessarily adds a semicolon

    XMLWordPrintable

Details

    • Bug
    • Resolution: Duplicate
    • P3: Somewhat important
    • 6.9
    • 6.5.2
    • QML: Tooling
    • None

    Description

      QML Coding Convention says:

      "If the code is longer than one line and hence within a block, we use semicolons to indicate the end of each statement"

      https://doc.qt.io/qt-6/qml-codingconventions.html#javascript-code

      This implies that a single line of JavaScript doesn't require a semicolon.  

      Now, if I qmlformat this: 

      Window {
          id: myWindow
          width: 640
          height: 480
          visible: true
          property bool connected: false
          Label {
              text: {
                  myWindow.connected ? qsTr("Connected") : qsTr("Disconnected")
              }
          }
      }
      

      There is a semicolon added: 

              text: {
                  myWindow.connected ? qsTr("Connected") : qsTr("Disconnected");
              }

       

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              qtqmlteam Qt Qml Team User
              jannej Janne Juntunen
              Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes