I got this error:
name.indexOf is not a function
TypeError: name.indexOf is not a function
at isAbsolute (/Users/lutsenko/Projects/mercdev/eventicious/eventicious_mobile_web/node_modules/eslint-plugin-import/lib/core/importType.js:30:15)
at apply (/Users/lutsenko/Projects/mercdev/eventicious/eventicious_mobile_web/node_modules/lodash.cond/index.js:140:25)
at /Users/lutsenko/Projects/mercdev/eventicious/eventicious_mobile_web/node_modules/lodash.cond/index.js:2261:11
at apply (/Users/lutsenko/Projects/mercdev/eventicious/eventicious_mobile_web/node_modules/lodash.cond/index.js:138:25)
at /Users/lutsenko/Projects/mercdev/eventicious/eventicious_mobile_web/node_modules/lodash.cond/index.js:1192:12
at resolveImportType (/Users/lutsenko/Projects/mercdev/eventicious/eventicious_mobile_web/node_modules/eslint-plugin-import/lib/core/importType.js:73:10)
at reportIfMissing (/Users/lutsenko/Projects/mercdev/eventicious/eventicious_mobile_web/node_modules/eslint-plugin-import/lib/rules/no-extraneous-dependencies.js:57:32)
at EventEmitter.handleRequires (/Users/lutsenko/Projects/mercdev/eventicious/eventicious_mobile_web/node_modules/eslint-plugin-import/lib/rules/no-extraneous-dependencies.js:131:11)
at emitOne (events.js:101:20)
at EventEmitter.emit (events.js:188:7)
This error happened because not all time type of name is string.
Example log with console.log(typeof name, name); on line 30 in lib/core/importType.js file.
string process/browser.js
string ./readable.js
string ./readable.js
string ./writable.js
string ./writable.js
string events
string events
string inherits
string inherits
string ./readable.js
string ./readable.js
string ./writable.js
string ./writable.js
string ./duplex.js
string ./duplex.js
string ./transform.js
string ./transform.js
string ./passthrough.js
string ./passthrough.js
number 6
name.indexOf is not a function
TypeError: name.indexOf is not a function
at isAbsolute (/Users/lutsenko/Projects/mercdev/eventicious/eventicious_mobile_web/node_modules/eslint-plugin-import/lib/core/importType.js:31:15)
at apply (/Users/lutsenko/Projects/mercdev/eventicious/eventicious_mobile_web/node_modules/lodash.cond/index.js:140:25)
at /Users/lutsenko/Projects/mercdev/eventicious/eventicious_mobile_web/node_modules/lodash.cond/index.js:2261:11
at apply (/Users/lutsenko/Projects/mercdev/eventicious/eventicious_mobile_web/node_modules/lodash.cond/index.js:138:25)
at /Users/lutsenko/Projects/mercdev/eventicious/eventicious_mobile_web/node_modules/lodash.cond/index.js:1192:12
at resolveImportType (/Users/lutsenko/Projects/mercdev/eventicious/eventicious_mobile_web/node_modules/eslint-plugin-import/lib/core/importType.js:74:10)
at reportIfMissing (/Users/lutsenko/Projects/mercdev/eventicious/eventicious_mobile_web/node_modules/eslint-plugin-import/lib/rules/no-extraneous-dependencies.js:57:32)
at EventEmitter.handleRequires (/Users/lutsenko/Projects/mercdev/eventicious/eventicious_mobile_web/node_modules/eslint-plugin-import/lib/rules/no-extraneous-dependencies.js:131:11)
at emitOne (events.js:101:20)
at EventEmitter.emit (events.js:188:7)
I don't know why name is number. Can you help me? My environment:
babel-eslintairbnb-basepackage.json:
"eslint": "^3.7.1",
"eslint-config-airbnb-base": "^8.0.0",
"eslint-loader": "^1.3.0",
"eslint-plugin-import": "^2.0.0",
Hi @immuzov! Thanks for reporting this.
Seems like it's triggered by the no-extraneous-dependencies rule, at either one of these calls to reportIfMissing (the first one if you're doing).
A few things I'd like you to try, if you don't mind:
require calls with a number parameter. Can you find out if you have something that looks like require(6) somewhere?By the way, is this blocking you, or is this just a crash you happened to notice and investigate?
I found why this error happen. Sorry, it's my mistake. I didn't ignore node_modules. It's not bug. Thank you for help. Sorry for my English :D
Well, we still check for require(6). That's obviously not allowed, but it shouldn't make the plugin crash. It could happen when people have ESLint in their editor and they type something really quickly.
I'll try to make a bug fix before the next release.
@immuzov If you ever feel like it, I'd be very curious where in your node_modules there is a require call to a number. It's not needed, but I'm just curious ;)
Sorry but i don't know where in my node_modules there is a require call to a number.
No problem. I found similar code in my node_modules:
{
33:[function(require,module,exports){
module.exports=require(31)
}]
// ...
}
I think it's something built by Webpack or Rollup.