我正在使用 Adobe Extendscript,它 == javascript*,并且我正在使用 Atom 中的 Atom JSHint 包。 Extendscript 是 Photoshop 和 After Effects 等 Adobe 应用程序的脚本框架。 Adobe 确实制作了一个 IDE,但它真的很弱,所以我用 Atom 编写,然后切换到“Extendscript Toolkit”来运行我的脚本。不管怎样……
Adobe 允许您使用 C 风格的预处理器指令,例如 #include "myUsefulFunctions.jsx"
,这样您就可以像真正的编程语言一样在库中保留可重用的内容。
问题是 JSHint linter 在页面顶部看到我的 C 风格预处理器指令,吓坏了并放弃了。为了真正让它对我的代码进行 lint,我必须注释掉预处理器指令,然后记得在运行代码之前取消注释它们。这意味着我每次测试至少要多敲 3 或 4 次按键,这是众所周知的。最坏的。事物。曾经。
因此,为了节省六次击键,我一直在研究 JSHint 的设置。到目前为止,我发现的一切似乎都不相关。有什么方法可以让 JSHint 在全局范围内忽略像 #this
这样的行,或者在文件本地让它跳过一两行?
*或者是 ===
?我真的对 JS 处理真相的方式感到困惑。
最佳答案
我也想了很久,直到找到最好的解决方案。 而不是使用:
#target aftereffects
您可以使用:
//@target aftereffects
我没有找到上述解决方案的任何文档。
我刚刚在网络上的一个脚本中找到了它,我尝试了一下,它成功了。
而是使用:
#include "some/path/to/file.jsx"
如 JavaScript Tools Guide 中所述:
evalFile()
$.evalFile (path[, timeout])
Loads a JavaScript script file from disk, evaluates it, and returns the result of evaluation.
path: The name and location of the file.
timeout: Optional. A number of milliseconds to wait before returning undefined, if the script cannot be evaluated. Default is 10000 milliseconds.
您可以使用:
$.evalFile("some/path/to/file.jsx");
区别在于#include
:
Includes a JavaScript source file from another location. Inserts the contents of the named file into this file at the location of this statement.
关于JSHint:不包括预处理器指令。不完全是,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34126492/