Code Monkey home page Code Monkey logo

Comments (4)

ikatyang avatar ikatyang commented on June 8, 2024

The current rule of attaching leading/middle comments is to attach them to the largest node next to it, for example the following comment is attached to mapping instead of mappingItem/mappingKey/plain, breaking the consistency does not seem to be a good idea IMO.

# comment
key: value

And the linked issue seems to be unrelated to this issue, where the ignore comment already worked with sequence.leadingComments, it just did not recognize the sequence.middleComments case.

from yaml-unist-parser.

fisker avatar fisker commented on June 8, 2024

In that Prettier issue, it seems user mean to ignore that sequenceItem, and prettier-ignore normally in leadingComments, should this special case handle in Prettier or here?

Does sequence.middleComments only appear before the first child?

from yaml-unist-parser.

ikatyang avatar ikatyang commented on June 8, 2024

In that Prettier issue, it seems user mean to ignore that sequenceItem, ...

There is only one sequence item in the sequence so I'm not sure if they meant sequence or sequenceItem given that both of them have the exact same range. And changing the comment attaching from sequence to sequenceItem would be a breaking change for Prettier since the prettier-ignore range would be wider.

...and prettier-ignore normally in leadingComments, should this special case handle in Prettier or here?

Since the ignore comment is a Prettier-specific feature, I'd say it should be handled on the Prettier side.

Does sequence.middleComments only appear before the first child?

Since the tag/anchor can only appear in front of the node, Yes.

https://github.com/ikatyang/yaml-unist-parser/blob/92ea25423fc23bc160477d21cc51d7beeace2a14/src/types.ts#L35-L36

https://github.com/ikatyang/yaml-unist-parser/blob/92ea25423fc23bc160477d21cc51d7beeace2a14/src/types.ts#L44-L45

https://github.com/ikatyang/yaml-unist-parser/blob/92ea25423fc23bc160477d21cc51d7beeace2a14/src/types.ts#L49-L50

https://github.com/ikatyang/yaml-unist-parser/blob/92ea25423fc23bc160477d21cc51d7beeace2a14/src/types.ts#L54-L55

from yaml-unist-parser.

fisker avatar fisker commented on June 8, 2024

Thank you! I'll try to fix that issue.

from yaml-unist-parser.

Related Issues (18)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.