JSHint 报告 undefined variable ,尽管 globals
设置。这是一个最小的例子:
文件.js:
// jshint esversion: 6, node: true
// globals Intl
'use strict';
let percent = new Intl.NumberFormat("en-US", { style: "percent" }).format;
运行jshint file.js
index2.js: line 5, col 19, 'Intl' is not defined.
1 error
知道我的配置有什么问题吗?注意这里没有.jshintrc
,JSHint的唯一配置就是file.js
开头的注释。
最佳答案
老实说,我从未见过使用//
这样简单的单行注释来配置jshint/globals。
尝试使用多行注释样式,如 /* globals MY_LIB: false */
按照定义在:http://jshint.com/docs/
关于javascript - 尽管有 `globals` 设置,JSHint 报告未定义的全局,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46204922/