【发布时间】:2017-10-08 06:28:35
【问题描述】:
我在通过 ESLint 运行的 .js 文件中获取了此代码。但它抛出了关于这一行的错误:iFrameResize({。
说:error 'iFrameResize' is not defined no-undef。
如果我这样定义:const iFrameResize()
我的代码不再有效,如何让 ESLint 满意并保持代码有效?
export default class Page extends PageManager {
before(next) {
next();
}
loaded(next) {
next();
}
after(next) {
const url = Url.parse(location.href, true);
const IC_PAGE = '/international-checkout';
const currentPageUrl = url.pathname;
if (currentPageUrl.indexOf(IC_PAGE) !== -1 && $('#icForm').length === 1) {
$(document).ready(() => {
if ($('#icForm').length === 1) {
if ($('.GiftStatus') && $('.GiftStatus').val() === '1') {
alert('Gift Certificate is not available for international orders. Please remove Gift Certificate from shopping cart before proceeding with International Checkout.');
window.parent.location.href = '/cart.php';
return false;
}
$('.icformfields').each((i, e) => {
const currentId = $(e).attr('id');
const res = currentId.split('-');
const finalId = Number(res[1]) + 1;
const finalName = $(e).attr('name') + finalId;
$(e.currentTarget).attr('name', finalName);
});
document.getElementById('icIframe').src = 'https://www.internationalcheckout.com/cart.php';
document.getElementById('icForm').submit();
$('#icIframe').load(() => {
$('#icForm').remove();
$('#loading').css('display', 'none');
$('html, body').animate({
scrollTop: $('#icIframe').offset().top,
}, 1000);
$('#icIframe').fadeIn();
});
}
});
iFrameResize({
checkOrigin: false,
enablePublicMethods: true,
});
}
next();
}
}
我想知道如何在不禁用特定行的错误报告的情况下满足 ESLint。
【问题讨论】:
-
@Michael 我明白你为什么认为它会重复,但我真的很想知道如何在不禁用错误报告的情况下让 ESLint 满意。
-
我现在看到了区别——我错过了你关于“不禁用错误报告”的问题的最后一部分,所以我同意这不是重复的
标签: javascript bigcommerce eslint