Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Feature Request: Add an option to require type annotations

Đang mở
#3,447 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức phù hợp với người mới
42/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Ít trao đổi
Công nghệ
lua
Lĩnh vực
devtools

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.

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 ---@param with a name + type
    • And it has at least one non-bare-return `return
      • Each parameter must define ---@return with type
  • 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>

Something along these lines

Ngôn ngữ chính
Lua
Star
4.4k
Fork
442
Merge trung bình
8 ngày 9 giờ
Pull request đã merge (30 ngày)
1

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của LuaLS/lua-language-server

Tất cả issue của LuaLS/lua-language-server

Issue tương tự

Thêm issue về Lua

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.