Ember.Logger.log 已弃用并且 console.info 给出 'no-console' 构建警告,该怎么办?
Ember.Logger.log is deprecated and console.info gives 'no-console' build warnings, what to do?
我对 Ember 开发比较陌生,但热衷于以正确的方式做事。
对于日志记录,我曾经使用 Ember.Logger.log('blah');
但现在它会在控制台中发出警告,表明它已被弃用。 https://emberjs.com/deprecations/v3.x#toc_use-console-rather-than-ember-logger 的警告中有 link,建议改用 console
。
所以我切换到 console.info('blah');
,但现在当我切换到 ember serve
时,有一堆 "problems",例如:
/Users/mick/Projects/Pop Up Eats/Vendor Website/app/routes/application.js
22:3 error Unexpected console statement no-console
27:3 error Unexpected console statement no-console
✖ 2 problems (2 errors, 0 warnings)
我该怎么办?我错过了什么吗?
这只是 Eslint 错误。
您可以通过转到您的 .eslintrc.js 文件并将其添加到您的规则中来将其更改为 warning/not 错误:
rules: {
"no-console": 0 //which turns the rule off
}
或
rules: {
"no-console": 1 //which will just warn you about the console logs
}
希望对您有所帮助。
我对 Ember 开发比较陌生,但热衷于以正确的方式做事。
对于日志记录,我曾经使用 Ember.Logger.log('blah');
但现在它会在控制台中发出警告,表明它已被弃用。 https://emberjs.com/deprecations/v3.x#toc_use-console-rather-than-ember-logger 的警告中有 link,建议改用 console
。
所以我切换到 console.info('blah');
,但现在当我切换到 ember serve
时,有一堆 "problems",例如:
/Users/mick/Projects/Pop Up Eats/Vendor Website/app/routes/application.js
22:3 error Unexpected console statement no-console
27:3 error Unexpected console statement no-console
✖ 2 problems (2 errors, 0 warnings)
我该怎么办?我错过了什么吗?
这只是 Eslint 错误。 您可以通过转到您的 .eslintrc.js 文件并将其添加到您的规则中来将其更改为 warning/not 错误:
rules: {
"no-console": 0 //which turns the rule off
}
或
rules: {
"no-console": 1 //which will just warn you about the console logs
}
希望对您有所帮助。