user2234151
user2234151

Reputation: 131

Eslint Exported comment not working for me

I am having an issue using the exported comment to prevent the unused variable warning using eslint. The global comment is working correctly elsewhere in my code.

Warning from eslint:

"bootstrap" is defined but never used  no-unused-vars

Code:

/* exported bootstrap */
var bootstrap = require('bootstrap');

Upvotes: 1

Views: 1354

Answers (1)

Ilya Volodin
Ilya Volodin

Reputation: 11266

If you have node or commonjs environments turned on, they create an extra scope, which means that the variables that would've been marked as global in, say, browser environment, are not accessible globally. As such, you can't mark them as exported. So if you want to use variable somewhere outside of the current file, you have to use modules.export = {...}. That's why exported comment doesn't work.

Upvotes: 1

Related Questions