Eslint 在 Sublime Text 3 或终端中不工作

Eslint not working in Sublime Text 3 or in the terminal

Eslint 在我的 Sublime Text 3 或终端中不工作。

我遵循了本自述文件中的说明。

https://github.com/roadhump/SublimeLinter-eslint

我首先通过输入

在我的终端中全局安装了 eslint
npm install -g eslint

当我在终端输入 eslint -v 时,我得到

v4.5.0

我通过包控制安装了 SublimeLinter-contrib-eslint。

当我在我的终端中输入时

hash -r
which eslint

它给了我

/usr/local/bin/eslint

在我的 Sublime 控制台中它说 eslint 找不到我的配置文件。我运行

eslint --init 

这是我在控制台收到的信息

Traceback (most recent call last):
File "<string>", line 1, in <module>
NameError: name 'eslint' is not defined

谁能给我解释一下这是什么意思,我该如何解决?谢谢你。

您将 Sublime Text 控制台与 terminal(有时也称为控制台)

混淆了

Sublime Text exposes its internals via an Application Programming Interface (API) that programmers can interact with using the Python programming language. An embedded Python interpreter is included in the editor. The embedded interpreter is useful to inspect the editor’s settings and to quickly test API calls while developing plugins.

因此,您只能 运行 Python 命令和 Python Sublime Text 在其控制台中公开的方法。 eslint 的插件可通过命令选项板获得。