LuaLS / LuaLS/lua-language-server
Feature Request: Add an option to require type annotations
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- Lua
- Star
- 4.4k
- Fork
- 442
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Mô tả
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
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Bắt đầu với cấu hình .luarc.json và các chẩn đoán hiện có incomplete-signature-doc, missing-global-doc và missing-local-export-doc để hiểu cách các chẩn đoán được bật và nâng mức. Xác định phạm vi của chẩn đoán mới cho các hàm, biến bảng toàn cục và chú thích bảng, sau đó xác thực hành vi cảnh báo và lỗi được yêu cầu dựa trên các ví dụ trong issue.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- lua
- Lĩnh vực
- devtools
- Loại issue
- Tính năng
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức độ hoạt động
- Ít trao đổi
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 42/100