1

I have a project that contains two environments: browser and service worker. In .eslintrc.js file I have

  env: {
   browser: true,
    serviceworker: true
  }

In service-worker.js file which could contain

console.log(document);

I want eslint to show an error that document is not defined by the service worker. In other words is it possible to set serviceworker: true to a specific path in my project? If that is possible in vscode settings will be also fine.

1 Answer 1

1

To apply an environment per-file, you can put this comment at the top of the file(s):

/* eslint-env serviceworker */

This is from the eslint documentation here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.