json - 为什么我的 GitHub 存储库中的代码是红色的以及如何禁用它?

标签 json github

我的代码在语法上是正确的,并且运行良好。

那么为什么 linter 将其标记为红色?

这很烦人,我不喜欢它的样子。

这是一个 .json 文件。

enter image description here

最佳答案

My code is syntactically correct

不,不是:JSON doesn't permit comments .

解决方法是使用 Linguist override通过添加 .gitattributes file内容如下:

*.json linguist-language=JavaScript

这告诉 GitHub 将存储库中的 .json 文件视为完整的 JavaScript(当然,允许注释)而不是 JSON。

GitHub appears to cache Linguist highlighting data ,因此在新的突出显示出现之前,可能需要修改、提交和再次推送任何现有的 JSON 文件。

关于json - 为什么我的 GitHub 存储库中的代码是红色的以及如何禁用它?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48634211/

相关文章:

PHP 在 JSON 数组中传回带有特殊字符的对象

javascript - 无法使用javascript访问json对象

json - 使用Grails中预定义的ID从JSON创建对象

git push -u origin master 致命: unable to update url base from redirection:

git - 为什么在设置 github pages 时需要丢失未跟踪的文件?

github - 如何删除 Github 环境

git - Vagrant 测试 Chef Recipe - 但如何处理私有(private) git

java - 如何处理具有 Class<?> 的 Java 类以使用 Gson 转换为 JSON

regex - Github "Branch name pattern"否定

ruby-on-rails - 如何覆盖 'as_json' 或 'to_json' 方法,以便 'respond_to' 不包含指定信息?