git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [GSoC][PATCH v2] Add a diff driver for JavaScript languages.

From
Glen Choo <chooglen@google.com>
Date
Mar 15, 2022, 21:34 UTC
Message-ID
<kl6l8rtayk5o.fsf@chooglen-macbookpro.roam.corp.google.com>
In-Reply-To
<xmqq1qz3dnqu.fsf@gitster.g>
Junio C Hamano <gitster@pobox.com> writes:
Show 13 quoted lines
> Glen Choo <chooglen@google.com> writes:
>
>> Interesting, I'll take note. I'm still personally not keen on supporting
>> CommonJS-only patterns when we are purportedly trying to show diffs for
>> JavaScript, but if we think this fits the style, I'm happy to oblige.
>
> The question is, with these patterns that are aware of CommonJS
> convention, would your bog-standard-and-boring vanilla JS code be
> detected incorrectly?  Becoming aware of popular conventions without
> hurting others would be a good thing.
>
> And the "popular conventions" does not have to be limited to
> CommonJS/Node.

From the perspective of "'exports' is a special name", yes, we could detect vanilla JS code 'incorrectly' because, in vanilla JS, the names 'exports' or 'module.exports' are not special. So perhaps, one could imagine a browser-side script that deals with "imports" and "exports" as part of their business:

  const exports = {
    quantity: 1,
    type: 'boxes',
  };
  exports.getQuantity = () => {
    foo();
  };

This diff driver would mistakenly detect `exports.getQuantity = () => {`.

Although, the more I think about it, the spirit of this patch seems to be "we want to show headers whenever we think we are in a function", so we don't actually need to treat 'exports' or 'module.exports' specially at all, e.g. this case should also pass our diff driver tests:

  const foo = {};
  foo.RIGHT = () => {
    ChangeMe();
  };

and if we do this, we will correctly handle 'exports' and 'module.exports' anyway by virtue of them being plain old JS objects.

Previous: Junio C HamanoNext: xing zhi jiang
Message 15 of 25 in “userdiff: add buildin diff driver for JavaScript language”
  1. xing zhi jiangMar 4, 2022
  2. [GSoC][PATCH 1/1] Add a diff driver for JavaScript languages.xing zhi jiang, Mar 4, 2022
  3. Johannes SixtMar 5, 2022
  4. xing-zhi jiangMar 7, 2022
  5. Johannes SixtMar 8, 2022
  6. xing zhi jiangMar 12, 2022
  7. Johannes SixtMar 5, 2022
  8. [GSoC][PATCH v2] Add a diff driver for JavaScript languages.xing zhi jiang, Mar 12, 2022
  9. Johannes SixtMar 13, 2022
  10. xing zhi jiangApr 3, 2022
  11. Glen ChooMar 14, 2022
  12. Johannes SixtMar 15, 2022
  13. Glen ChooMar 15, 2022
  14. Junio C HamanoMar 15, 2022
  15. Glen ChooMar 15, 2022
  16. xing zhi jiangApr 3, 2022
  17. xing zhi jiangApr 3, 2022
  18. xing zhi jiangApr 3, 2022
  19. [GSoC][PATCH v3] Add a diff driver for JavaScript languages.xing zhi jiang, Apr 3, 2022
  20. Johannes SixtApr 3, 2022
  21. Ævar Arnfjörð BjarmasonApr 4, 2022
  22. Johannes SixtApr 4, 2022
  23. Junio C HamanoApr 4, 2022
  24. Ævar Arnfjörð BjarmasonApr 5, 2022
  25. Glen ChooApr 4, 2022

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.