by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Jul 26 14:51
    screetBloom opened #719
  • Jul 17 02:52
    zhizhunbao995 edited #718
  • Jul 16 06:30
    zhizhunbao995 opened #718
  • Jul 13 16:23
    conartist6 commented #712
  • Jun 25 08:58
    N1kto commented #316
  • Jun 15 02:16
    tjx666 commented #717
  • Jun 15 00:06
    eventualbuddha commented #717
  • Jun 14 11:33
    tjx666 edited #717
  • Jun 14 11:07
    tjx666 edited #717
  • Jun 14 11:06
    tjx666 opened #717
  • Jun 12 17:48
    Daniel15 synchronize #716
  • Jun 12 00:53
    Daniel15 commented #559
  • Jun 12 00:53
    Daniel15 opened #716
  • Jun 11 07:33
    bromagosa commented #370
  • Jun 09 15:14
    conartist6 edited #712
  • Jun 07 17:47
    conartist6 synchronize #712
  • Jun 07 17:39
    conartist6 commented #623
  • Jun 07 17:35
    conartist6 commented #706
  • Jun 07 17:34
    conartist6 commented #706
  • Jun 07 17:30
    conartist6 closed #714
Ben Newman
@benjamn
mostly comments disappearing, sometimes trailing/dangling comments becoming leading
Jeroen Engels
@jfmengels
ok, so I should always check the diffs
Ben Newman
@benjamn
yeah :/
if the comment was a leading comment to begin with, it will usually survive just fine, so the tweaks I mentioned are usually finding ways to turn weird trailing comments into leading comments
Jeroen Engels
@jfmengels
I see
Jeroen Engels
@jfmengels
Btw, you might like the use I'm making of jscodeshift/recast: I'm working on generating the lodash/fp docs (a variant of lodash where all arguments are in a different order, among other things), and I'm using it in order to update the examples written in the JSDoc of the sources (so they need to be generated automatically)
Thought you'd like to know
Ben Newman
@benjamn
neat!
that does make sense
if you're only modifying the text of comments, they should get reprinted in-place, without any trouble
even so, figuring out which nodes the comments are attached to (and writing code that gets it right every time) can be tricky
please let me know how it goes :)
Jeroen Engels
@jfmengels
I'm not changing the text of comments (for now, hoping to not having to resort to custom cases if possible), but the console.log()s don't make much sense with lodash/fp in the examples, that's why I wanted them gone.
Sure, will do!
(and just filtering out the lines with console.logs does the trick, so we're good there)
Ben Newman
@benjamn
yeah, that's another thing: sometimes it's a lot easier to do a dumb preprocessing step than it is to figure out how to write a smart transform
Jeroen Engels
@jfmengels
Yes, lesson learned ;) (or so I hope)
Ben Newman
@benjamn
it's all about your productivity :)
Jeroen Engels
@jfmengels
Well, I spent a few evenings on this, where I kept thinking in the "jscodeshift box", not outside the box
Ok, off to bed. Thanks a lot @benjamn, and I'll let you know how it goes ;)
Ben Newman
@benjamn
good luck & take care!
Jeroen Engels
@jfmengels
Hey!
I'm off to bed, but just wanted to let you know that my (second) PR for the lodash docs has been merged lodash/lodash#1963.
Original core docs: https://github.com/lodash/lodash/blob/4.3.0/doc/README.md
Generated fp docs: https://gist.github.com/jfmengels/6b973b69c491375117dc#_pullatindexes-array (scroll a little bit down)
Have a good one ;)
Benjamin Tan
@demoneaux
Hi @benjamn I sent in a few PRs recently, wonder if you've seen them?
demetriusnunes
@demetriusnunes
hi guys, wonder if you could help me. I'm just starting with codemods, and I wonder how could use it to instrument my code, ie, add logging statements at the beginning of each function. has anyone done that?
Brendan Annable
@BrendanAnnable
Buzzing in here!
Any thoughts on adding jsdoc/closure compiler annotations support? Or adding some plugin architecture for externally adding support?
My goal is to use recast as a general programmatic refactoring tool, but I need it to refactor the typing information along with it.
There is a parser here https://github.com/hegemonic/catharsis but it does not appear to support codegen.
jsdoc also has an internal parser that you can't really access properly, but again no codegen either.
Ben Newman
@benjamn
@BrendanAnnable is there an AST specification for that parser? And, at a minimum, does it generate AST nodes that have .loc.{start,end} information?
Brendan Annable
@BrendanAnnable
@benjamn So that parser only parses the typing information, so I doubt it would have .loc information. i.e. if you have a comment e.g. /** @type {Array<SomeFancyType>} */ it won't actually parse the entire comment, just the Array<SomeFancyType> part.
I only briefly looked into it though
jsdoc have their own "regex parser" infront of it https://github.com/jsdoc3/jsdoc/blob/master/lib/jsdoc/doclet.js#L110
Matheus Fernandes
@matheuss
Hi guys! I'm reading a file that have this array:
plugins: [],
With recast, I'm adding to elements and then saving the file. Turns out that recast does this:
plugins: ["hyperpanic", "hypercwd"],
Any change that I could print this?
plugins: [
   "hyperpanic",
   "hypercwd"
],
Brendan Annable
@BrendanAnnable
Recast doesn't have the ability to print according to a style guide.
There was a github issue requesting such a feature.
Matheus Fernandes
@matheuss
😔
Thanks!
Ari Porad
@ariporad

Hi All, quick question: Is there a way to use scope to eliminate unused variables? For example, if I have this:

function () {
  var x = 5;
  doFoo(123);
};

I want to convert it to:

function () {
  // Notice: No `x`
  doFoo(123);
}

Thanks!

Brendan Annable
@BrendanAnnable
@ariporad Maybe collect two pieces of information in a single traversal and analze after. e.g. Collect each declared Identifier and its associated scope, and also collect all used variables and their associated scope (using scope.lookup) and then compare the two for disparities.
Ari Porad
@ariporad
Ok, thanks!
Brendan Annable
@BrendanAnnable
@benjamn Is there any plans for scope.js to support defaulted function params? It currently treats them as global variables.
(ast-types)
Lucas Bento
@lucasbento
Do I have to enable something for recast to parse async/await?
I'm not finding anything about it on the repository
Ben Newman
@benjamn
@BrendanAnnable that's definitely an oversight/bug, and I'd be happy to review a pull request!
@lucasbento try recast.parse(source, { parser: <any object with a .parse method> })
Lucas Bento
@lucasbento
@benjamn: thank you, I fixed it by using babylon parser
sorry I forgot to mention that here
Ben Newman
@benjamn
np, glad you figured it out