This repository has been archived by the owner. It is now read-only.

disallowUnusedParams throw an error with import #1875

Closed
yodairish opened this Issue Oct 16, 2015 · 5 comments

Comments

Projects
None yet
2 participants
@yodairish

yodairish commented Oct 16, 2015

If I add rule "disallowUnusedParams" then files which contains "import" and "function" will throw an error:

import one from 'one';

function some() {}
internalError: Error running rule disallowUnusedParams: This is an issue with JSCS and not your codebase.
Please file an issue (with the stack trace below) at: https://github.com/jscs-dev/node-jscs/issues/new
AssertionError: ImportDeclaration should appear when the mode is ES6 and in the module context.
    at Referencer.ImportDeclaration (...path/node_modules/jscs/node_modules/escope/lib/referencer.js:711:17)
    at Referencer.Visitor.visit (...path/node_modules/jscs/node_modules/escope/node_modules/esrecurse/esrecurse.js:109:34)
    at Referencer.Visitor.visitChildren (...path/node_modules/jscs/node_modules/escope/node_modules/esrecurse/esrecurse.js:88:38)
    at Referencer.Program (...path/node_modules/jscs/node_modules/escope/lib/referencer.js:539:22)
    at Referencer.Visitor.visit (...path/node_modules/jscs/node_modules/escope/node_modules/esrecurse/esrecurse.js:109:34)
    at Object.analyze (...path/node_modules/jscs/node_modules/escope/lib/index.js:130:16)
    at Object.JsFile.getScope (...path/node_modules/jscs/lib/js-file.js:757:34)
    at Object.<anonymous> (...path/node_modules/jscs/lib/rules/disallow-unused-params.js:94:30)
    at Array.forEach (native)
    at Object.JsFile.iterateNodesByType (...path/node_modules/jscs/lib/js-file.js:545:42) at some.js :
     1 |import one from 'one';
--------^
     2 |
     3 |function some() {}

but if I remove this rule or import(exactly remove, not comment) then all fine

@hzoo

This comment has been minimized.

Show comment
Hide comment
@hzoo

hzoo Oct 17, 2015

Member

AssertionError: ImportDeclaration should appear when the mode is ES6 and in the module context. is an interesting error message.

What version of jscs are you using and are you using esnext: true in your config?

Member

hzoo commented Oct 17, 2015

AssertionError: ImportDeclaration should appear when the mode is ES6 and in the module context. is an interesting error message.

What version of jscs are you using and are you using esnext: true in your config?

@hzoo hzoo added the bug label Oct 17, 2015

@yodairish

This comment has been minimized.

Show comment
Hide comment
@yodairish

yodairish Oct 17, 2015

version: 2.3.2

yup, esnext is on

{
  "esnext": true,
  "excludeFiles": [
    "node_modules/**"
  ],
  "disallowUnusedParams": true
}

yodairish commented Oct 17, 2015

version: 2.3.2

yup, esnext is on

{
  "esnext": true,
  "excludeFiles": [
    "node_modules/**"
  ],
  "disallowUnusedParams": true
}
@hzoo

This comment has been minimized.

Show comment
Hide comment
@hzoo

hzoo Oct 17, 2015

Member

Ok looking into it. Oh I see its an escope issue?

Member

hzoo commented Oct 17, 2015

Ok looking into it. Oh I see its an escope issue?

@hzoo

This comment has been minimized.

Show comment
Hide comment
@hzoo

hzoo Oct 17, 2015

Member

Ok its a simple fix - need to add an option to escope to allow es6 and modules, not necessarily related to esnext

Member

hzoo commented Oct 17, 2015

Ok its a simple fix - need to add an option to escope to allow es6 and modules, not necessarily related to esnext

@hzoo hzoo added this to the 2.4.0 milestone Oct 17, 2015

@hzoo hzoo closed this in 63526b7 Oct 17, 2015

@hzoo

This comment has been minimized.

Show comment
Hide comment
@hzoo

hzoo Oct 17, 2015

Member

I'l try to do another quick patch release but otherwise you'll have to use the commit to version "jscs": "jscs-dev/node-jscs#63526b73"

Member

hzoo commented Oct 17, 2015

I'l try to do another quick patch release but otherwise you'll have to use the commit to version "jscs": "jscs-dev/node-jscs#63526b73"

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.