为什么在我尝试编译时 Rome 认为我的文件是空的?

Why does Rome think my file is empty when I try to compile it?

我正在尝试 Facebook 上的这个新东西,叫做 Rome

由于它仍处于实验阶段,您需要先从源代码构建此工具。我按照这些 steps 没有任何问题。

简而言之,我所做的是:

cd /tmp
git clone https://github.com/facebookexperimental/rome.git
cd rome
./scripts/build-release dist

然后我安装了它:

cd /tmp
mkdir try-rome
cd try-rome/
npm install ../rome/dist/

一切都很好。然后我创建了这个文件index.js,内容如下:

alert("wat?")

并根据撰写本文时的 "Getting Started" 说明在根目录下放置一个空的 rome.json 文件:

Rome requires a project configuration in order to operate. This can take three possible forms.

  • A rome.json file
  • A rome.rjson file (What is RJSON? See #13)
  • A rome field on package.json

This can just be an empty file. It's required in order for Rome to determine all the files in a project

和运行这个命令:

./node_modules/.bin/rome compile index.js 

失败并出现以下错误:

我知道这个文件不是空的,为什么 Rome 认为它是空的?

documentation 我看到了这一行:

$ echo '{}' >rome.json

rome.json 文件似乎至少应该有一个空的 json {}

在此上下文中,一个空的 rome.json 文件意味着它至少有 {}。我同意文档应该重新措辞以使其更清楚。

生成 rome.json 文件的更好方法是使用 ./scripts/dev-rome init 脚本,该脚本提供启用 linting 的推荐配置。