如何让 eslint 验证 VSCode 中的 Adob​​e Extendscript (.jsx) 文件

How to get eslint to validate Adobe Extendscript (.jsx) files in VSCode

我正在尝试使用 VSCode 为 Adob​​e After Effects 编写 extendscript 脚本。我想让一些 linting 发生(如果它是 ESLint 或任何其他 linter,不要太过分),但我无法说服 ESLint 对我的文件进行 lint。

Extendscript 是 ECMAScript 标准的一种方言,因此类似于 JavaScript 和 ActionScript。这些文件的扩展名为 .jsx。 VSCode 有一些 extendscript 插件,this one 提供语言支持,因此 VSCode 将我的 .jsx 文件视为 extendscript 文件。所以我希望这能在我的 settings.json:

中起作用
{
  "eslint.options": {
    "extensions":  [".jsx", ".js"]
  },
  "eslint.validate": [
    "javascript",
    "javascriptreact",
    "extendscript"
  ]
}

如果我尝试命令 ESLint.ShowOutputChannel 我得到错误:

ESLint is not running. By default only JavaScript files are validated. If you want to validate other file types please specify them in the 'eslint.validate' setting.

edit 我还尝试将第 10 行的 "extendscript" 替换为

{ "language": "extendscript", "autofix": false }

但运气不好。

我认为您的 user/workspace 设置没问题。也许您缺少安装 ESLint?

如果您在工作区工作,您应该在 package.json

中安装 eslint
npm i -D eslint babel-eslint

如果你只想让 VS Code lint 总是你的文件,你可以安装 eslint 作为全局包:

npm i -g eslint babel-eslint

之后,你应该初始化eslint

eslint --init

查看 eslint cli

的更多示例和文档

这对我有用:

{
  "eslint.options": {
    "extensions":  [".jsx", ".js"]
  },
  "eslint.validate": [
    "javascript",
    "javascriptreact",
    "jsx"
  ]
}

查看 github repo for the Extendscript Language,我发现语言 ID 注册为 jsx,而不是 extendscript。