examples/classic/firebase/app.js JAVASCRIPT 58 lines View on github.com → Search inside
1var emailRE = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/23// Setup Firebase4var config = {5  apiKey: "AIzaSyAi_yuJciPXLFr_PYPeU3eTvtXf8jbJ8zw",6  authDomain: "vue-demo-537e6.firebaseapp.com",7  databaseURL: "https://vue-demo-537e6.firebaseio.com"8}9firebase.initializeApp(config)1011var usersRef = firebase.database().ref('users')1213// create Vue app14var app = new Vue({15  // element to mount to16  el: '#app',17  // initial data18  data: {19    newUser: {20      name: '',21      email: ''22    }23  },24  // firebase binding25  // https://github.com/vuejs/vuefire26  firebase: {27    users: usersRef28  },29  // computed property for form validation state30  computed: {31    validation: function () {32      return {33        name: !!this.newUser.name.trim(),34        email: emailRE.test(this.newUser.email)35      }36    },37    isValid: function () {38      var validation = this.validation39      return Object.keys(validation).every(function (key) {40        return validation[key]41      })42    }43  },44  // methods45  methods: {46    addUser: function () {47      if (this.isValid) {48        usersRef.push(this.newUser)49        this.newUser.name = ''50        this.newUser.email = ''51      }52    },53    removeUser: function (user) {54      usersRef.child(user['.key']).remove()55    }56  }57})

Code quality findings 5

Use let or const to avoid scope issues and hoisting
info correctness var-declaration
var emailRE = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
Use let or const to avoid scope issues and hoisting
info correctness var-declaration
var config = {
Use let or const to avoid scope issues and hoisting
info correctness var-declaration
var usersRef = firebase.database().ref('users')
Use let or const to avoid scope issues and hoisting
info correctness var-declaration
var app = new Vue({
Use let or const to avoid scope issues and hoisting
info correctness var-declaration
var validation = this.validation

Security findings 1

Matches Google/GCP/Drive/Gmail/YouTube API keys
security Google API Key

Get this view in your editor

Same data, no extra tab — call code_get_file + code_get_findings over MCP from Claude/Cursor/Copilot.