diff options
| author | Leander Beernaert <leander.beernaert@qt.io> | 2019-11-18 16:15:01 +0100 |
|---|---|---|
| committer | Leander Beernaert <leander.beernaert@qt.io> | 2019-11-25 15:34:40 +0100 |
| commit | f1f395b37da163bce2dc3b5fc4e298bb4f56a3e7 (patch) | |
| tree | 9ce2ba89a86ed754a8ecb8f52181770853e21a08 /tools/qmllint | |
| parent | ba494aaa24defe1401f621b791891e696b308756 (diff) | |
| parent | 0ee087f5a5edd7d1aa39fd15e0dc85985320c09a (diff) | |
Merge remote-tracking branch 'origin/dev' into wip/cmake
Change-Id: I48b9c2e4f3a75c18470c55f73f2089dc1401de54
Diffstat (limited to 'tools/qmllint')
| -rw-r--r-- | tools/qmllint/findunqualified.cpp | 2 | ||||
| -rw-r--r-- | tools/qmllint/main.cpp | 6 |
2 files changed, 5 insertions, 3 deletions
diff --git a/tools/qmllint/findunqualified.cpp b/tools/qmllint/findunqualified.cpp index ee2a0c38c1..d72f02b94a 100644 --- a/tools/qmllint/findunqualified.cpp +++ b/tools/qmllint/findunqualified.cpp @@ -530,7 +530,7 @@ void FindUnqualifiedIDVisitor::endVisit(QQmlJS::AST::Catch *) bool FindUnqualifiedIDVisitor::visit(QQmlJS::AST::WithStatement *withStatement) { m_colorOut.write(QString::asprintf("Warning: "), Warning); - m_colorOut.write(QString::asprintf("%d:%d: with statements are strongly discouraged in QML and might cause false positives when analying unqalified identifiers\n", withStatement->firstSourceLocation().startLine, withStatement->firstSourceLocation().startColumn), Normal); + m_colorOut.write(QString::asprintf("%d:%d: with statements are strongly discouraged in QML and might cause false positives when analysing unqalified identifiers\n", withStatement->firstSourceLocation().startLine, withStatement->firstSourceLocation().startColumn), Normal); enterEnvironment(ScopeType::JSLexicalScope, "with"); return true; } diff --git a/tools/qmllint/main.cpp b/tools/qmllint/main.cpp index 56f72dd020..232b31934e 100644 --- a/tools/qmllint/main.cpp +++ b/tools/qmllint/main.cpp @@ -62,11 +62,13 @@ static bool lint_file(const QString &filename, const bool silent, const bool war QQmlJS::Lexer lexer(&engine); QFileInfo info(filename); - bool isJavaScript = info.suffix().toLower() == QLatin1String("js"); + const QString lowerSuffix = info.suffix().toLower(); + const bool isJavaScript = (lowerSuffix == QLatin1String("js") || lowerSuffix == QLatin1String("mjs")); + const bool isESModule = lowerSuffix == QLatin1String("mjs"); lexer.setCode(code, /*line = */ 1, /*qmlMode=*/ !isJavaScript); QQmlJS::Parser parser(&engine); - bool success = isJavaScript ? parser.parseProgram() : parser.parse(); + bool success = isJavaScript ? (isESModule ? parser.parseModule() : parser.parseProgram()) : parser.parse(); if (!success && !silent) { const auto diagnosticMessages = parser.diagnosticMessages(); |
