Pular para o conteúdo
Skillpedia
Sites e telas (frontend)75 mil · #2781

const-let

O que ela faz

Esta skill verifica o JavaScript em busca de declarações var e sugere const ou let no lugar. Ela é para desenvolvedores que querem um código mais seguro e fácil de ler.

Quando usar

  • ✓Quando você encontra var em um arquivo JavaScript antigo.
  • ✓Quando uma variável parece acessível onde não deveria.
  • ✓Quando você revisa o código quanto à clareza antes de uma versão.

Link da skill

https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/const-let/SKILL.md

Copie e cole na sua IA (Claude, ChatGPT ou Cursor) pedindo para seguir as instruções.

Como usar

O jeito mais fácil: copie a mensagem e cole na sua IA. Ela lê a skill e segue as instruções.

Mensagem pronta para colar

Use esta skill para me ajudar: https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/const-let/SKILL.md Leia o arquivo SKILL.md desse link e siga as instruções dele na minha tarefa.
Quer que a sua IA encontre skills como esta sozinha?Instale o MCP grátis do Skillpedia: uma linha, e ela pesquisa entre 15.000+ skills antes de cada tarefa.Instalar em 1 minuto →

Exemplo do que pedir para a IA

“Revise este script e troque cada var por const ou let.”

5 skills novas por semana. 1 minuto de leitura.

Como funciona

O agente lista todas as declarações var com o número da linha e depois usa const para valores que nunca mudam e let para valores que são reatribuídos.

Conteúdo técnico (SKILL.md original)

Texto original do autor, em inglês, direto do GitHub.

Prefer const and let over var

var's function scope and hoisting behavior regularly causes bugs where variables are accessible outside the block they were declared in. const and let enforce block scope and make code intent clearer — const signals that a binding should not be reassigned, which helps readers understand data flow.

Quick Reference

  • Use const for values that are never reassigned
  • Use let when reassignment is needed
  • Never use var — it has function scope and is hoisted, causing subtle bugs
  • const does not mean immutable — objects and arrays declared with const can still be mutated

Check

Scan this JavaScript file for any use of var and flag every occurrence with line numbers.

Fix

Replace all var declarations with const or let as appropriate. Use const when the variable is never reassigned, let otherwise.

Explain

Explain why const and let are preferred over var, covering scope, hoisting, and temporal dead zone.

Code Review

Review scripts, client components, and browser execution paths related to Prefer const and let over var. Flag exact imports, event handlers, runtime side effects, or blocking operations that violate the rule, and state how the change should be verified in the browser.


For full implementation details, code examples, and framework-specific guidance, see references/rule.md.

Rule page: https://frontendchecklist.io/rules/javascript/const-let

Perguntas frequentes

Por que var é arriscado?

A skill diz que var tem escopo de função e hoisting, o que pode causar erros sutis.

Quando devo usar const?

Quando a variável nunca é reatribuída.

const torna objetos imutáveis?

Não. A skill observa que objetos e arrays declarados com const ainda podem ser alterados.

Detalhes

Descrição original do autor

Use when reviewing scripts, client components, bundles, or runtime behavior related to Prefer const and let over var. Inspect both source code and the browser execution path so fixes target the real bottleneck or bug.

repo: thedaviddias/Front-End-Checklist

Popularidade

Estrelas no GitHub
75 mil
Posição no ranking
#2781
Licença
MIT
Atualizada em
31/10/2026

Essa skill é útil?

0

Entre para votar.

Comentários

  • …

Mais skills deste repositório

Skills parecidas