如何在 .babelrc 文件上设置和保留语言语法类型

How to set and keep language syntax type on .babelrc file

在 Atom 1.18 中,每次我打开编辑器时,我的 .babelrc 文件默认为 JSON 文件类型,这使得语法突出显示看起来很不对。而且我必须不断将它改回 Babel 类型。

如何修复(暂时):

每次关闭和打开 .babelrc 文件时都必须重置它。

现在我意识到这是一个很少被触及的文件,但了解如何针对其他文件类型修复此问题会很有帮助。

在 config.cson

中有一种非常具体的设置方法

https://discuss.atom.io/t/how-do-i-make-atom-recognize-a-file-with-extension-x-as-language-y/26539

http://flight-manual.atom.io/using-atom/sections/basic-customization/#configuring-with-cson

"*":
  core:
    customFileTypes:
      "source.js.jsx": [
        "js"
        "es6"
        "es"
        "babel"
        "babelrc"
        "jsx"
      ]

我删除这些错误的方法是使文件 JSON 兼容。 不是完美的解决方案,但有效。

//.babelrc
{
  "plugins": [
    "transform-class-properties"
  ],
  "presets": [
    ["es2015", { "modules": false}],
    "react",
  ],
}