Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

143
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda