@atlisp/lint 0.2.16 → 0.2.17
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.
- package/README.md +1 -1
- package/atlisp-lint.default.json +1 -1
- package/dist/checks/arg-count.d.ts +2 -1
- package/dist/checks/arg-count.js +37 -19
- package/dist/checks/builtin-arg-count.d.ts +2 -1
- package/dist/checks/builtin-arg-count.js +3 -2
- package/dist/checks/cond-duplicate.js +5 -6
- package/dist/checks/constant-condition.js +9 -9
- package/dist/checks/dangerous-calls.js +1 -1
- package/dist/checks/dangling-defun.d.ts +0 -7
- package/dist/checks/dangling-defun.js +0 -63
- package/dist/checks/double-not.js +1 -1
- package/dist/checks/empty-branch.js +1 -1
- package/dist/checks/empty-catch.d.ts +2 -1
- package/dist/checks/empty-catch.js +8 -7
- package/dist/checks/function-complexity.js +5 -18
- package/dist/checks/global-naming.js +1 -1
- package/dist/checks/identical-branches.js +3 -3
- package/dist/checks/if-without-else.js +1 -1
- package/dist/checks/misplaced-else.js +2 -2
- package/dist/checks/missing-export.js +3 -3
- package/dist/checks/missing-princ.js +1 -1
- package/dist/checks/multiple-setq.js +1 -1
- package/dist/checks/no-return.d.ts +2 -1
- package/dist/checks/no-return.js +4 -3
- package/dist/checks/nth-usage.js +1 -1
- package/dist/checks/parameter-naming.js +2 -2
- package/dist/checks/quote-vs-function.js +1 -1
- package/dist/checks/recursive-call.js +1 -1
- package/dist/checks/redundant-let.js +1 -1
- package/dist/checks/redundant-nil-else.js +1 -1
- package/dist/checks/redundant-progn.js +1 -1
- package/dist/checks/redundant-setq.js +1 -1
- package/dist/checks/self-compare.js +1 -1
- package/dist/checks/setq-single-arg.js +3 -2
- package/dist/checks/single-arg-and-or.js +1 -1
- package/dist/checks/undeclared-setq.d.ts +2 -1
- package/dist/checks/undeclared-setq.js +6 -5
- package/dist/checks/unused-let.js +3 -3
- package/dist/checks/unused-local-fun.js +2 -2
- package/dist/checks/unused-package-dep.d.ts +0 -1
- package/dist/checks/unused-package-dep.js +6 -93
- package/dist/checks/unused-param.js +2 -2
- package/dist/checks/unused-variable.js +2 -2
- package/dist/checks/variable-shadow.js +3 -3
- package/dist/checks/while-constant.js +1 -1
- package/dist/cli/collector.js +26 -19
- package/dist/config.d.ts +1 -1
- package/dist/config.js +18 -9
- package/dist/fixes/index.d.ts +4 -0
- package/dist/fixes/index.js +843 -140
- package/dist/formatter.d.ts +0 -1
- package/dist/formatter.js +0 -6
- package/dist/index.js +59 -51
- package/dist/project.d.ts +1 -1
- package/dist/project.js +98 -112
- package/dist/runner.d.ts +1 -1
- package/dist/runner.js +17 -8
- package/dist/utils.js +21 -30
- package/dist/validate.js +3 -3
- package/dist/visitor-runner.d.ts +0 -28
- package/dist/visitor-runner.js +3 -809
- package/dist/visitors/equal-nil.d.ts +2 -2
- package/dist/visitors/equal-nil.js +5 -4
- package/dist/visitors/index.d.ts +1 -1
- package/dist/visitors/progn-in-cond.d.ts +2 -2
- package/dist/visitors/progn-in-cond.js +5 -4
- package/dist/visitors/redundant-and-or.d.ts +2 -2
- package/dist/visitors/redundant-and-or.js +3 -3
- package/dist/visitors/redundant-car-cdr.d.ts +2 -2
- package/dist/visitors/redundant-car-cdr.js +3 -3
- package/dist/visitors/register.d.ts +6 -0
- package/dist/visitors/register.js +625 -0
- package/dist/visitors/shared.d.ts +40 -0
- package/dist/visitors/shared.js +129 -0
- package/dist/visitors/types.d.ts +2 -7
- package/dist/visitors/types.js +0 -69
- package/dist/watch.js +33 -12
- package/dist/worker.js +1 -1
- package/package.json +2 -2
package/dist/utils.js
CHANGED
|
@@ -6,8 +6,7 @@ exports.codeLines = codeLines;
|
|
|
6
6
|
exports.findMatchingParen = findMatchingParen;
|
|
7
7
|
exports.extractForm = extractForm;
|
|
8
8
|
exports.extractStrings = extractStrings;
|
|
9
|
-
|
|
10
|
-
function stripLine(line) {
|
|
9
|
+
function stripLineInternal(line, keepQuotes) {
|
|
11
10
|
const out = [];
|
|
12
11
|
let inStr = false;
|
|
13
12
|
let i = 0;
|
|
@@ -17,46 +16,38 @@ function stripLine(line) {
|
|
|
17
16
|
break;
|
|
18
17
|
if (ch === '"') {
|
|
19
18
|
inStr = !inStr;
|
|
19
|
+
if (keepQuotes)
|
|
20
|
+
out.push(ch);
|
|
20
21
|
i++;
|
|
21
22
|
continue;
|
|
22
23
|
}
|
|
23
24
|
if (ch === '\\' && inStr) {
|
|
24
|
-
|
|
25
|
+
if (keepQuotes) {
|
|
26
|
+
out.push(ch);
|
|
27
|
+
if (i + 1 < line.length) {
|
|
28
|
+
out.push(line[i + 1]);
|
|
29
|
+
i++;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
if (i + 1 < line.length)
|
|
34
|
+
i++;
|
|
35
|
+
}
|
|
36
|
+
i++;
|
|
25
37
|
continue;
|
|
26
38
|
}
|
|
27
|
-
if (!inStr)
|
|
39
|
+
if (keepQuotes || !inStr)
|
|
28
40
|
out.push(ch);
|
|
29
41
|
i++;
|
|
30
42
|
}
|
|
31
43
|
return out.join('');
|
|
32
44
|
}
|
|
45
|
+
/** Strip string contents and comments from a line of AutoLISP code */
|
|
46
|
+
function stripLine(line) {
|
|
47
|
+
return stripLineInternal(line, false);
|
|
48
|
+
}
|
|
33
49
|
function stripLineRaw(line) {
|
|
34
|
-
|
|
35
|
-
let inStr = false;
|
|
36
|
-
let i = 0;
|
|
37
|
-
while (i < line.length) {
|
|
38
|
-
const ch = line[i];
|
|
39
|
-
if (ch === ';' && !inStr)
|
|
40
|
-
break;
|
|
41
|
-
if (ch === '"') {
|
|
42
|
-
inStr = !inStr;
|
|
43
|
-
out.push(ch);
|
|
44
|
-
i++;
|
|
45
|
-
continue;
|
|
46
|
-
}
|
|
47
|
-
if (ch === '\\' && inStr) {
|
|
48
|
-
out.push(ch);
|
|
49
|
-
if (i + 1 < line.length) {
|
|
50
|
-
out.push(line[i + 1]);
|
|
51
|
-
i++;
|
|
52
|
-
}
|
|
53
|
-
i++;
|
|
54
|
-
continue;
|
|
55
|
-
}
|
|
56
|
-
out.push(ch);
|
|
57
|
-
i++;
|
|
58
|
-
}
|
|
59
|
-
return out.join('');
|
|
50
|
+
return stripLineInternal(line, true);
|
|
60
51
|
}
|
|
61
52
|
/** Iterate lines with string-aware content */
|
|
62
53
|
function* codeLines(content) {
|
package/dist/validate.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.validateConfig = validateConfig;
|
|
4
|
-
const VALID_RULES = [
|
|
4
|
+
const VALID_RULES = new Set([
|
|
5
5
|
'append_single',
|
|
6
6
|
'arg_count',
|
|
7
7
|
'assoc_without_cdr',
|
|
@@ -101,7 +101,7 @@ const VALID_RULES = [
|
|
|
101
101
|
'redundant_car_cdr',
|
|
102
102
|
'equal_nil',
|
|
103
103
|
'redundant_and_or',
|
|
104
|
-
];
|
|
104
|
+
]);
|
|
105
105
|
const VALID_SEVERITIES = ['off', 'info', 'warn', 'error'];
|
|
106
106
|
function validateConfig(config) {
|
|
107
107
|
const errors = [];
|
|
@@ -110,7 +110,7 @@ function validateConfig(config) {
|
|
|
110
110
|
}
|
|
111
111
|
if (config.checks) {
|
|
112
112
|
for (const [rule, sev] of Object.entries(config.checks)) {
|
|
113
|
-
if (!VALID_RULES.
|
|
113
|
+
if (!VALID_RULES.has(rule)) {
|
|
114
114
|
errors.push({ path: `checks.${rule}`, message: `Unknown rule '${rule}'` });
|
|
115
115
|
}
|
|
116
116
|
if (!VALID_SEVERITIES.includes(sev)) {
|
package/dist/visitor-runner.d.ts
CHANGED
|
@@ -1,32 +1,4 @@
|
|
|
1
1
|
import { Issue, LintConfig } from './types';
|
|
2
2
|
import { AstNode } from '@atlisp/parser';
|
|
3
|
-
export interface CollectState {
|
|
4
|
-
openCount: number;
|
|
5
|
-
closeCount: number;
|
|
6
|
-
setqDefs: Map<string, {
|
|
7
|
-
line: number;
|
|
8
|
-
file: string;
|
|
9
|
-
}>;
|
|
10
|
-
symbolRefs: Map<string, number>;
|
|
11
|
-
condKeys: Map<number, Set<string>>;
|
|
12
|
-
defunScopes: Array<{
|
|
13
|
-
name: string;
|
|
14
|
-
params: string[];
|
|
15
|
-
body: AstNode[];
|
|
16
|
-
line: number;
|
|
17
|
-
file: string;
|
|
18
|
-
}>;
|
|
19
|
-
letScopes: Array<{
|
|
20
|
-
bindings: string[];
|
|
21
|
-
body: AstNode[];
|
|
22
|
-
line: number;
|
|
23
|
-
}>;
|
|
24
|
-
dangerousCalls: Array<{
|
|
25
|
-
name: string;
|
|
26
|
-
node: AstNode;
|
|
27
|
-
}>;
|
|
28
|
-
ssgetCount: number;
|
|
29
|
-
sssetCount: number;
|
|
30
|
-
}
|
|
31
3
|
export declare function runChecksWithVisitor(ast: AstNode, file: string, config: LintConfig, disableMap: Map<string, Set<number>>): Issue[];
|
|
32
4
|
//# sourceMappingURL=visitor-runner.d.ts.map
|