Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

144
Vistas
Cant figure out user snippets

I am trying to make another user snippet in VSCode to automate the document.querySelector but whenever I try to it gives me a weird error shown below. I have another snippet that works just fine but that was shown to me by an online class I am taking. I don't have any experience with json so I may just be getting the syntax wrong but it is the exact same as my previous snippet.

VSCode screenshot

In case that link doesn't work I'll include the code written below. The error I am getting is on the very first curly brace and it says "end of file expected .json"

All help is appreciated :)

{                    // start of file and json object

// other snippets here

  
  "query selector": {
    "scope": "javascript",
    "prefix": "dq",
    "body": ["document.querySelector('$0')"],
    "description": "Select element from document"
  },

// other snippets here

}                    // end of json object
about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

Use a square bracket to start a json file, and end with a square bracket [ ].

[
  {
  "query selector": {
  "scope": "javascript",
  "prefix": "dq",
  "body": 
  ["document.querySelector('$0')"],
  "description": "Select element from document"
                 }
  }
]
about 4 years ago · Juan Pablo Isaza Denunciar

0

Your json file is incorrect.

You should place the object starting with the key “query selector” inside the json object above.

Add a comma after the curly brace in line 14 and add your snippet in there. Remove your outer curly braces from lines 17 and 24.

Json files are only one single object.

So your snippets file would look something like this:

{
  "Print to console": {
    "prefix": "log",
    "body": [
      "console.log('$1');",
      "$2"
    ],
    "description": "Log output to console"
  },
  "query selector": {
    "scope": "javascript",
    "prefix": "dq",
    "body": [
      "document.querySelector('$0')"
    ],
    "description": "Select element from document"
  }
}

By the way, I don't think you need the "scope" key.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda