@atlisp/lint 0.1.25 → 0.1.27

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.
@@ -11,7 +11,7 @@
11
11
  "quit_exit": "error",
12
12
  "command_shell": "warn",
13
13
  "startapp": "warn",
14
- "vl_registry_write": "warn",
14
+ "vl_registry_write": "off",
15
15
  "vlax_without_loading": "warn",
16
16
  "token_in_url": "warn",
17
17
  "open_without_close": "warn",
@@ -81,12 +81,12 @@
81
81
  "type_check": "off",
82
82
  "redundant_if": "warn",
83
83
  "undeclared_setq": "warn",
84
- "unused_catch_result": "warn",
85
- "string_concat_loop": "warn",
84
+ "unused_catch_result": "off",
85
+ "string_concat_loop": "off",
86
86
  "if_without_else": "off",
87
87
  "redundant_list": "warn",
88
88
  "entget_in_loop": "warn",
89
- "promise_handler": "warn",
89
+ "promise_handler": "off",
90
90
  "module_cycle": "warn",
91
91
  "arg_count_project": "warn"
92
92
  },
@@ -106,7 +106,7 @@
106
106
  "exit": "error",
107
107
  "command_shell": "warn",
108
108
  "startapp": "warn",
109
- "vl_registry_write": "warn"
109
+ "vl_registry_write": "off"
110
110
  },
111
111
  "module_registration": {
112
112
  "severity": "off",
@@ -3,6 +3,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.checkArgCount = checkArgCount;
4
4
  const locale_1 = require("../locale");
5
5
  const parser_1 = require("@atlisp/parser");
6
+ function isInQuoteOrFunction(node) {
7
+ let cur = node.parent;
8
+ while (cur) {
9
+ if (cur.children?.[0]?.type === 'symbol' &&
10
+ (cur.children[0].name === 'quote' || cur.children[0].name === 'function')) {
11
+ return true;
12
+ }
13
+ cur = cur.parent;
14
+ }
15
+ return false;
16
+ }
6
17
  function checkArgCount(content, file) {
7
18
  const issues = [];
8
19
  const ast = (0, parser_1.parseAst)(content, { errorRecovery: true });
@@ -36,13 +47,15 @@ function checkArgCount(content, file) {
36
47
  for (const call of calls) {
37
48
  if (!call.children || call.children.length === 0)
38
49
  continue;
39
- // Skip if the first child is the function name — that's the head of this call
50
+ // Skip calls inside quoted or function forms
51
+ if (isInQuoteOrFunction(call))
52
+ continue;
40
53
  const argCount = call.children.length - 1;
41
54
  if (argCount !== paramCount) {
42
55
  issues.push({
43
56
  file,
44
57
  line: call.pos.line,
45
- severity: 'warn',
58
+ severity: 'error',
46
59
  rule: 'arg_count',
47
60
  message: (0, locale_1.t)('arg_count', funcName, argCount, paramCount),
48
61
  });
@@ -253,6 +253,9 @@ function checkNode(node, content, file, issues) {
253
253
  return;
254
254
  }
255
255
  const funcName = head.name.toLowerCase();
256
+ // Don't recurse into quoted or function forms
257
+ if (funcName === 'quote' || funcName === 'function')
258
+ return;
256
259
  const arity = BUILTIN_ARITY[funcName];
257
260
  if (arity) {
258
261
  const argCount = node.children.length - 1;
@@ -260,7 +263,7 @@ function checkNode(node, content, file, issues) {
260
263
  issues.push({
261
264
  file,
262
265
  line: head.pos.line,
263
- severity: 'warn',
266
+ severity: 'error',
264
267
  rule: 'builtin_arg_count',
265
268
  message: (0, locale_1.t)('builtin_arg_count.too_few', funcName, argCount, arity.min),
266
269
  });
@@ -269,7 +272,7 @@ function checkNode(node, content, file, issues) {
269
272
  issues.push({
270
273
  file,
271
274
  line: head.pos.line,
272
- severity: 'warn',
275
+ severity: 'error',
273
276
  rule: 'builtin_arg_count',
274
277
  message: (0, locale_1.t)('builtin_arg_count.too_many', funcName, argCount, arity.max),
275
278
  });
@@ -8,7 +8,7 @@ function checkRedundantIf(content, file) {
8
8
  const lines = content.split('\n');
9
9
  for (let i = 0; i < lines.length; i++) {
10
10
  const stripped = (0, utils_1.stripLine)(lines[i]);
11
- if (/\((if|when|unless)\s+\S+\s+\(progn\b/.test(stripped)) {
11
+ if (/\((when|unless)\s+\S+\s+\(progn\b/.test(stripped)) {
12
12
  issues.push({ file, line: i + 1, severity: 'warn', rule: 'redundant_if', message: (0, locale_1.t)('redundant_if') });
13
13
  }
14
14
  }
package/dist/config.js CHANGED
@@ -122,12 +122,12 @@ const DEFAULT_CONFIG = {
122
122
  type_check: 'off',
123
123
  format_indent: 'off',
124
124
  redundant_if: 'warn',
125
- unused_catch_result: 'warn',
126
- string_concat_loop: 'warn',
125
+ unused_catch_result: 'off',
126
+ string_concat_loop: 'off',
127
127
  if_without_else: 'off',
128
128
  redundant_list: 'warn',
129
129
  entget_in_loop: 'warn',
130
- promise_handler: 'warn',
130
+ promise_handler: 'off',
131
131
  module_cycle: 'warn',
132
132
  arg_count_project: 'warn',
133
133
  },
package/dist/locale.js CHANGED
@@ -36,6 +36,7 @@ const messages = {
36
36
  unused_parameter: "Parameter '{0}' in '{1}' is never used",
37
37
  constant_condition: "Constant condition '{0}' in {1} — possibly leftover debug code",
38
38
  redundant_progn: 'Redundant progn in {0}: only one form inside',
39
+ redundant_if: "Redundant progn in when/unless body — when/unless already allows multiple forms",
39
40
  empty_branch: "Empty branch in '{0}' — no body forms",
40
41
  unused_let_binding: "Let binding '{0}' is never used",
41
42
  recursive_call: "Function '{0}' calls itself — possible infinite recursion",
@@ -156,6 +157,7 @@ Options:
156
157
  unused_parameter: "参数 '{0}' 在函数 '{1}' 中从未使用",
157
158
  constant_condition: "常量条件 '{0}' 在 {1} 中——可能是调试残留代码",
158
159
  redundant_progn: '冗余 progn:{0} 内只有一个表达式',
160
+ redundant_if: 'when/unless 体中冗余 progn —— when/unless 已隐含 progn,可直接写多个表达式',
159
161
  empty_branch: "'{0}' 的条件分支为空——没有表达式",
160
162
  unused_let_binding: "let 绑定 '{0}' 从未被使用",
161
163
  recursive_call: "函数 '{0}' 调用了自身——可能存在无限递归",
package/dist/presets.js CHANGED
@@ -10,7 +10,7 @@ exports.PRESETS = {
10
10
  quit_exit: 'error',
11
11
  command_shell: 'warn',
12
12
  startapp: 'warn',
13
- vl_registry_write: 'warn',
13
+ vl_registry_write: 'off',
14
14
  token_in_url: 'warn',
15
15
  open_without_close: 'warn',
16
16
  line_length: 'warn',
@@ -65,12 +65,12 @@ exports.PRESETS = {
65
65
  shadow_builtin: 'warn',
66
66
  dynamic_doc: 'warn',
67
67
  redundant_if: 'warn',
68
- unused_catch_result: 'warn',
69
- string_concat_loop: 'warn',
68
+ unused_catch_result: 'off',
69
+ string_concat_loop: 'off',
70
70
  if_without_else: 'off',
71
71
  redundant_list: 'warn',
72
72
  entget_in_loop: 'warn',
73
- promise_handler: 'warn',
73
+ promise_handler: 'off',
74
74
  module_cycle: 'warn',
75
75
  arg_count_project: 'warn',
76
76
  },
@@ -152,11 +152,11 @@ exports.PRESETS = {
152
152
  module_registration: 'error',
153
153
  namespace_header: 'error',
154
154
  unused_catch_result: 'error',
155
- string_concat_loop: 'warn',
155
+ string_concat_loop: 'off',
156
156
  if_without_else: 'off',
157
157
  redundant_list: 'error',
158
158
  entget_in_loop: 'warn',
159
- promise_handler: 'error',
159
+ promise_handler: 'off',
160
160
  module_cycle: 'error',
161
161
  arg_count_project: 'error',
162
162
  },
package/dist/rules.js CHANGED
@@ -156,7 +156,7 @@ exports.RULES = [
156
156
  description: '检测函数调用自身(可能无限递归)',
157
157
  category: '正确性',
158
158
  },
159
- { name: 'redundant_if', defaultSeverity: 'warn', description: '检测 if/when 分支中冗余 progn', category: '风格' },
159
+ { name: 'redundant_if', defaultSeverity: 'warn', description: '检测 when/unless 中冗余 progn(when/unless 已隐含 progn', category: '风格' },
160
160
  { name: 'redundant_let', defaultSeverity: 'warn', description: '检测无绑定的 let 建议改用 progn', category: '风格' },
161
161
  { name: 'redundant_nil_else', defaultSeverity: 'warn', description: '检测 if 中冗余的 nil 分支', category: '风格' },
162
162
  { name: 'redundant_progn', defaultSeverity: 'warn', description: '检测分支中多余的 progn', category: '风格' },
@@ -228,12 +228,12 @@ exports.RULES = [
228
228
  description: '检测 vlax-* 使用前未调用 vl-load-com',
229
229
  category: '最佳实践',
230
230
  },
231
- { name: 'unused_catch_result', defaultSeverity: 'warn', description: '检测 vl-catch-all-apply 结果被当布尔值用', category: '正确性' },
232
- { name: 'string_concat_loop', defaultSeverity: 'warn', description: '检测循环内字符串拼接', category: '性能' },
231
+ { name: 'unused_catch_result', defaultSeverity: 'off', description: '检测 vl-catch-all-apply 结果被当布尔值用', category: '正确性' },
232
+ { name: 'string_concat_loop', defaultSeverity: 'off', description: '检测循环内字符串拼接', category: '性能' },
233
233
  { name: 'if_without_else', defaultSeverity: 'off', description: '检测 if 无 else 分支', category: '风格' },
234
234
  { name: 'redundant_list', defaultSeverity: 'warn', description: '检测 (list) 等价于 nil', category: '风格' },
235
235
  { name: 'entget_in_loop', defaultSeverity: 'warn', description: '检测循环内 entget', category: '性能' },
236
- { name: 'promise_handler', defaultSeverity: 'warn', description: '检测 vlax-invoke 缺少回调处理器', category: '最佳实践' },
236
+ { name: 'promise_handler', defaultSeverity: 'off', description: '检测 vlax-invoke 缺少回调处理器', category: '最佳实践' },
237
237
  { name: 'module_cycle', defaultSeverity: 'warn', description: '检测模块循环依赖', category: '架构' },
238
238
  { name: 'arg_count_project', defaultSeverity: 'warn', description: '跨文件检查函数参数数量', category: '正确性' },
239
239
  { name: 'builtin_arg_count', defaultSeverity: 'error', description: '检查 AutoLISP 内置函数调用参数个数是否匹配', category: '正确性' },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlisp/lint",
3
- "version": "0.1.25",
3
+ "version": "0.1.27",
4
4
  "description": "AutoLISP static analysis tool — parens, security, conventions, SBCL syntax validation",
5
5
  "keywords": [
6
6
  "CAD",