Aas*_*edi 4 javascript android node.js atom-editor
我已经制作了一个脚本来向我的 Firebase 服务器发送推送通知,但是 javascript eslint 首先为 const 抛出错误。
然后我在 Google 上发现我必须将 ecmaVersion = 6 放在我的 .eslintsrc 文件中。我这样做了,然后它在要求、导出和控制台字段上显示错误。
我使用 Atom 作为我的代码编译器。这是我的代码:
const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp(functions.config().firebase);
exports.printUrl = functions.database.ref('images/{uid}').onWrite(event => {
var request = event.data.val();
var payload = {
data:{
url : request.url,
location : request.location
}
};
admin.messaging().sendToTopic(request.topic, payload)
.then(function(response){
console.log("Successfully sent message : ", response);
})
.catch(function(error){
console.log("Error sending message : ", error);
})
});
Run Code Online (Sandbox Code Playgroud)
您需要让 eslint 知道您正在 Node 环境中工作以摆脱 require 和 exports 错误。因此,通过将其添加到您的 eslintConfig:
"env": {
"node": true
}
Run Code Online (Sandbox Code Playgroud)
为了允许 console.log,您必须通过将其添加到您的 eslintconfig 来打开规则:
"rules": {
"no-console": 0
}
Run Code Online (Sandbox Code Playgroud)
您可以在此处找到更多信息:https : //eslint.org/docs/user-guide/configuring
| 归档时间: |
|
| 查看次数: |
2528 次 |
| 最近记录: |