If you want to use ESlint with k6, then you may have read my previous post about How to lint k6 tests. Well, I am pleased to say that now, its even easier! I have this week released k6-linting-rules, an ESlint plugin that takes care of adding the required rules for you.

How to use the ESlint plugin for k6

You’ll first need to install ESLint:

npm i eslint --save-dev

Next, install eslint-plugin-k6-linting-rules:

npm install eslint-plugin-k6-linting-rules --save-dev

Add k6-linting-rules to the plugins section of your .eslintrc configuration file. You can omit the eslint-plugin- prefix:

{
    "plugins": [
        "k6-linting-rules"
    ]
}

Finally, configure the rules to use under the rules section.

{
    "rules": {
        "k6-linting-rules/k6": 2
    }
}

That’s it. ESlint is now configured for linting k6! If you want to see the code behind the plugin you can see the repo on my github. Feedback is not only welcome, but encouraged.