Skip to content

oltodo/eslint-plugin-qml

Repository files navigation

eslint-plugin-qml

An ESLint plugin to lint JavaScript in QML files (.qml extension).

Usage

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()
}

Tips for use with Atom linter-eslint

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.

Contributing

$ 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.

About

Lint JavaScript code in QML files

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published