Error While Linting - new-module-imports
Hey friends, I just updated to "^5.0.1" from "^4.6.1"
When linting I now get this error (causes Ember Build to also fail):
$ eslint app
Cannot read property 'forEach' of undefined
TypeError: Cannot read property 'forEach' of undefined
at VariableDeclarator (D:\Projects\myApp\node_modules\eslint-plugin-ember\lib\rules\new-module-imports.js:27:27)
at listeners.(anonymous function).forEach.listener (D:\Projects\myApp\node_modules\eslint\lib\util\safe-emitter.js:47:58)
at Array.forEach (native)
at Object.emit (D:\Projects\myApp\node_modules\eslint\lib\util\safe-emitter.js:47:38)
at NodeEventGenerator.applySelector (D:\Projects\myApp\node_modules\eslint\lib\util\node-event-generator.js:251:26)
at NodeEventGenerator.applySelectors (D:\Projects\myApp\node_modules\eslint\lib\util\node-event-generator.js:280:22)
at NodeEventGenerator.enterNode (D:\Projects\myApp\node_modules\eslint\lib\util\node-event-generator.js:294:14)
at CodePathAnalyzer.enterNode (D:\Projects\myApp\node_modules\eslint\lib\code-path-analysis\code-path-analyzer.js:608:23)
at Traverser.enter (D:\Projects\myApp\node_modules\eslint\lib\linter.js:956:32)
at Traverser.__execute (D:\Projects\myApp\node_modules\estraverse\estraverse.js:397:31)
at Traverser.traverse (D:\Projects\myApp\node_modules\estraverse\estraverse.js:501:28)
Seems to fail here:
const properties = node.id.properties;
// Iterate through the destructured properties and report them
properties.forEach((item) => {
properties is undefined
When I set the rule to Off in eslintrc I get another error with require-super-in-init
"eslint": "v4.2.0"
"ember-cli": "2.12.2",
"ember-cli-eslint": "^4.2.2",
It seems the issue was with this:
init: Ember.on("init", function() {
setInterval(function() {
if (Ember.$(window).width() < 1040) {
Ember.$(".listings-management").css("width", Ember.$(window).width());
} else {
Ember.$(".listings-management").css("width", "100%");
}
}, 1000);
}),
Changing this fixed the issue:
init() {
this._super(...arguments);
setInterval(function() {
if (Ember.$(window).width() < 1040) {
Ember.$(".listings-management").css("width", Ember.$(window).width());
} else {
Ember.$(".listings-management").css("width", "100%");
}
}, 1000);
},
I ended up debugging the Node instance running ESLint app and figured this out.
Thanks
I'm getting Cannot read property 'forEach' of undefined as well now.
@rwwagner90 Any idea what code is causing the error?
@rwwagner90 can you share the full stack trace and possibly an example snippet that reproduces the issue?
I think it was potentially caused by not ignoring the concat-stats-for directory. I'm not seeing the issue anymore. If it comes back, I will let you know.
Thanks @rwwagner90 for the direction... I ran into the same issue with an addon with no .eslintignore file. Re-generating the file with ember init command fixed the issue. Indeed, eslint was running inside the dist directory (with ie9-transpiled files inside)...
To reproduce the issue (though I have to say it's not really standard):
-
ember addon new-addon - in
.eslintignoreremove the line aboutdist - add
ie9to targets `config/targets.js - `ember install ember-cli-babel' (to get the ember-cli-babel@7)
- `ember install ember-cli-flash' (<- seems the issue was with this transpiled file: https://github.com/poteto/ember-cli-flash/blob/master/app/initializers/flash-messages.js)
-
yarn build -
yarn lint:js
In case it is helpful to others... I was seeing this same error and stack trace but it was because I needed to add /electron-out/ to .eslintignore