Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: Path must be a string. Received undefined on v1.6.1 on node 6 #301

Closed
nfcampos opened this issue May 3, 2016 · 5 comments
Closed
Milestone

Comments

@nfcampos
Copy link

nfcampos commented May 3, 2016

I get this stacktrace on running eslint on node 6

TypeError: Path must be a string. Received undefined
    at assertPath (path.js:7:11)
    at Object.extname (path.js:1429:5)
    at EventEmitter.checkFileExtension (/Users/nuno/cp/j2/node_modules/eslint-plugin-import/lib/rules/extensions.js:43:36)
    at emitOne (events.js:101:20)
    at EventEmitter.emit (events.js:188:7)
    at NodeEventGenerator.enterNode (/Users/nuno/cp/j2/node_modules/eslint/lib/util/node-event-generator.js:40:22)
    at CodePathAnalyzer.enterNode (/Users/nuno/cp/j2/node_modules/eslint/lib/code-path-analysis/code-path-analyzer.js:607:23)
    at CommentEventGenerator.enterNode (/Users/nuno/cp/j2/node_modules/eslint/lib/util/comment-event-generator.js:97:23)
    at Controller.traverser.traverse.enter (/Users/nuno/cp/j2/node_modules/eslint/lib/eslint.js:886:36)
    at Controller.__execute (/Users/nuno/cp/j2/node_modules/estraverse/estraverse.js:397:31)

I guess on this line https://github.com/benmosher/eslint-plugin-import/blob/master/src/rules/extensions.js#L27 resolve is returning undefined because it doesn't find the module and as such path.extname throws on the next line

@benmosher
Copy link
Member

Ah, right. It's weird none of the tests are failing on that in CI. Also resolve shouldn't return undefined in general, IIRC.

Can you post your eslintrc settings and (if possible) the line of code that's causing this? (if you're able to trace it back)

Also hopefully #296 fixes this anyway.

@nfcampos
Copy link
Author

nfcampos commented May 3, 2016

I'll try to find some time to find the line that is causing this. In the meantime here's the eslintrc:

{
  "extends": [
    "eslint:recommended",
    "plugin:react/recommended",
    "plugin:import/errors",
    "plugin:import/warnings",
    "plugin:ava/recommended"
  ],
  "parser": "babel-eslint",
  "parserOptions": {
    "sourceType": "module",
    "ecmaFeatures": {
      "jsx": true,
      "experimentalObjectRestSpread": true
    },
    "ecmaVersion": 6
  },
  "rules": {
    "comma-dangle": 0,
    "no-unused-vars": 1,
    "no-console": 0,
    "jsx-quotes": [1, "prefer-single"],
    "react/display-name": [0],
    "react/prop-types": [0],
    "import/no-extraneous-dependencies": 2,
    "import/extensions": 1,
    "import/order": 1,
  },
  "env": {
    "browser": true,
    "node": true,
    "es6": true
  },
  "plugins": [
    "import",
    "react",
    "ava"
  ],
  "settings": {
    "import/ignore": [
      "node_modules",
      \.css$
    ],
    import/resolver: webpack
  }
}

@benmosher
Copy link
Member

I think you're probably right, it's likely an unresolved import. I double-checked, and #296 should fix it; it coalesces back to the source file's import path if it is unresolved.

So probably no need to look closely unless #296 doesn't actually fix it.

@benmosher benmosher added this to the next milestone May 5, 2016
@radekbenkel
Copy link
Contributor

radekbenkel commented May 5, 2016

FYI: In my case it's TypeError: Path must be a string. Received null. Using master solves that issue.

@benmosher
Copy link
Member

Just published v1.7.0, should resolve this. Let me know if it doesn't and I can reopen. 😄

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

No branches or pull requests

3 participants