aboutsummaryrefslogtreecommitdiffstats
path: root/src/qmlformat/qqmlformatoptions.cpp
Commit message (Collapse)AuthorAgeFilesLines
* qmlformat: Add GroupAttributesTogether optionXavier BESSON2025-11-251-0/+18
| | | | | | | | | | | | Equivalent to NormalizeOrder but reorder QML categories without sorting attributes (property definitions, property bindings, methods, signals, enums) Fixes: QTBUG-132060 Change-Id: Ib46ce4bb58ce46e3293d14954b0e363837b64b76 Original-patch-by: Oliver Kuss <oliver.kuss@okapp.de> Reviewed-by: Semih Yavuz <semih.yavuz@qt.io> Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
* qmlformat: Fix SemicolonRule option ignored in config fileSemih Yavuz2025-11-031-6/+26
| | | | | | | | | | | | The SemicolonRule setting from .qmlformat.ini was not being applied, only the command line option took effect. Pick-to: 6.10 Fixes: QTBUG-141638 Change-Id: I471fde37c3650e872a893ce46bb5f55e9cc3158e Initial-Patch-By: Dmitry Makarenko <kryksyh@gmail.com> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmlformat: Add argument to output available optionsXavier BESSON2025-10-301-0/+10
| | | | | | Task-number: QTCREATORBUG-33305 Change-Id: I9e23a755da0354ab1d64b7f50ff6f9cc7acbe85a Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
* qmlformat: Group "pure" formatting and tool behavior optionsFabian Kosmale2025-10-101-19/+37
| | | | | | | | | | | | Make it easier to see which options can be configured via the .qmlformat.ini file, by grouping them together, both in qdoc as well as in the help options. Fixes: QTBUG-127344 Pick-to: 6.10 Change-Id: I39501f8d30ce43a50e8a87a44f9d3769993f59ab Reviewed-by: Semih Yavuz <semih.yavuz@qt.io> Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
* Add security header for src/qmlformatSemih Yavuz2025-09-171-0/+1
| | | | | | | | | | | There is no security critic code in qmlformat. Everything remains at the default "signicant" security level. QUIP: 23 Fixes: QTBUG-136198 Pick-to: 6.10 6.9 6.8 Change-Id: Iac1c84748bc98a9c921fc8ae895a2dcd53d01270 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* qmlformat: add 'single line empty objects' optionXavier BESSON2025-08-261-0/+15
| | | | | | | Fixes: QTCREATORBUG-33333 Change-Id: Ia7eca0392418ec9b5cd13de8f6b5e263f4f09e72 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Semih Yavuz <semih.yavuz@qt.io>
* qmlformat: allow specifying an alternative location for settingsSemih Yavuz2025-08-141-1/+23
| | | | | | | | | | | | When requested, use the specified .qmlformat.ini file as the setttings file. When --settings option is given through commandline, do not perform per-directory configuration lookup. Adapt the test to accept the SearchOptions. Fixes: QTBUG-107212 Change-Id: I6b4f2c4a4321f89ae6dabf89a866c53486c22cce Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
* qmltoolings add --dry-run option for qmlformat and qmllintSemih Yavuz2025-08-141-1/+9
| | | | | | | | | | | | | Add reportConfigForFiles to generic tooling class. It will perform the search for the given files. Use stdout to report. qmllint had already an option --dry-run for printing the fixed codes, but we can still allow this to use that option name. For qmlls, report the path if verbose option is set. Fixes: QTBUG-137874 Change-Id: I6bd43866073b3df832b6fd89d477bced869d74c0 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* qmlformat: Add missing space in help outputKai Köhne2025-07-291-1/+1
| | | | | | Pick-to: 6.10 Change-Id: I1f6e0ed833795d6af1e853f2420d6997ada9561c Reviewed-by: Semih Yavuz <semih.yavuz@qt.io>
* qqmltoolingsettings: refactor search()Semih Yavuz2025-07-181-1/+1
| | | | | | | | | | | Return structured result instead of bool from search(). Update search() and read() to adapt the return. Add an isValid() convenience method to return type. Refactor search implementation into separate helper methods. Task-number: QTBUG-107212 Change-Id: I858951f0d4a7714eff01a3e6fcf96f92e2684ae1 Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
* qmlformat: customizable semicolonSemih Yavuz2025-05-131-0/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add semicolon option to qmlformat. While --Always always appends semicolons to the JS statements, --essential removes the semicolons unless it is not safe to rely on ASI once semicolons are removed. Change the way EmptyStatements are handled. Prior to this commit, semicolons following if, for, foreach, while statements without bodies were added to the new line with some indentation. Make the semicolon following no-body items stick to the right paranthesis. If there is a chain of empty statements, write out a single one. [ChangeLog][qmlformat] New option semicolon-rule is added and EmptyStatement formatting behavior has changed. * Added --semicolon-rule option with modes: - --semicolon-rule=always: Always appends semicolons to JS statements. - --semicolon-rule=essential: Removes semicolons unless ASI makes it unsafe. * Changed handling of EmptyStatements: - Semicolons after control structures without a body (e.g., if, for, while) now appear directly after the closing parenthesis, instead of on a new line. - Consecutive empty statements are collapsed into a single semicolon. Fixes: QTBUG-107152 Change-Id: Ic95047a1f0077937d4c1f01328d77a3e6a4f22d6 Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
* Tag error string with _L1 literal operatorKaj Grönholm2025-03-011-1/+1
| | | | | | | | This one was left from 121eec233e457f561c Pick-to: 6.9 6.8 Change-Id: I9d7968145ec2969c4195c8747d1e74c3d4640092 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Tag error strings with _L1 literal operatorVolker Hilsheimer2025-02-271-3/+3
| | | | | | | | | Fixes warnings-as-error build failures with VC++. Pick-to: 6.9 6.8 Change-Id: I61aab87d3a8ceed26763ba192b1bca52ffff906f Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* qmlformat: Error out when no input files are providedOlivier De Cannière2025-02-191-11/+41
| | | | | | | | | | | | | | | | | | | | | | qmlformat now errors out if -No input is provided as a positional argument and -F is not set -A positional argument does not exist -Option -F is set but the file does not exist -Option -F is set but the file is empty -Option -F is set but the file points to a file that doesn't exist TestQmlformat::testFilesOption was modified to no longer try to format a nonexistent file. That should now get rejected early. TestQmlformat::settingsFromFileOrCommandLine was modified to pass at least one file to prevent an error. [ChangeLog][Qml][qmlformat] qmlformat will now error out if no files are provided as positional arguments or via the -F option. Pick-to: 6.9 6.8 Change-Id: I7f900242c3e9e9041c9a08057a7e898e26c17493 Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
* qmlformat: don't build if commandlineparser not foundSemih Yavuz2025-01-291-6/+2
| | | | | | Task-number: QTBUG-133225 Change-Id: I8d21d16cc90e50b2ef56fcaeed5b8c3933ecbc9b Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
* qmlformat: fix precedence of settingsSemih Yavuz2025-01-291-24/+58
| | | | | | | | | | | Options set through commandline should have the precedence over the settings read from .ini file. Introduce a mapper in the setting, that marks the option if set by command line input. Add more tests. Pick-to: 6.8 6.9 Fixes: QTBUG-133225 Change-Id: Id0b18655f7bf64670dab4e38f5aff2fdaa889f1b Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
* qmlformat: move configuration functions into librarySemih Yavuz2025-01-291-0/+155
| | | | | | | | | | ...Then we can add tests for them. More tests to be added in the next commit. Pick-to: 6.8 6.9 Task-number: QTBUG-133225 Change-Id: I3f40ddc3d0895a785d6bce359c63ad6ad4d70606 Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
* qmlformat: Reorder imports alphabeticallyOvidiu Tepescu2025-01-131-0/+3
| | | | | | | | | | | Reorder imports alphabetically. [ChangeLog][qmlformat] qmlformat now supports sorting of imports, there is a new commandline option -S that is used to sort imports. Fixes: QTBUG-132061 Change-Id: Ic163456d2beed84833f7aadef0688d37292ef0f2 Reviewed-by: Semih Yavuz <semih.yavuz@qt.io>
* qmlformat: allow customizable line breakSemih Yavuz2024-12-051-0/+6
| | | | | | | | | Set line break width from commandline or settings file. Introduce -W option to set the maximum line width. Task-number: QTBUG-113590 Change-Id: Ieb0c4bd728139eec6dacaf629a640a0f2c88557f Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
* QmlFormat. A bit risky. Remove LineWriterOptions::updateOptionsDmitrii Akshintsev2024-11-051-2/+0
| | | | | | | | | | | | | | After QTBUG-128866 it seems that all times we use `LineWriterOptions::Update::None` meaning that not any of the if-s or flags checks on the LineWriterOptions are applicable. At least for the current production usages (QmlLS, qmlformat) This opens a great possibility of removing it completely along with other aux entities (see patches in the chain) Thoughts: Probably in the beginning it was intended to have a capability of changing items / expressions etc. in order not to reparse / rebuild DOM again after reformatting. AFIK atm we do not support any incremental parsing or changes in the DOM / QmlLS, but also this functionality was hard to deal with, therefore it's arguably a better option to remove it. Change-Id: I00725f012f1860eafd5609e4352bce4880f3ccb3 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Semih Yavuz <semih.yavuz@qt.io> Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
* qmlformat: extract settings logic into librarySami Shalayel2024-09-201-0/+87
Move the code from tools/qmlformat.cpp that parses .qmlformat.ini files into a newly created qmlformat library under src/qmlformat. This would allow qmlls to reuse the same code. Task-number: QTBUG-128866 Change-Id: Ibf7e52be744ea11c235d0b853ffa80f778c14a2b Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>