An ESLint plugin to lint JavaScript in QML files (.qml
extension).
Install the plugin:
npm install --save-dev eslint eslint-plugin-qml
Add it to your .eslintrc
:
{
"plugins": ["qml"]
}
Run ESLint on .qml
files:
eslint --ext qml .
It will lint Javascript blocks and functions in your QML documents:
Rectangle {
Text {
title: ''
}
function hello() {
title.text = "Hello World";
}
Component.onCompleted: hello()
}
The linter-eslint package allows for linting within the Atom IDE.
In order to see eslint-plugin-qml
work its magic within QML code
blocks in your Atom editor, you can go to linter-eslint
's settings and
within "List of scopes to run ESLint on...", add the cursor scope "source.gfm".
However, this reports a problem when viewing QML which does not have
configuration, so you may wish to use the cursor scope "source.embedded.js",
but note that eslint-plugin-qml
configuration comments and skip
directives won't work in this context.
$ git clone https://github.com/oltodo/eslint-plugin-qml.git
$ cd eslint-plugin-qml
$ npm install
$ npm test
This project follows the ESLint contribution guidelines.