Hi Nathan,

 

I already answered your question on stackoverflow, but in case you haven’t seen 
it: ESLint performance deep-merge on all config files found in the path of the 
file you are currently linting. If anyone of them enables any environment that 
has globalReturn turned on, all of the files will be linted with globalReturn 
option (which will disable exported comments). In order to figure out if you 
have Node environment leaking through one of the higher-up config files, you 
can run eslint with “—print-config” flag and it will output the whole 
configuration that is used to lint a current file (you have to pass it a file 
that you want to lint). If you see Node/CommonJS environments in that list, or 
you see “modules”: true in the list of parserConfig, that means you can’t use 
exported comments. To track down where it’s coming from, you can run eslint 
with “—debug” flag, that should list all config files that are currently being 
used.

 

Thanks,

 

Ilya Volodin

 

From: [email protected] [mailto:[email protected]] On Behalf Of 
Nathan Friedly
Sent: Friday, May 27, 2016 9:02 AM
To: ESLint <[email protected]>
Subject: [ESLint] Help with /* exported functionName */ in browser env

 

Hi everyone,

 

I've read the docs for exported, specifically the part about how exported 
doesn't work in node/commonjs env and I believe I'm doing things correctly 
according to the instructions there. My ESLint env is set to browser/jquery and 
each of my functions has an /* exported functionName */ comment, but I keep 
getting caught by no-unused-vars rule. Can anyone take a look and let me know 
what I'm doing wrong?

 

You can see the full source at   
<https://github.com/watson-developer-cloud/visual-recognition-nodejs/tree/eslint-exported>
 
https://github.com/watson-developer-cloud/visual-recognition-nodejs/tree/eslint-exported
 (just run npm install; npm test) but I'll try and include the relevant bits 
below:

 

Here's my .eslintrc (it extends  
<https://github.com/watson-developer-cloud/visual-recognition-nodejs/blob/eslint-exported/.eslintrc>
 this one, although I get the same behavior without the extends):

{
  "extends": "../../.eslintrc",
  "env": {
    "browser": true,
    "jquery": true
  }
}

This is one of the functions (here's the  
<https://github.com/watson-developer-cloud/visual-recognition-nodejs/blob/eslint-exported/public/js/use.js#L19>
 second and  
<https://github.com/watson-developer-cloud/visual-recognition-nodejs/blob/eslint-exported/public/js/demo.js#L30>
 third):

/**
 * Returns the next hour as Date
 * @return {Date} the next hour
 */
/* exported nextHour */
function nextHour() {
  var oneHour = new Date();
  oneHour.setHours(oneHour.getHours() + 1);
  return oneHour;
}

Finally, this is the output I get from ESLint:

/Users/nfriedly/visual-recognition-nodejs/public/js/demo.js
  24:10  error  'nextHour' is defined but never used  no-unused-vars
  37:10  error  'resize' is defined but never used    no-unused-vars
 
/Users/nfriedly/visual-recognition-nodejs/public/js/use.js
  26:10  error  'setupUse' is defined but never used  no-unused-vars

It works if I replace the /* exported... comment with an // 
eslint-disable-next-line no-unused-vars but I know that's not the correct 
solution.

 

Thanks in advance,

-Nathan

-- 
You received this message because you are subscribed to the Google Groups 
"ESLint" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected] 
<mailto:[email protected]> .
For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"ESLint" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to