0

This has probably been asked before, but I don't really know how to search for it so if it has, I am really sorry.

Say I have a file called a.js that has a class called Navigation in it, then in b.js I call that with a method inside the class called getView();

a.js

Navigation.prototype.getView = function getView(id) {
   return this.views[id]; 
};

b.js

var currentView = Navigation.getView(id);

How would I go about tell ESLint that Navigation should be ignred from the no-undef rule?

ChronixPsyc
  • 478
  • 1
  • 8
  • 22

2 Answers2

1

You can try to use the globals comment inside the file you want to ignore it.

/* globals MY_GLOBAL */
ztadic91
  • 2,774
  • 1
  • 15
  • 21
1

ESLint lints each file in isolation, so it will not resolve identifiers defined in other files. The /* exported ... */ comment and globals allow you to inform ESLint of dependencies in other files.

Note that /* exported */ has no effect for any of the following:

  • when the environment is node or commonjs
  • when parserOptions.sourceType is module
  • when ecmaFeatures.globalReturn is true
Community
  • 1
  • 1
kemotoe
  • 1,730
  • 13
  • 27