I have gone through the documentation and searched K6 community topics as well but I couldn’t find anybody having problem with linting. I am using ESLint for linting. During eslint --init I get a series of questions. I do not which options are good or appropriate for K6. When I am asked a question like “Does your code run on node or browser”, I don’t know which one to select. Same with import/export question. I know K6 team writes blogs on various topics around K6. Please write a blog/tutorial for linting as well.
Linting questions and answers:
? How would you like to use ESLint? To check syntax, find problems, and enforce code style
? What type of modules does your project use? JavaScript modules (import/export)
? Which framework does your project use? None of these
? Does your project use TypeScript? No
? Where does your code run? I think I selected none
? How would you like to define a style for your project? Use a popular style guide
I am getting an error like the one below. How to resolve it. I can’t disable the rule itself otherwise I won’t get error for custom variables
const __ENV: {
[name: string]: string;
}
Environment variables. Environment variables
We currently don’t have any eslint-config which you use, but it would be neat to have IMO.
There are a few things you could do to fix the error right now. The first and simplest way is to define the globals you want to use in a comment at the top of your file:
/* global __ENV */
const hostname = __ENV.MY_HOSTNAME
This might not be the neatest way of doing it though, and would have to be repeated in every file of your project.
The “better” way would be to add an .eslintrc.json to your project and configure the globals there:
@allansson Thanks for providing the solution but there are many more bugs like that. I don’t have a lot of experience in setting up linting which is why I am looking for a K6 specific eslint config