【问题标题】:How to set and keep language syntax type on .babelrc file如何在 .babelrc 文件中设置和保留语言语法类型
【发布时间】:2017-12-30 05:12:53
【问题描述】:

在 Atom 1.18 中,每次我打开编辑器时,我的 .babelrc 文件都默认为 JSON 文件类型,这使得语法高亮看起来很遥远。而且我必须不断将其改回Babel 类型。

如何解决(暂时):

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

现在我意识到这是一个很少被触及的文件,但知道如何为其他文件类型解决这个问题会很有帮助。

【问题讨论】:

    标签: javascript syntax-highlighting atom-editor babeljs


    【解决方案1】:

    在 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"
          ]
    

    【讨论】:

      【解决方案2】:

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

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

      【讨论】:

        猜你喜欢
        • 2019-10-15
        • 2021-08-06
        • 1970-01-01
        • 2019-08-27
        • 2019-08-27
        • 2022-06-23
        • 2016-04-13
        • 2023-03-11
        • 2019-07-22
        相关资源
        最近更新 更多