Skip to content
This repository has been archived by the owner on Mar 23, 2024. It is now read-only.

disallowUnusedParams throw an error with import #1875

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

disallowUnusedParams throw an error with import #1875

yodairish opened this issue Oct 16, 2015 · 5 comments
Labels
Milestone

Comments

@yodairish
Copy link

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
Copy link
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
Copy link
Author

version: 2.3.2

yup, esnext is on

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

@hzoo
Copy link
Member

hzoo commented Oct 17, 2015

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

@hzoo
Copy link
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 as completed in 63526b7 Oct 17, 2015
@hzoo
Copy link
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.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants