@atlisp/lint 0.1.17 → 0.1.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/README.md +3 -4
  2. package/atlisp-lint.default.json +12 -5
  3. package/dist/checks/bare-names.js +2 -0
  4. package/dist/checks/constant-condition.js +3 -0
  5. package/dist/checks/empty-catch.js +68 -23
  6. package/dist/checks/entget-in-loop.d.ts +3 -0
  7. package/dist/checks/entget-in-loop.js +56 -0
  8. package/dist/checks/if-without-else.d.ts +4 -0
  9. package/dist/checks/if-without-else.js +31 -0
  10. package/dist/checks/long-function-call.js +1 -1
  11. package/dist/checks/promise-handler.d.ts +4 -0
  12. package/dist/checks/promise-handler.js +53 -0
  13. package/dist/checks/redundant-list.d.ts +4 -0
  14. package/dist/checks/redundant-list.js +22 -0
  15. package/dist/checks/string-concat-loop.d.ts +3 -0
  16. package/dist/checks/string-concat-loop.js +59 -0
  17. package/dist/checks/undeclared-setq.js +2 -0
  18. package/dist/checks/unused-catch-result.d.ts +3 -0
  19. package/dist/checks/unused-catch-result.js +28 -0
  20. package/dist/config.js +11 -4
  21. package/dist/formatters-html.d.ts +3 -0
  22. package/dist/formatters-html.js +91 -0
  23. package/dist/formatters-sarif.d.ts +3 -0
  24. package/dist/formatters-sarif.js +55 -0
  25. package/dist/index.js +41 -2
  26. package/dist/locale.js +23 -7
  27. package/dist/presets.js +16 -2
  28. package/dist/project.js +180 -2
  29. package/dist/rules.js +8 -1
  30. package/dist/runner.d.ts +1 -2
  31. package/dist/runner.js +106 -224
  32. package/dist/validate.js +8 -1
  33. package/dist/visitor-runner.d.ts +4 -0
  34. package/dist/visitor-runner.js +709 -0
  35. package/package.json +1 -1
  36. package/dist/atlisp-lint.default.json +0 -90
  37. package/dist/lib/lint-sbcl.lisp +0 -161
  38. package/dist/stub-packages.json +0 -41
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlisp/lint",
3
- "version": "0.1.17",
3
+ "version": "0.1.19",
4
4
  "description": "AutoLISP static analysis tool — parens, security, conventions, SBCL syntax validation",
5
5
  "keywords": [
6
6
  "CAD",
@@ -1,90 +0,0 @@
1
- {
2
- "locale": "zh",
3
- "source": {
4
- "globs": ["**/*.lsp"],
5
- "exclude": ["**/node_modules/**", "**/vendor/**", "**/.git/**"]
6
- },
7
- "checks": {
8
- "parens": "error",
9
- "encoding": "warn",
10
- "cl_syntax": "warn",
11
- "quit_exit": "error",
12
- "command_shell": "error",
13
- "startapp": "warn",
14
- "vl_registry_write": "warn",
15
- "vlax_without_loading": "off",
16
- "token_in_url": "warn",
17
- "open_without_close": "warn",
18
- "bare_function_names": "off",
19
- "line_length": "warn",
20
- "function_complexity": "warn",
21
- "parameter_naming": "warn",
22
- "unused_variable": "warn",
23
- "missing_doc": "warn",
24
- "error_handling": "warn",
25
- "global_naming": "warn",
26
- "extra_parens": "warn",
27
- "arg_count": "warn",
28
- "strcat_usage": "warn",
29
- "cond_simplify": "warn",
30
- "redundant_progn": "warn",
31
- "quote_style": "warn",
32
- "eq_usage": "warn",
33
- "lambda_syntax": "warn",
34
- "comment_style": "warn",
35
- "empty_catch": "warn",
36
- "nth_usage": "warn",
37
- "append_single": "warn",
38
- "setq_multiple": "warn",
39
- "function_order": "off",
40
- "magic_number": "off",
41
- "mixed_indent": "warn",
42
- "long_function_call": "warn",
43
- "no_return": "warn",
44
- "shadow_builtin": "warn",
45
- "dynamic_doc": "warn",
46
- "loop_optimization": "off",
47
- "type_check": "off",
48
- "redundant_if": "warn",
49
- "trailing_whitespace": "warn",
50
- "module_registration": "off",
51
- "namespace_header": "off"
52
- },
53
- "line_length": {
54
- "max": 100,
55
- "tab_width": 2
56
- },
57
- "function_complexity": {
58
- "max_lines": 60,
59
- "max_nesting": 6
60
- },
61
- "cl_syntax": {
62
- "keywords": ["&key"]
63
- },
64
- "dangerous_calls": {
65
- "quit": "error",
66
- "exit": "error",
67
- "command_shell": "error",
68
- "startapp": "warn",
69
- "vl_registry_write": "warn"
70
- },
71
- "module_registration": {
72
- "severity": "off",
73
- "patterns": [],
74
- "dirs": ["modules"]
75
- },
76
- "namespace_header": {
77
- "severity": "off",
78
- "package": "",
79
- "deps": [],
80
- "search_lines": 15
81
- },
82
- "bare_function_names": {
83
- "allowlist": ["T", "nil"],
84
- "namespace_pattern": "^[a-z]+:"
85
- },
86
- "sbcl": {
87
- "walk_exclude": [".vscode", "vendor", ".git"],
88
- "defmacro_allow_files": ["compat-cl"]
89
- }
90
- }
@@ -1,161 +0,0 @@
1
- ;; @lisp SBCL Lint — syntax validation via SBCL
2
- ;; Usage: sbcl --script lint-sbcl.lisp <src-dir> <stub-packages.json> <walk-exclude-json> <defmacro-allow-files-json> <locale>
3
-
4
- (require :uiop)
5
-
6
- (defparameter *errors* 0)
7
- (defparameter *warnings* 0)
8
- (defparameter *checked* 0)
9
- (defparameter *locale* "zh")
10
-
11
- ;; ── i18n ──────────────────────────────────────────────────────────────
12
- (defun i18n (key)
13
- (cdr (assoc key
14
- (if (string= *locale* "zh")
15
- '((:not-found . "not found symbol")
16
- (:syntax-error . "syntax error")
17
- (:vec-syntax . "#( vector syntax")
18
- (:char-syntax . "# backslash char literal")
19
- (:eval-syntax . "#. read-time eval")
20
- (:defmacro . "defmacro")
21
- (:trailing-ws . "trailing whitespace")
22
- (:ok . "OK")
23
- (:fail . "FAIL")
24
- (:header . " @lisp SBCL Lint")
25
- (:source . " Source")
26
- (:found . " Found ~d .lsp files")
27
- (:scanned . " Scanned")
28
- (:errors . " Errors")
29
- (:warnings . " Warnings"))
30
- '((:not-found . "not found symbol")
31
- (:syntax-error . "syntax error")
32
- (:vec-syntax . "#( vector syntax")
33
- (:char-syntax . "# backslash char literal")
34
- (:eval-syntax . "#. read-time eval")
35
- (:defmacro . "defmacro")
36
- (:trailing-ws . "trailing whitespace")
37
- (:ok . "OK")
38
- (:fail . "FAIL")
39
- (:header . " @lisp SBCL Lint")
40
- (:source . " Source")
41
- (:found . " Found ~d .lsp files")
42
- (:scanned . " Scanned")
43
- (:errors . " Errors")
44
- (:warnings . " Warnings"))))))
45
-
46
- ;; ── Stub packages from external file ──────────────────────────────────
47
- (defun load-stub-packages (file-path)
48
- (flet ((ensure-pkg (name &optional use-list)
49
- (unless (find-package name)
50
- (make-package name :use (or use-list '())))))
51
- (with-open-file (s file-path :direction :input)
52
- (let ((packages (read s)))
53
- (dolist (pkg packages)
54
- (ensure-pkg (first pkg) (second pkg)))))))
55
-
56
- ;; ── File walking ──────────────────────────────────────────────────────
57
- (defun source-files (dir)
58
- (sort
59
- (remove-if-not
60
- (lambda (p)
61
- (let ((n (pathname-type p)))
62
- (and n (string-equal n "lsp"))))
63
- (uiop:directory-files dir))
64
- 'string< :key #'namestring))
65
-
66
- (defun walk-tree (dir exclude-dirs)
67
- (let ((result (source-files dir)))
68
- (dolist (sub (uiop:subdirectories dir))
69
- (let ((name (car (last (pathname-directory sub)))))
70
- (unless (find name exclude-dirs :test 'string=)
71
- (setf result (append result (walk-tree sub exclude-dirs))))))
72
- result))
73
-
74
- ;; ── Per-file check ────────────────────────────────────────────────────
75
- (defun check-file (path src-dir defmacro-allow-files)
76
- (incf *checked*)
77
- (let* ((rel (enough-namestring path src-dir))
78
- (fullname (format nil "~a.~a" (pathname-name path) (pathname-type path))))
79
- (format t " ~a ... " rel)
80
- (force-output)
81
- ;; Syntax check via READ
82
- (handler-case
83
- (with-open-file (s path :direction :input)
84
- (loop for form = (read s nil :eof)
85
- until (eq form :eof)))
86
- (error (e)
87
- (let ((msg (princ-to-string e)))
88
- (cond
89
- ((search "not found" msg)
90
- (format t "~% [NOTE] ~a: ~a~%" rel (i18n :not-found))
91
- (incf *warnings*))
92
- (t
93
- (format t "~a~% [ERROR] ~a: ~a~%" (i18n :fail) rel (i18n :syntax-error))
94
- (incf *errors*)
95
- (return-from check-file))))))
96
- ;; Trailing whitespace
97
- (with-open-file (s path :direction :input)
98
- (loop for line = (read-line s nil nil)
99
- for lineno from 1
100
- while line
101
- when (and (> (length line) 0)
102
- (find (char line (1- (length line))) '(#\Space #\Tab)))
103
- do (progn
104
- (format t "~% [WARN] ~a line ~d: ~a~%" rel lineno (i18n :trailing-ws))
105
- (incf *warnings*))))
106
- ;; CL-ism checks: raw content scan
107
- (with-open-file (s path :direction :input)
108
- (let ((content (make-string (file-length s))))
109
- (file-position s 0)
110
- (read-sequence content s)
111
- (when (search "#(" content)
112
- (format t "~% [WARN] ~a: ~a~%" rel (i18n :vec-syntax))
113
- (incf *warnings*))
114
- (when (search "#\\" content)
115
- (format t "~% [WARN] ~a: ~a~%" rel (i18n :char-syntax))
116
- (incf *warnings*))
117
- (when (search "#." content)
118
- (format t "~% [WARN] ~a: ~a~%" rel (i18n :eval-syntax))
119
- (incf *warnings*))
120
- (when (and (search "defmacro" content)
121
- (not (some (lambda (s) (search s fullname)) defmacro-allow-files)))
122
- (format t "~% [WARN] ~a: ~a~%" rel (i18n :defmacro))
123
- (incf *warnings*))))
124
- (format t "~a~%" (i18n :ok))))
125
-
126
- ;; ── Main ──────────────────────────────────────────────────────────────
127
- (defun main ()
128
- (let* ((args (uiop:command-line-arguments))
129
- (src-dir (first args))
130
- (stub-file (second args))
131
- (walk-exclude (if (third args)
132
- (read-from-string (third args))
133
- '(".vscode" "test" "experiment" "tools" ".git")))
134
- (defmacro-allow (if (fourth args)
135
- (read-from-string (fourth args))
136
- '("compat-cl")))
137
- (locale (fifth args)))
138
- (when locale (setf *locale* locale))
139
- (load-stub-packages stub-file)
140
-
141
- (format t "~%==================================================~%")
142
- (format t "~a~%" (i18n :header))
143
- (format t "~a: ~a~%" (i18n :source) (namestring (pathname src-dir)))
144
- (format t "==================================================~%~%")
145
- (setf *errors* 0 *warnings* 0 *checked* 0)
146
-
147
- (let ((files (walk-tree src-dir walk-exclude)))
148
- (format t "~a~%~%" (format nil (i18n :found) (length files)))
149
- (dolist (f files)
150
- (check-file f src-dir defmacro-allow)))
151
-
152
- (format t "~%==================================================~%")
153
- (format t "~a: ~d~%" (i18n :scanned) *checked*)
154
- (format t "~a: ~d~%" (i18n :errors) *errors*)
155
- (format t "~a: ~d~%" (i18n :warnings) *warnings*)
156
- (format t "==================================================~%~%")
157
- (if (> *errors* 0)
158
- (uiop:quit 1)
159
- (uiop:quit 0))))
160
-
161
- (main)
@@ -1,41 +0,0 @@
1
- ((AUTOLISP ())
2
- (@ (COMMON-LISP AUTOLISP))
3
- (C ())
4
- (JSON ())
5
- (SIDEBAR ())
6
- (FUN ())
7
- (DCL ())
8
- (BASE ())
9
- (STRING ())
10
- (BLOCK ())
11
- (ENTITY ())
12
- (LAYER ())
13
- (LAYOUT ())
14
- (CURVE ())
15
- (LIST ())
16
- (M ())
17
- (P ())
18
- (UI ())
19
- (SYS ())
20
- (EXCEL ())
21
- (WORD ())
22
- (RE ())
23
- (VECTRA ())
24
- (DOS ())
25
- (AT-PM ())
26
- (QRENCODE ())
27
- (NETWORK ())
28
- (PKGMAN ())
29
- (DATETIME ())
30
- (DICT ())
31
- (@NLP ())
32
- (AT-SIDEBAR ())
33
- (S ())
34
- (VL ())
35
- (VLR ())
36
- (VLAX ())
37
- (THEME ())
38
- (AJAX ())
39
- (ATLISP ())
40
- (LOG ())
41
- (ATLISP-CORE ()))