javascript - Why am I getting a 'no-unused-vars' warning in a for...of loop and how do I fix it?
问题描述
I'm working on a React app created with Create React App. In every for...of loop, I get this weird 'no-unused-vars' warning pointing to the variable I have instantiated in the for statement.
ESLint tells me my variable is not used, but it is actually used.
Does anybody else get a similar warning? Is it an ESLint bug or am I doing something wrong here?
This is not a big issue, but it is annoying.
Thanks for your help.
for (let track of tracks) {
let chords = RavelFormatter.splitEntries(track.pitches)
for (let chord of chords) {
var n = chord.split(':')
total += n.length
}
}
Console output
Line 13: 'track' is defined but never used no-unused-vars
Line 15: 'chord' is defined but never used no-unused-vars
解决方案
请将babel-eslint
软件包升级到 version 10.0.3
。
这很可能会修复那些在循环内部使用 var 并错误地报告为未使用的误报。
推荐阅读
- php - 流明 POST 访问“MethodNotAllowedHttpException”
- python - Pandas 仅将最后一个 bs4 元素打印到 csv 文件
- python - 不健康的部署
- ios - Flutter:1.20.2:在 iPhone 上启动应用程序时出错
- excel - VBA 代码太慢 - 需要 6 小时才能执行输出
- arrays - Vue中如何使用html表格生成JSON数据
- google-apps-script - 有没有办法将 Google Apps 脚本触发器设置为基于多个电子表格之一的编辑?
- java - jlIllegalArgumentException:不是托管类型
- r - 使用 tidyr 转换数据框
- html - 使用参数生成的 HTML 表