LuaLS / LuaLS/lua-language-server
Feature Request: Add an option to require type annotations
Nessuno ha ancora preso questa issue.
- Lingua principale
- Lua
- Stelle
- 4.4k
- Fork
- 442
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
Desire
I would like a way for lua-language-server to apply a "strict" mode to the functions and tables variables of lua files. e.g. if a function takes at least one parameter or has at least one return <foo> statement, it would error if that function doesn't also have a ---@param / ---@return statement to match it.
Issue
There seems to be some arguments that can make lua-language-server more strict, for example these:
.luarc.json
{
"diagnostics": {
"neededFileStatus": {
"incomplete-signature-doc": "Any",
"missing-global-doc": "Any",
"missing-local-export-doc": "Any"
},
"severity": {
"incomplete-signature-doc": "Error",
"missing-global-doc": "Error",
"missing-local-export-doc": "Error"
}
},
}
But they seem to activate only on inlined functions or functions that have incomplete documentation. So if a function has no docs at all, it gets skipped.
Suggestion
A new diagnostic that maybe can be a warning but can be escalated to an error. And it basically says
- If it is a global variable table, it needs a
---@type - If it is a function
- And it has at least one parameter
- Each parameter must define
---@paramwith a name + type
- Each parameter must define
- And it has at least one non-bare-return `return
- Each parameter must define
---@returnwith type
- Each parameter must define
- And it has at least one parameter
- If the type annotation is a table
- Require that the table is "filled out" with concrete types. e.g.
---@type table->---@type table<string, integer>
- Require that the table is "filled out" with concrete types. e.g.
Something along these lines
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia dalla configurazione .luarc.json e dalle diagnosi esistenti incomplete-signature-doc, missing-global-doc e missing-local-export-doc per capire come vengono abilitate e promosse le diagnosi. Definisci l'ambito della nuova diagnosi per le funzioni, le variabili di tabella globali e le annotazioni di tabella, quindi convalida il comportamento richiesto di avviso ed errore in base agli esempi nell'issue.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- lua
- Ambito
- devtools
- Tipo di issue
- Funzionalità
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Stato di attività
- Tranquilla
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 42/100