Skip to content
This repository has been archived by the owner on Aug 18, 2021. It is now read-only.

Exported class is defined but never used #8

Closed
gaearon opened this issue Feb 27, 2015 · 13 comments
Closed

Exported class is defined but never used #8

gaearon opened this issue Feb 27, 2015 · 13 comments
Labels

Comments

@gaearon
Copy link
Member

gaearon commented Feb 27, 2015

'use strict';

class Lol {
}

module.exports = Lol;

says

Lol is defined but never used
@sebmck sebmck closed this as completed in f06d335 Feb 28, 2015
@sebmck
Copy link
Contributor

sebmck commented Feb 28, 2015

Fixed as of 1.0.8, thanks!

@sebmck
Copy link
Contributor

sebmck commented Feb 28, 2015

Or not...

@sebmck sebmck reopened this Feb 28, 2015
@nzakas
Copy link

nzakas commented Feb 28, 2015

ES6 scoping is still experimental in escope. We are still finding edge cases and this is probably one of them.

@sebmck
Copy link
Contributor

sebmck commented Feb 28, 2015

Could probably turn it into a function expression with the init of a variable declaration. Would need to inject a semicolon token into the token stream though to satisfy all the other rules.

@n1k0
Copy link

n1k0 commented Feb 28, 2015

+1, export var foo = 42; raises the same warning, would love seeing this fixed :)

@gpbl
Copy link

gpbl commented Feb 28, 2015

Yup same for export function doSomething() { }.

BenoitZugmeyer added a commit to BenoitZugmeyer/babel-eslint that referenced this issue Mar 7, 2015
eslint does not support an escope "module" scope but we need it to
support modules syntax.

Simply pushing all variables from the "module" scope in the "global"
scope should fix many issues: babel#8, babel#15, babel#17, babel#21, babel#29
@sebmck
Copy link
Contributor

sebmck commented Mar 10, 2015

Should be fixed if you upgrade babel-eslint to 2.0.0 and eslint to 0.16.x, thanks!

@sebmck sebmck closed this as completed Mar 10, 2015
@emmenko
Copy link

emmenko commented Mar 10, 2015

@sebmck I've installed v2 and I'm getting this error now

$ eslint --ext .js,.jsx .
TypeError: Cannot read property 'VISITOR_KEYS' of undefined
    at monkeypatch (/usr/local/lib/node_modules/babel-eslint/index.js:36:35)
    at Object.exports.parse (/usr/local/lib/node_modules/babel-eslint/index.js:50:5)
    at parse (/usr/local/lib/node_modules/eslint/lib/eslint.js:454:27)
    at EventEmitter.module.exports.api.verify (/usr/local/lib/node_modules/eslint/lib/eslint.js:606:15)
    at processFile (/usr/local/lib/node_modules/eslint/lib/cli-engine.js:193:27)
    at /usr/local/lib/node_modules/eslint/lib/cli-engine.js:293:26
    at /usr/local/lib/node_modules/eslint/lib/util/traverse.js:61:17
    at Array.forEach (native)
    at traverse (/usr/local/lib/node_modules/eslint/lib/util/traverse.js:41:54)
    at /usr/local/lib/node_modules/eslint/lib/util/traverse.js:63:17
$ npm -g list |grep eslint
├─┬ [email protected]
├─┬ [email protected]

sebmck added a commit to babel/babel that referenced this issue Mar 10, 2015
@sebmck
Copy link
Contributor

sebmck commented Mar 10, 2015

@emmenko Fixed.

@emmenko
Copy link

emmenko commented Mar 10, 2015

@sebmck thx, that fixed it. Having a different problem now regarding imports

import React from 'react/addons'
let {PureRenderMixin} = React.addons

//  2:24  error  'React' is not defined  no-undef

Do I have to change some kind of configuration when upgrading to 2.0.0 ?

@sebmck
Copy link
Contributor

sebmck commented Mar 10, 2015

@emmenko Yep, this is an internal ESLint/escope issue that needs to be fixed. Needs to be fixed on their end. Reference: estools/escope#51

@emmenko
Copy link

emmenko commented Mar 10, 2015

Ah ok thanks. Just wondering because it was working before... ;)

@tikotzky
Copy link

@sebmck there still seems to be some weirdness with no-unused-vars

This gives a linting error

function foo(){}
export { foo };
//  1:9  error  foo is defined but never used  no-unused-vars

while these are ok

export function foo(){}
class foo{}
export { foo };

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

8 participants