[英]TSLint: Shadowed name in map. Is this false positive?
I have the following TypeScript / Javascript codes for producing multiple line using jQuery. 我有以下用于使用jQuery生成多行代码的TypeScript / Javascript代码。
let evenLine = false;
const divs = clientsInfo.map((m) => {
const div = $('<li/>', { class: 'hubClientInfo' + (evenLine ? ' even' : ' odd') });
evenLine = !evenLine;
div.append($('<span/>', { class: 'hc-userAgent' }).text(m.userAgent));
div.append($('<span/>', { class: 'hc-ip' }).text(m.ipAddress));
div.append($('<span/>', { class: 'time' }).text(m.connectedTimeUtc.toString()));
div.append($('<span/>', { class: 'hc-user' }).text(m.username));
div.append($('<span/>', { class: 'hc-id' }).text(m.id));
return div;
});
TSLint reports Shadowed name regarding to "evenLine". TSLint报告有关“ evenLine”的阴影名称。
Is this a false alarm? 这是假警报吗? or is there a way to improve the codes to avoid such alarm?
还是有办法改进代码以避免此类警报?
Eventually I had found that down the bottom of the TS file there's a "evenLine" declared globally outside any class or module. 最终,我发现在TS文件的底部,在任何类或模块之外全局声明了一个“ evenLine”。 So renaming those "evenLine" within a function scope had fixed the TSLint warning, while the program has been working properly.
因此,在程序正常运行时,在功能范围内重命名那些“ evenLine”可修复TSLint警告。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.