简体   繁体   English

Eslint:未使用的变量

[英]Eslint : no-unused-vars

I am new in using Eslint to fixing the bugs and I have got the following error. 我是使用Eslint修复错误的新手,但遇到以下错误。

error 'query' is assigned a value but never used no-unused-vars

My code is 我的代码是

  const query = Samples.find().where('patientId', patientId).exec((err, docs) => {
    if (err) res.send(err);
    // If no errors, send them back to the client
    res.json({ items: docs });
});

Any help is highly appreciated. 非常感谢您的帮助。

Just remove the const query part. 只需删除const query部分。 Unless they're more code you're not sharing (which you should in order to create a reproducible example), it appears you don't actually need it: 除非它们是更多的代码,否则您不会共享(为了创建可重现的示例,应该共享它们),看来您实际上并不需要它:

Samples.find().where('patientId', patientId).exec((err, docs) => {
    if (err) res.send(err);
    // If no errors, send them back to the client
    res.json({ items: docs });
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM