Skip to content
This repository has been archived by the owner on Jan 19, 2019. It is now read-only.

eslint throwing "cannot read property 'name' of null" #593

Closed
pietrofxq opened this issue Jan 7, 2019 · 9 comments
Closed

eslint throwing "cannot read property 'name' of null" #593

pietrofxq opened this issue Jan 7, 2019 · 9 comments
Labels

Comments

@pietrofxq
Copy link

pietrofxq commented Jan 7, 2019

What version of TypeScript are you using?
3.1.1

What version of typescript-eslint-parser are you using?
21.0.2

Eslint version: 5.12.0

What code were you trying to parse?

declare module "@ajs/context-path" {
  export default function (): string;
}

and

const BaseState = ({ title, hint, src, ...props }) => (
  <MessageBox {...props}>
    <MessageImage src={src} />
    <MessageText>
      <MainMessage>{title}</MainMessage>
      <p>{hint}</p>
    </MessageText>
  </MessageBox>
)

What did you expect to happen?
No eslint errors

What happened?
image

.eslintrc:

{
  "extends": [
    "eslint:recommended",
    "plugin:react/recommended",
    "@atlassian/atlassian-fecq",
    "prettier"
  ],
  "settings": {
    "react": {
      "pragma": "React",
      "version": "^16.5.2"
    }
  },
  "parser": "typescript-eslint-parser",
  "env": {
    "es6": true,
    "browser": true,
    "node": true
  },
  "globals": {
    "I18n": true
  },
  "plugins": [
    "react",
    "typescript"
  ],
  "parserOptions": {
    "sourceType": "module",
    "ecmaFeatures": {
      "experimentalObjectRestSpread": true,
      "jsx": true
    }
  }
}

Am I missing something? Using typescript-eslint-parser disables jsx parsing even though I have jsx:true in parserOptions and throws this cannot read property 'name' of null error.

@armano2
Copy link
Contributor

armano2 commented Jan 7, 2019

"parserOptions": {
    "sourceType": "module",
    "jsx": true
}

@pietrofxq
Copy link
Author

@armano2 thanks... that got rid of the react issues. Now I still have "cannot read property 'name' of null"

@pietrofxq
Copy link
Author

This seems to be an issue with vscode-eslint. Running eslint in the command line doesn't give me such error, it only shows up in the vscode 'problems' panel

@armano2
Copy link
Contributor

armano2 commented Jan 7, 2019

can you try setting up in vscode

eslint.options: options to configure how ESLint is started using the ESLint CLI Engine API. Defaults to an empty option bag. An example to point to a custom .eslintrc.json file is:

{
  "eslint.options": { "configFile": "path/.eslintrc.json" }
}

looks like its not using typescript-eslint-parser

@pietrofxq
Copy link
Author

same issue :/ I can see that vscode is reading the file because when I change typescript-eslint-parser to babel-eslint the error changes instantly. Looks like everything is working properly despite of the error showing up in the "problems" tab, I'll live with it for now

@armano2
Copy link
Contributor

armano2 commented Jan 8, 2019

i was able to reproduce it in console :)

and looks like issue is in typescript-estree

@armano2
Copy link
Contributor

armano2 commented Jan 8, 2019

ok issue is here https://github.com/eslint/typescript-eslint-parser/blob/master/analyze-scope.js#L323

there is no support for anonymous functions :)

@pietrofxq pietrofxq changed the title jsx not working and eslint retuning "cannot read property 'name' of null" eslint throwing "cannot read property 'name' of null" Jan 8, 2019
@JamesHenry
Copy link
Member

Should hopefully be fixed by #596

@armano2
Copy link
Contributor

armano2 commented Jan 12, 2019

to be precise by this commit: 08f5a74

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

3 participants