@checkdigit/eslint-plugin 7.0.0-PR.88-26f3 → 7.0.0-PR.88-5b1b
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/dist-cjs/index.cjs +8525 -7033
- package/dist-cjs/metafile.json +133 -37
- package/dist-mjs/index.mjs +50 -35
- package/dist-mjs/no-wallaby-comment.mjs +8 -7
- package/dist-types/index.d.ts +7 -37
- package/package.json +1 -1
- package/src/index.ts +57 -34
- package/src/no-wallaby-comment.ts +8 -6
package/src/index.ts
CHANGED
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
* This code is licensed under the MIT license (see LICENSE.txt for details).
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
+
import fs from 'node:fs';
|
|
10
|
+
|
|
9
11
|
import invalidJsonStringify, { ruleId as invalidJsonStringifyRuleId } from './invalid-json-stringify';
|
|
10
12
|
import noFullResponse, { ruleId as noFullResponseRuleId } from './agent/no-full-response';
|
|
11
13
|
import noPromiseInstanceMethod, { ruleId as noPromiseInstanceMethodRuleId } from './no-promise-instance-method';
|
|
@@ -25,7 +27,17 @@ import regexComment from './regular-expression-comment';
|
|
|
25
27
|
import requireAssertPredicateRejectsThrows from './require-assert-predicate-rejects-throws';
|
|
26
28
|
import requireStrictAssert from './require-strict-assert';
|
|
27
29
|
|
|
28
|
-
|
|
30
|
+
const pkg = JSON.parse(fs.readFileSync('./package.json', 'utf-8')) as {
|
|
31
|
+
name: string;
|
|
32
|
+
version: string;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const plugin = {
|
|
36
|
+
// preferred location of name and version
|
|
37
|
+
meta: {
|
|
38
|
+
name: pkg.name,
|
|
39
|
+
version: pkg.version,
|
|
40
|
+
},
|
|
29
41
|
rules: {
|
|
30
42
|
'file-path-comment': filePathComment,
|
|
31
43
|
'no-card-numbers': noCardNumbers,
|
|
@@ -42,39 +54,50 @@ export default {
|
|
|
42
54
|
[requireResolveFullResponseRuleId]: requireResolveFullResponse,
|
|
43
55
|
[requireTypeOutOfTypeOnlyImportsRuleId]: requireTypeOutOfTypeOnlyImports,
|
|
44
56
|
},
|
|
45
|
-
configs: {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
'@checkdigit/regular-expression-comment': 'error',
|
|
54
|
-
'@checkdigit/require-assert-predicate-rejects-throws': 'error',
|
|
55
|
-
'@checkdigit/object-literal-response': 'error',
|
|
56
|
-
'@checkdigit/no-test-import': 'error',
|
|
57
|
-
[`@checkdigit/${invalidJsonStringifyRuleId}`]: 'error',
|
|
58
|
-
[`@checkdigit/${noPromiseInstanceMethodRuleId}`]: 'error',
|
|
59
|
-
[`@checkdigit/${noFullResponseRuleId}`]: 'error',
|
|
60
|
-
[`@checkdigit/${requireResolveFullResponseRuleId}`]: 'error',
|
|
61
|
-
[`@checkdigit/${requireTypeOutOfTypeOnlyImportsRuleId}`]: 'error',
|
|
62
|
-
},
|
|
57
|
+
configs: {},
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
// assign configs here so we can reference `plugin`
|
|
61
|
+
Object.assign(plugin.configs, {
|
|
62
|
+
all: {
|
|
63
|
+
plugins: {
|
|
64
|
+
'@checkdigit': plugin,
|
|
63
65
|
},
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
},
|
|
66
|
+
rules: {
|
|
67
|
+
'@checkdigit/no-card-numbers': 'error',
|
|
68
|
+
'@checkdigit/file-path-comment': 'error',
|
|
69
|
+
'@checkdigit/no-uuid': 'error',
|
|
70
|
+
'@checkdigit/require-strict-assert': 'error',
|
|
71
|
+
'@checkdigit/no-wallaby-comment': 'error',
|
|
72
|
+
'@checkdigit/regular-expression-comment': 'error',
|
|
73
|
+
'@checkdigit/require-assert-predicate-rejects-throws': 'error',
|
|
74
|
+
'@checkdigit/object-literal-response': 'error',
|
|
75
|
+
'@checkdigit/no-test-import': 'error',
|
|
76
|
+
[`@checkdigit/${invalidJsonStringifyRuleId}`]: 'error',
|
|
77
|
+
[`@checkdigit/${noPromiseInstanceMethodRuleId}`]: 'error',
|
|
78
|
+
[`@checkdigit/${noFullResponseRuleId}`]: 'error',
|
|
79
|
+
[`@checkdigit/${requireResolveFullResponseRuleId}`]: 'error',
|
|
80
|
+
[`@checkdigit/${requireTypeOutOfTypeOnlyImportsRuleId}`]: 'error',
|
|
78
81
|
},
|
|
79
82
|
},
|
|
80
|
-
|
|
83
|
+
recommended: {
|
|
84
|
+
plugins: {
|
|
85
|
+
'@checkdigit': plugin,
|
|
86
|
+
},
|
|
87
|
+
rules: {
|
|
88
|
+
'@checkdigit/no-card-numbers': 'error',
|
|
89
|
+
'@checkdigit/file-path-comment': 'off',
|
|
90
|
+
'@checkdigit/no-uuid': 'error',
|
|
91
|
+
'@checkdigit/require-strict-assert': 'error',
|
|
92
|
+
'@checkdigit/no-wallaby-comment': 'off',
|
|
93
|
+
'@checkdigit/regular-expression-comment': 'error',
|
|
94
|
+
'@checkdigit/require-assert-predicate-rejects-throws': 'error',
|
|
95
|
+
'@checkdigit/object-literal-response': 'error',
|
|
96
|
+
'@checkdigit/no-test-import': 'error',
|
|
97
|
+
[`@checkdigit/${invalidJsonStringifyRuleId}`]: 'error',
|
|
98
|
+
[`@checkdigit/${noPromiseInstanceMethodRuleId}`]: 'error',
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
export default plugin;
|
|
@@ -43,12 +43,14 @@ function processBlockComment(context: Rule.RuleContext, sourceCode: SourceCode,
|
|
|
43
43
|
let startLine = comment.loc?.start.line ?? 0;
|
|
44
44
|
const endLine = comment.loc?.end.line ?? 0;
|
|
45
45
|
let match;
|
|
46
|
+
|
|
47
|
+
let start;
|
|
48
|
+
let end;
|
|
46
49
|
while (comment.loc && (match = wallabyRegex.exec(commentValue)) !== null) {
|
|
47
50
|
const removeEntireComment = blockCommentRegex.test(comment.value.trim());
|
|
48
51
|
if (removeEntireComment) {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
removeWallabyComment(context, sourceCode, start, end);
|
|
52
|
+
start = sourceCode.getIndexFromLoc({ line: comment.loc.start.line, column: comment.loc.start.column });
|
|
53
|
+
end = sourceCode.getIndexFromLoc({ line: comment.loc.end.line, column: comment.loc.end.column });
|
|
52
54
|
} else {
|
|
53
55
|
let lineNumber = 0;
|
|
54
56
|
while (startLine <= endLine) {
|
|
@@ -59,10 +61,10 @@ function processBlockComment(context: Rule.RuleContext, sourceCode: SourceCode,
|
|
|
59
61
|
}
|
|
60
62
|
startLine++;
|
|
61
63
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
removeWallabyComment(context, sourceCode, start, end);
|
|
64
|
+
start = sourceCode.getIndexFromLoc({ line: lineNumber + 1, column: comment.loc.start.column });
|
|
65
|
+
end = sourceCode.getIndexFromLoc({ line: lineNumber + 2, column: 0 });
|
|
65
66
|
}
|
|
67
|
+
removeWallabyComment(context, sourceCode, start, end);
|
|
66
68
|
}
|
|
67
69
|
});
|
|
68
70
|
}
|