为什么在for ... of循环中收到"no-unused-vars"警告,我该如何解决? [英] Why am I getting a 'no-unused-vars' warning in a for...of loop and how do I fix it?
问题描述
我正在使用Create React App创建的React应用程序.在每个for ... of循环中,我得到这个奇怪的'no-unused-vars'警告,指向我在for语句中实例化的变量.
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告诉我我的变量未使用,但实际上已使用.
其他人也会收到类似的警告吗?是ESLint错误还是我在这里做错了什么?
这不是什么大问题,但是很烦人.
感谢您的帮助.
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
}
}
控制台输出
Line 13: 'track' is defined but never used no-unused-vars
Line 15: 'chord' is defined but never used no-unused-vars
推荐答案
请参见此问题,此问题与eslint的特定版本有关,您可以将eslint版本恢复回v6.1.0来解决此问题.
see this issue, this issue is related to specific version of eslint, you can revert your eslint version back to v6.1.0 to resolve this.
这篇关于为什么在for ... of循环中收到"no-unused-vars"警告,我该如何解决?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!