ternjs / tern

A JavaScript code analyzer for deep, cross-editor language support
https://ternjs.net/
MIT License
4.25k stars 378 forks source link

Find definition in a jsx project #1018

Open knobo opened 5 years ago

knobo commented 5 years ago

Run tern-find-definition in emacs when standing on InputElement when I have the jsx extention, it woks.

How can I make tern look for jsx files by default?

import InputElement from './InputElement.jsx';
^[[1;2CRequest: {
  "query": {
    "end": 98,
    "file": "src/input/InputElementBlock.jsx",
    "type": "definition",
    "variable": null
  }
}
Response: {
  "origin": "src/input/InputElement.jsx",
  "start": 145,
  "end": 150,
  "file": "src/input/InputElement.jsx",
  "contextOffset": 50,
  "context": "nst block = bemCn('input');\n\nexport default class "
}

But without the jsx extention Like this:

import InputBlock from './InputBlock';

It does not work.

Request: {
  "query": {
    "end": 153,
    "file": "src/input/InputElementBlock.jsx",
    "type": "definition",
    "variable": null
  }
}
Response: {
  "origin": "node_modules/react-transition-group/TransitionGroup.js"
}
othree commented 5 years ago

I am think to add a official jsx plugin to deal with this.