Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add syntax highlighting to Yarn lockfiles #4761

Merged
merged 5 commits into from
Mar 10, 2020

Conversation

arcanis
Copy link
Contributor

@arcanis arcanis commented Jan 6, 2020

Description

Yarn 1 uses a Yaml-like format which is good enough with the YAML highlighting, and Yarn 2 will switch to the good old regular YAML. Adding syntax highlighting to this file will help JS developers to review the changes, potentially preventing security issues.

Checklist:

@Alhadis
Copy link
Collaborator

Alhadis commented Jan 7, 2020

FYI: you can use Lightshow to show how files would be rendered with syntax highlighting. 😉

Copy link
Contributor

@pchaigno pchaigno left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for taking the time to contribute to Linguist!

Could you please add one of the two sample files you pointed to to samples/YAML/?

From the few examples I've looked at on GitHub, these files appear to be generated (?). Maybe we should add them to generated.rb?

@Alhadis
Copy link
Collaborator

Alhadis commented Jan 7, 2020

Maybe we should add them to generated.rb?

#4459, #4445

@pchaigno
Copy link
Contributor

pchaigno commented Jan 7, 2020

Ah, thanks @Alhadis!

@Alhadis Alhadis changed the title Adds proper highlighting for Yarn's lockfile Add syntax highlighting to Yarn lockfiles Jan 8, 2020
@stale
Copy link

stale bot commented Feb 7, 2020

This pull request has been automatically marked as stale because it has not had recent activity, and will be closed if no further activity occurs. If this pull request was overlooked, forgotten, or should remain open for any other reason, please reply here to call attention to it and remove the stale status. Thank you for your contributions.

@stale stale bot added the Stale label Feb 7, 2020
@stale
Copy link

stale bot commented Feb 21, 2020

This pull request has been automatically closed because it has not had activity in a long time. Please feel free to reopen it or create a new issue.

@stale stale bot closed this Feb 21, 2020
@Alhadis Alhadis reopened this Feb 21, 2020
@stale stale bot removed the Stale label Feb 21, 2020
@arcanis
Copy link
Contributor Author

arcanis commented Feb 27, 2020

Samples are here, sorry for the wait 🙂

@arcanis
Copy link
Contributor Author

arcanis commented Feb 27, 2020

Hm keeping both versions seems to make the tests unhappy - how should I fix it? Add a single version?

Also, should I add yarn.lock to vendor.yml?

@Alhadis
Copy link
Collaborator

Alhadis commented Feb 27, 2020

Hm keeping both versions seems to make the tests unhappy - how should I fix it?

Move the contents of samples/YAML/yarn/* to just samples/YAML/*. The exact error is here:

Errno::EISDIR: Is a directory @ io_fread - /home/runner/work/linguist/linguist/samples/YAML/yarn

Also, should I add yarn.lock to vendor.yml?

That shouldn't be necessary as YAML is a data-type language, so it won't skew or show up in a repository's language stats.

@arcanis
Copy link
Contributor Author

arcanis commented Feb 27, 2020

Move the contents of samples/YAML/yarn/* to just samples/YAML/*. The exact error is here:

The problem is that the detection for both yarn formats has the same filename, so I can't have both in the same directory.

@Alhadis
Copy link
Collaborator

Alhadis commented Feb 27, 2020

Then omit whichever one has the conflicting filename; only one is needed.

Which reminds me; this should be going in samples/YAML/filenames if it's an entry being added to the filenames array (instead of extensions).

@Alhadis
Copy link
Collaborator

Alhadis commented Feb 27, 2020

Ouch. I just saw the size of the file you're adding... a 26,114-line sample is probably a bit overkill. 😉

Could you add a much more minimal sample, please? Something around the ~1-5 KBs range will do. Otherwise, it's going to nuke our classifier.

(I should have checked this first, knowing the size of Yarn lockfiles…)

Copy link
Member

@lildude lildude left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please update the OP to link to the source of the sample file and the license it is covered by as the file in the PR isn't the one you linked to in the OP.

@arcanis
Copy link
Contributor Author

arcanis commented Mar 10, 2020

@lildude the sample is in the OP, it's the lockfile from the Yarn project, licensed BSD 2-clause.

@lildude
Copy link
Member

lildude commented Mar 10, 2020

@lildude the sample is in the OP, it's the lockfile from the Yarn project, licensed BSD 2-clause.

That's not the same file. https://github.com/yarnpkg/berry/blob/master/yarn.lock is 14757 lines long. The sample you've included is only 30 lines long.

@arcanis
Copy link
Contributor Author

arcanis commented Mar 10, 2020

Yes, because

Could you add a much more minimal sample, please? Something around the ~1-5 KBs range will do. Otherwise, it's going to nuke our classifier.

I trimmed the file to a more reasonable size. Check the start of the file, it's the same content.

@lildude
Copy link
Member

lildude commented Mar 10, 2020

I trimmed the file to a more reasonable size. Check the start of the file, it's the same content.

Ah, that explains it and isn't clear. I've updated the OP to reflect this and the license. Thanks.

@lildude lildude merged commit 506e013 into github-linguist:master Mar 10, 2020
@github-linguist github-linguist locked as resolved and limited conversation to collaborators Jun 17, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants