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 support for Browserslist #5099

Merged

Conversation

voskresla
Copy link
Contributor

@voskresla voskresla commented Nov 30, 2020

Description

This PR add support for Browserslist configs.

Syntax highlighting based on https://github.com/browserslist/browserslist-vscode.
cc @ai

Checklist:

  • I am adding a new language.
    • The extension of the new language is used in hundreds of repositories on GitHub.com
    • I have included a real-world usage sample for all extensions added in this PR:
    • I have included a syntax highlighting grammar:
    • I have updated the heuristics to distinguish my language from others using the same extension.

lib/linguist/languages.yml Outdated Show resolved Hide resolved
@voskresla voskresla changed the title WIP: Add support for Browserslist Add support for Browserslist Nov 30, 2020
@voskresla voskresla changed the title Add support for Browserslist WIP: Add support for Browserslist Nov 30, 2020
@ai
Copy link
Contributor

ai commented Nov 30, 2020

Adding Browserslist config highlighting is important because it is default way to specify target browsers in Autoprefixer and Babel and it is already used in 350K public repositories.

lib/linguist/languages.yml Outdated Show resolved Hide resolved
samples/browserslist/.browserslistrc Outdated Show resolved Hide resolved
@Alhadis
Copy link
Collaborator

Alhadis commented Nov 30, 2020

Usage checks out (I happen to be familiar with the format, so I'm skipping the usual sample harvest routine). Just a small nit to correct and we should be good to go. 👍

@voskresla voskresla changed the title WIP: Add support for Browserslist Add support for Browserslist Nov 30, 2020
lib/linguist/languages.yml Show resolved Hide resolved
@Alhadis
Copy link
Collaborator

Alhadis commented Dec 1, 2020

@voskresla You might want to set core.ignorecase globally so it's configured for all future projects:

$ git config --global core.ignorecase false

Or add to your ~/.gitconfig file:

[core]
	ignorecase = false

The --local switch sets a config setting for one particular repository directory only (stored in .git/config). So it won't persist across other projects, including future checkouts of Linguist.

@voskresla
Copy link
Contributor Author

)

@Alhadis
Copy link
Collaborator

Alhadis commented Dec 1, 2020

LGTM. 👍

@lildude, I say we :shipit:.

@wspwebben
Copy link

wspwebben commented Dec 1, 2020

@ai mentioned browserslist config name is deprecated, does it makes sense to drop it from samples? We should keep support for existing configs, so it's only about example file.

@Alhadis
Copy link
Collaborator

Alhadis commented Dec 1, 2020

@wspwebben We don't judge formats on their deprecation– or recommendation-status, only their real-world distribution. Discouraging the use of a filename won't change the fact there are over a million files on GitHub using that particular format and filename.

@wspwebben
Copy link

wspwebben commented Dec 1, 2020

@wspwebben We don't judge formats on their deprecation– or recommendation-status, only their real-world distribution. Discouraging the use of a filename won't change the fact there are over a million files on GitHub using that particular format and filename.

That's why we should keep support for that format in configs, so syntax highlight would still work for these files, but there's no need to keep that format as an example in samples

@Alhadis
Copy link
Collaborator

Alhadis commented Dec 1, 2020

but there's no need to keep that format as an example in samples

There is. The samples directory isn't for human consumption—it's to train our Bayesian classifier, which disambiguates files based on the frequency of certain tokens. The more samples Linguist has, the more accurate its predictions are.

@wspwebben
Copy link

Got it, thank you for clarification :D

@Alhadis
Copy link
Collaborator

Alhadis commented Dec 1, 2020

No problem! 😉 That's also the reason we prefer "real-world" samples instead of just "Hello, world" examples, BTW:—they need to be an accurate rendition of the sort of files Linguist will encounter in-the-wild after it starts indexing the new language.

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.

LGTM.

This won't go live on GitHub.com until a new release is made which I won't be able to do until mid-to-late January at the earliest.

@lildude lildude merged commit 23409e0 into github-linguist:master Dec 2, 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.

5 participants