提问人:Mark 提问时间:2/25/2023 更新时间:2/25/2023 访问量:37
将一个 .js 文件导入另一个文件(JSLINT 无法识别“导入”关键字)
Import a .js file into another (JSLINT doesn't recognize the "Import" key word)
问:
我正在尝试将.js文件导入到antoher.js文件中。JSLint 抛出错误,似乎无法识别“import”语句
import "./Scripts/dompurify/purify.min.js";
(function ($, constants, appUtilities, window, confirm) {
var DATE_PATTERN = /^(?=\d)(?:(?:(?:(?:0?[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0?[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})|(?:0?2(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))|(?:(?:0?[1-9])|(?:1[0-2]))(\/|-|\.)(?:0?[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{2}))$/, GTSelectedTestId,
ADDRESS_PATTERN = /^[0-9a-zA-Z.'@#%&\/-\s]*$/;
function mutexCheckboxSelection(mutexCheckboxes, event) {
if (!mutexCheckboxes || mutexCheckboxes.length < 2) {
return;
}
答:
0赞
ruffin
2/25/2023
#1
好的,我将坚持我最初的评论,即您可能想转移到 eslint,但我拿走了您的片段,填写了它,然后这个 lints。
我认为底线是 jslint 目前只允许一种导入语法:
import foo from "source"
或import {foo, bar} from "source"
/*global jQuery */
import something from "./Scripts/dompurify/purify.min.js";
(function ($, constants, appUtilities, window, confirm) {
var GTSelectedTestId;
var ADDRESS_PATTERN = /^[0-9a-zA-Z.'@#%&\/-\s]*$/;
function mutexCheckboxSelection(mutexCheckboxes, event) {
if (!mutexCheckboxes || mutexCheckboxes.length < 2) {
return;
}
return event;
}
GTSelectedTestId = 5;
console.log(
"listing vars here to shush errors about unused vars",
$,
constants,
appUtilities,
window,
confirm,
GTSelectedTestId,
ADDRESS_PATTERN,
something
);
return mutexCheckboxSelection;
}(jQuery, [], [], window, true));
所以很明显,你应该编辑与你的用例的匹配,但随后它应该lint。something
评论
import