@simplysm/eslint-plugin 12.16.27 → 12.16.29
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/package.json +7 -7
- package/src/rules/ng-template-no-todo-comments.js +2 -4
- package/src/rules/no-hard-private.js +1 -1
- package/src/rules/ts-no-buffer-in-typedarray-context.js +23 -16
- package/src/rules/ts-no-exported-types.js +18 -20
- package/src/rules/ts-no-throw-not-implement-error.js +1 -1
- package/src/rules/ts-no-unused-injects.js +1 -1
- package/src/rules/ts-no-unused-protected-readonly.js +4 -3
- package/tests/ng-template-no-todo-comments.spec.js +56 -59
- package/tests/ts-no-buffer-in-typedarray-context.spec.js +39 -39
- package/tests/ts-no-exported-types.spec.js +71 -71
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@simplysm/eslint-plugin",
|
|
3
|
-
"version": "12.16.
|
|
3
|
+
"version": "12.16.29",
|
|
4
4
|
"description": "심플리즘 패키지 - ESLINT 플러그인",
|
|
5
5
|
"author": "김석래",
|
|
6
6
|
"repository": {
|
|
@@ -13,18 +13,18 @@
|
|
|
13
13
|
"main": "src/index.js",
|
|
14
14
|
"dependencies": {
|
|
15
15
|
"@angular-eslint/utils": "^20.7.0",
|
|
16
|
-
"@eslint/compat": "^2.0.
|
|
17
|
-
"@typescript-eslint/utils": "^8.
|
|
16
|
+
"@eslint/compat": "^2.0.3",
|
|
17
|
+
"@typescript-eslint/utils": "^8.57.0",
|
|
18
18
|
"angular-eslint": "^20.7.0",
|
|
19
|
-
"eslint": "^9.39.
|
|
19
|
+
"eslint": "^9.39.4",
|
|
20
20
|
"eslint-import-resolver-typescript": "^4.4.4",
|
|
21
21
|
"eslint-plugin-import": "^2.32.0",
|
|
22
|
-
"eslint-plugin-unused-imports": "^4.
|
|
22
|
+
"eslint-plugin-unused-imports": "^4.4.1",
|
|
23
23
|
"globals": "^16.5.0",
|
|
24
24
|
"typescript": "~5.8.3",
|
|
25
|
-
"typescript-eslint": "^8.
|
|
25
|
+
"typescript-eslint": "^8.57.0"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@typescript-eslint/rule-tester": "^8.
|
|
28
|
+
"@typescript-eslint/rule-tester": "^8.57.0"
|
|
29
29
|
}
|
|
30
30
|
}
|
|
@@ -22,9 +22,7 @@ export default {
|
|
|
22
22
|
|
|
23
23
|
const start = match.index;
|
|
24
24
|
const end = start + match[0].length;
|
|
25
|
-
const content = commentContent
|
|
26
|
-
.slice(todoIndex + 5)
|
|
27
|
-
.trim();
|
|
25
|
+
const content = commentContent.slice(todoIndex + 5).trim();
|
|
28
26
|
|
|
29
27
|
const loc = context.getSourceCode().getLocFromIndex(start);
|
|
30
28
|
const endLoc = context.getSourceCode().getLocFromIndex(end);
|
|
@@ -38,4 +36,4 @@ export default {
|
|
|
38
36
|
|
|
39
37
|
return {};
|
|
40
38
|
},
|
|
41
|
-
};
|
|
39
|
+
};
|
|
@@ -1,22 +1,29 @@
|
|
|
1
1
|
import ts from "typescript";
|
|
2
|
-
import { ESLintUtils } from
|
|
2
|
+
import { ESLintUtils } from "@typescript-eslint/utils";
|
|
3
3
|
|
|
4
4
|
const TYPED_ARRAY_NAMES = new Set([
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
"Uint8Array",
|
|
6
|
+
"Uint8ClampedArray",
|
|
7
|
+
"Int8Array",
|
|
8
|
+
"Uint16Array",
|
|
9
|
+
"Int16Array",
|
|
10
|
+
"Uint32Array",
|
|
11
|
+
"Int32Array",
|
|
12
|
+
"Float32Array",
|
|
13
|
+
"Float64Array",
|
|
9
14
|
]);
|
|
10
15
|
|
|
11
16
|
export default {
|
|
12
17
|
meta: {
|
|
13
|
-
type:
|
|
18
|
+
type: "problem",
|
|
14
19
|
docs: {
|
|
15
|
-
description:
|
|
16
|
-
|
|
20
|
+
description:
|
|
21
|
+
"Disallow Buffer being used directly in TypedArray contexts. Use new TypedArray(buffer) instead.",
|
|
22
|
+
recommended: "error",
|
|
17
23
|
},
|
|
18
24
|
messages: {
|
|
19
|
-
directBuffer:
|
|
25
|
+
directBuffer:
|
|
26
|
+
"Do not use Buffer directly where {{expected}} is expected. Use new {{expected}}(buffer) instead.",
|
|
20
27
|
},
|
|
21
28
|
schema: [],
|
|
22
29
|
},
|
|
@@ -39,7 +46,7 @@ export default {
|
|
|
39
46
|
}
|
|
40
47
|
|
|
41
48
|
function isBuffer(type) {
|
|
42
|
-
return getTypeName(type) ===
|
|
49
|
+
return getTypeName(type) === "Buffer";
|
|
43
50
|
}
|
|
44
51
|
|
|
45
52
|
function isTypedArray(type) {
|
|
@@ -57,7 +64,7 @@ export default {
|
|
|
57
64
|
const expr = current.expression;
|
|
58
65
|
if (
|
|
59
66
|
expr.expression.kind === ts.SyntaxKind.Identifier &&
|
|
60
|
-
expr.expression.escapedText ===
|
|
67
|
+
expr.expression.escapedText === "Buffer"
|
|
61
68
|
) {
|
|
62
69
|
return true;
|
|
63
70
|
}
|
|
@@ -79,15 +86,15 @@ export default {
|
|
|
79
86
|
|
|
80
87
|
context.report({
|
|
81
88
|
node,
|
|
82
|
-
messageId:
|
|
89
|
+
messageId: "directBuffer",
|
|
83
90
|
data: {
|
|
84
|
-
expected: getTypeName(expectedType) ||
|
|
91
|
+
expected: getTypeName(expectedType) || "TypedArray",
|
|
85
92
|
},
|
|
86
93
|
});
|
|
87
94
|
}
|
|
88
95
|
|
|
89
96
|
function checkTypedAssignment(lhsNode, rhsNode) {
|
|
90
|
-
if (lhsNode.type !==
|
|
97
|
+
if (lhsNode.type !== "Identifier") return;
|
|
91
98
|
|
|
92
99
|
const lhsTsNode = parserServices.esTreeNodeToTSNodeMap.get(lhsNode);
|
|
93
100
|
const expectedType = getCachedType(lhsTsNode);
|
|
@@ -140,8 +147,8 @@ export default {
|
|
|
140
147
|
},
|
|
141
148
|
|
|
142
149
|
ArrayExpression(node) {
|
|
143
|
-
node.elements.forEach(el => {
|
|
144
|
-
if (el && el.type !==
|
|
150
|
+
node.elements.forEach((el) => {
|
|
151
|
+
if (el && el.type !== "SpreadElement") {
|
|
145
152
|
const tsNode = parserServices.esTreeNodeToTSNodeMap.get(el);
|
|
146
153
|
const contextualType = checker.getContextualType(tsNode);
|
|
147
154
|
if (contextualType) {
|
|
@@ -7,7 +7,7 @@ export default {
|
|
|
7
7
|
docs: {
|
|
8
8
|
description:
|
|
9
9
|
"지정된 타입이 export API나 public 클래스 멤버에서 노출되는 것을 금지하고, 대체 타입을 안내합니다.",
|
|
10
|
-
recommended:
|
|
10
|
+
recommended: "error",
|
|
11
11
|
},
|
|
12
12
|
schema: [
|
|
13
13
|
{
|
|
@@ -40,11 +40,13 @@ export default {
|
|
|
40
40
|
|
|
41
41
|
create(context) {
|
|
42
42
|
const optTypes = context.options[0].types;
|
|
43
|
-
const optTypeMap = new Map(
|
|
44
|
-
t
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
43
|
+
const optTypeMap = new Map(
|
|
44
|
+
optTypes.map((t) => [
|
|
45
|
+
t.ban,
|
|
46
|
+
{ safe: t.safe ?? undefined, ignoreInGeneric: t.ignoreInGeneric ?? false },
|
|
47
|
+
]),
|
|
48
|
+
);
|
|
49
|
+
const bannedTypeNames = new Set(optTypes.map((t) => t.ban));
|
|
48
50
|
|
|
49
51
|
const parserServices = ESLintUtils.getParserServices(context);
|
|
50
52
|
const checker = parserServices.program.getTypeChecker();
|
|
@@ -71,11 +73,12 @@ export default {
|
|
|
71
73
|
return { ban: name, safe: entry.safe };
|
|
72
74
|
}
|
|
73
75
|
|
|
74
|
-
const typeArgs =
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
76
|
+
const typeArgs =
|
|
77
|
+
"aliasTypeArguments" in t && Array.isArray(t.aliasTypeArguments)
|
|
78
|
+
? t.aliasTypeArguments
|
|
79
|
+
: t.flags & ts.TypeFlags.Object && t.objectFlags & ts.ObjectFlags.Reference
|
|
80
|
+
? checker.getTypeArguments(t)
|
|
81
|
+
: [];
|
|
79
82
|
|
|
80
83
|
for (const arg of typeArgs) {
|
|
81
84
|
const match = visit(arg);
|
|
@@ -120,8 +123,7 @@ export default {
|
|
|
120
123
|
return {
|
|
121
124
|
FunctionDeclaration(node) {
|
|
122
125
|
const tsNode = parserServices.esTreeNodeToTSNodeMap.get(node);
|
|
123
|
-
const isExported =
|
|
124
|
-
(ts.getCombinedModifierFlags(tsNode) & ts.ModifierFlags.Export) !== 0;
|
|
126
|
+
const isExported = (ts.getCombinedModifierFlags(tsNode) & ts.ModifierFlags.Export) !== 0;
|
|
125
127
|
if (!isExported) return;
|
|
126
128
|
|
|
127
129
|
const signature = checker.getSignatureFromDeclaration(tsNode);
|
|
@@ -137,9 +139,7 @@ export default {
|
|
|
137
139
|
|
|
138
140
|
MethodDefinition(node) {
|
|
139
141
|
const isConstructor = node.kind === "constructor";
|
|
140
|
-
const isPublic =
|
|
141
|
-
node.accessibility !== "private" &&
|
|
142
|
-
node.accessibility !== "protected";
|
|
142
|
+
const isPublic = node.accessibility !== "private" && node.accessibility !== "protected";
|
|
143
143
|
if (!isConstructor && !isPublic) return;
|
|
144
144
|
|
|
145
145
|
const tsNode = parserServices.esTreeNodeToTSNodeMap.get(node.value);
|
|
@@ -157,8 +157,7 @@ export default {
|
|
|
157
157
|
},
|
|
158
158
|
|
|
159
159
|
PropertyDefinition(node) {
|
|
160
|
-
const isPublic =
|
|
161
|
-
node.accessibility !== "private" && node.accessibility !== "protected";
|
|
160
|
+
const isPublic = node.accessibility !== "private" && node.accessibility !== "protected";
|
|
162
161
|
if (!isPublic) return;
|
|
163
162
|
|
|
164
163
|
const tsNode = parserServices.esTreeNodeToTSNodeMap.get(node);
|
|
@@ -184,8 +183,7 @@ export default {
|
|
|
184
183
|
node.id.typeAnnotation.typeAnnotation,
|
|
185
184
|
);
|
|
186
185
|
type = checker.getTypeFromTypeNode(tsType);
|
|
187
|
-
}
|
|
188
|
-
else if (node.init) {
|
|
186
|
+
} else if (node.init) {
|
|
189
187
|
const tsInit = parserServices.esTreeNodeToTSNodeMap.get(node.init);
|
|
190
188
|
type = getCachedType(tsInit);
|
|
191
189
|
}
|
|
@@ -23,7 +23,7 @@ export default {
|
|
|
23
23
|
node.type === "PropertyDefinition" &&
|
|
24
24
|
node.value?.type === "CallExpression" &&
|
|
25
25
|
node.value.callee?.name === "inject" &&
|
|
26
|
-
node.key?.type === "Identifier"
|
|
26
|
+
node.key?.type === "Identifier",
|
|
27
27
|
);
|
|
28
28
|
|
|
29
29
|
for (const field of injectFields) {
|
|
@@ -31,7 +31,8 @@ export default {
|
|
|
31
31
|
if (!args?.[0] || args[0].type !== "ObjectExpression") return;
|
|
32
32
|
|
|
33
33
|
const templateProp = args[0].properties.find(
|
|
34
|
-
(p) =>
|
|
34
|
+
(p) =>
|
|
35
|
+
p.type === "Property" && p.key?.type === "Identifier" && p.key?.name === "template",
|
|
35
36
|
);
|
|
36
37
|
|
|
37
38
|
if (!templateProp) return;
|
|
@@ -54,7 +55,7 @@ export default {
|
|
|
54
55
|
node.accessibility === "protected" &&
|
|
55
56
|
node.readonly === true &&
|
|
56
57
|
!node.static &&
|
|
57
|
-
node.key?.type === "Identifier"
|
|
58
|
+
node.key?.type === "Identifier",
|
|
58
59
|
);
|
|
59
60
|
|
|
60
61
|
for (const field of protectedReadonlyFields) {
|
|
@@ -63,7 +64,7 @@ export default {
|
|
|
63
64
|
// 템플릿에서 사용 여부
|
|
64
65
|
// \b는 $로 시작하는 identifier에서 동작 안 함 → lookahead/lookbehind 사용
|
|
65
66
|
const identifierPattern = new RegExp(
|
|
66
|
-
`(?<![a-zA-Z0-9_$])${escapeRegExp(fieldName)}(?![a-zA-Z0-9_$])
|
|
67
|
+
`(?<![a-zA-Z0-9_$])${escapeRegExp(fieldName)}(?![a-zA-Z0-9_$])`,
|
|
67
68
|
);
|
|
68
69
|
const usedInTemplate = identifierPattern.test(templateText);
|
|
69
70
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { RuleTester } from
|
|
2
|
-
import rule from
|
|
1
|
+
import { RuleTester } from "eslint";
|
|
2
|
+
import rule from "../src/rules/ng-template-no-todo-comments.js";
|
|
3
3
|
import { describe, expect } from "vitest";
|
|
4
4
|
import { templateParser } from "angular-eslint";
|
|
5
5
|
|
|
6
|
-
describe(
|
|
6
|
+
describe("ng-template-no-todo-comments 규칙 테스트", () => {
|
|
7
7
|
// 인라인 템플릿을 가진 Angular 컴포넌트 생성을 위한 헬퍼 함수
|
|
8
8
|
const createComponentWithTemplate = (template) => `
|
|
9
9
|
import { Component } from '@angular/core';
|
|
@@ -24,53 +24,53 @@ describe('ng-template-no-todo-comments 규칙 테스트', () => {
|
|
|
24
24
|
});
|
|
25
25
|
|
|
26
26
|
// 기본 템플릿 테스트
|
|
27
|
-
describe(
|
|
27
|
+
describe("기본 템플릿 테스트", () => {
|
|
28
28
|
// 유효한 템플릿 테스트 (규칙 위반 없음)
|
|
29
|
-
describe(
|
|
30
|
-
ruleTester.run(
|
|
29
|
+
describe("정상적인 HTML 템플릿은 경고가 없어야 함", () => {
|
|
30
|
+
ruleTester.run("ng-template-no-todo-comments", rule, {
|
|
31
31
|
valid: [
|
|
32
32
|
{
|
|
33
|
-
code: createComponentWithTemplate(
|
|
34
|
-
filename:
|
|
33
|
+
code: createComponentWithTemplate("<div>정상적인 HTML 템플릿</div>"),
|
|
34
|
+
filename: "test.component.ts",
|
|
35
35
|
},
|
|
36
36
|
],
|
|
37
37
|
invalid: [],
|
|
38
38
|
});
|
|
39
39
|
});
|
|
40
40
|
|
|
41
|
-
describe(
|
|
42
|
-
ruleTester.run(
|
|
41
|
+
describe("일반 주석은 경고가 없어야 함", () => {
|
|
42
|
+
ruleTester.run("ng-template-no-todo-comments", rule, {
|
|
43
43
|
valid: [
|
|
44
44
|
{
|
|
45
|
-
code: createComponentWithTemplate(
|
|
46
|
-
filename:
|
|
45
|
+
code: createComponentWithTemplate("<!-- 일반 주석 -->"),
|
|
46
|
+
filename: "test.component.ts",
|
|
47
47
|
},
|
|
48
48
|
],
|
|
49
49
|
invalid: [],
|
|
50
50
|
});
|
|
51
51
|
});
|
|
52
52
|
|
|
53
|
-
describe(
|
|
54
|
-
ruleTester.run(
|
|
53
|
+
describe("NOTE 주석은 경고가 없어야 함", () => {
|
|
54
|
+
ruleTester.run("ng-template-no-todo-comments", rule, {
|
|
55
55
|
valid: [
|
|
56
56
|
{
|
|
57
|
-
code: createComponentWithTemplate(
|
|
58
|
-
filename:
|
|
57
|
+
code: createComponentWithTemplate("<!-- NOTE: 이것은 메모입니다 -->"),
|
|
58
|
+
filename: "test.component.ts",
|
|
59
59
|
},
|
|
60
60
|
],
|
|
61
61
|
invalid: [],
|
|
62
62
|
});
|
|
63
63
|
});
|
|
64
64
|
|
|
65
|
-
describe(
|
|
66
|
-
ruleTester.run(
|
|
65
|
+
describe("여러 줄의 일반 주석은 경고가 없어야 함", () => {
|
|
66
|
+
ruleTester.run("ng-template-no-todo-comments", rule, {
|
|
67
67
|
valid: [
|
|
68
68
|
{
|
|
69
69
|
code: createComponentWithTemplate(`<div>
|
|
70
70
|
<!-- 여러 줄에 걸친
|
|
71
71
|
일반 주석입니다 -->
|
|
72
72
|
</div>`),
|
|
73
|
-
filename:
|
|
73
|
+
filename: "test.component.ts",
|
|
74
74
|
},
|
|
75
75
|
],
|
|
76
76
|
invalid: [],
|
|
@@ -78,22 +78,22 @@ describe('ng-template-no-todo-comments 규칙 테스트', () => {
|
|
|
78
78
|
});
|
|
79
79
|
});
|
|
80
80
|
|
|
81
|
-
describe(
|
|
82
|
-
describe(
|
|
83
|
-
ruleTester.run(
|
|
81
|
+
describe("TODO 주석 테스트", () => {
|
|
82
|
+
describe("단일 TODO 주석은 경고가 발생해야 함", () => {
|
|
83
|
+
ruleTester.run("ng-template-no-todo-comments", rule, {
|
|
84
84
|
valid: [],
|
|
85
85
|
invalid: [
|
|
86
86
|
{
|
|
87
|
-
code: createComponentWithTemplate(
|
|
88
|
-
filename:
|
|
89
|
-
errors: [{ messageId:
|
|
87
|
+
code: createComponentWithTemplate("<!-- TODO: 이 기능 구현 필요 -->"),
|
|
88
|
+
filename: "test.component.ts",
|
|
89
|
+
errors: [{ messageId: "noTodo" }],
|
|
90
90
|
},
|
|
91
91
|
],
|
|
92
92
|
});
|
|
93
93
|
});
|
|
94
94
|
|
|
95
|
-
describe(
|
|
96
|
-
ruleTester.run(
|
|
95
|
+
describe("요소 내부의 TODO 주석은 경고가 발생해야 함", () => {
|
|
96
|
+
ruleTester.run("ng-template-no-todo-comments", rule, {
|
|
97
97
|
valid: [],
|
|
98
98
|
invalid: [
|
|
99
99
|
{
|
|
@@ -101,30 +101,30 @@ describe('ng-template-no-todo-comments 규칙 테스트', () => {
|
|
|
101
101
|
<!-- TODO: 여기에 폼 추가하기 -->
|
|
102
102
|
<span>임시 내용</span>
|
|
103
103
|
</div>`),
|
|
104
|
-
filename:
|
|
105
|
-
errors: [{ messageId:
|
|
104
|
+
filename: "test.component.ts",
|
|
105
|
+
errors: [{ messageId: "noTodo" }],
|
|
106
106
|
},
|
|
107
107
|
],
|
|
108
108
|
});
|
|
109
109
|
});
|
|
110
110
|
|
|
111
|
-
describe(
|
|
112
|
-
ruleTester.run(
|
|
111
|
+
describe("주석 텍스트 안에 TODO 키워드가 있으면 경고가 발생해야 함", () => {
|
|
112
|
+
ruleTester.run("ng-template-no-todo-comments", rule, {
|
|
113
113
|
valid: [],
|
|
114
114
|
invalid: [
|
|
115
115
|
{
|
|
116
116
|
code: createComponentWithTemplate(`<div>
|
|
117
117
|
<!-- 이 부분은 TODO: 수정이 필요합니다 -->
|
|
118
118
|
</div>`),
|
|
119
|
-
filename:
|
|
120
|
-
errors: [{ messageId:
|
|
119
|
+
filename: "test.component.ts",
|
|
120
|
+
errors: [{ messageId: "noTodo" }],
|
|
121
121
|
},
|
|
122
122
|
],
|
|
123
123
|
});
|
|
124
124
|
});
|
|
125
125
|
|
|
126
|
-
describe(
|
|
127
|
-
ruleTester.run(
|
|
126
|
+
describe("여러 줄 주석 내의 TODO 키워드도 감지해야 함", () => {
|
|
127
|
+
ruleTester.run("ng-template-no-todo-comments", rule, {
|
|
128
128
|
valid: [],
|
|
129
129
|
invalid: [
|
|
130
130
|
{
|
|
@@ -135,26 +135,23 @@ describe('ng-template-no-todo-comments 규칙 테스트', () => {
|
|
|
135
135
|
가 포함된 케이스
|
|
136
136
|
-->
|
|
137
137
|
</div>`),
|
|
138
|
-
filename:
|
|
139
|
-
errors: [{ messageId:
|
|
138
|
+
filename: "test.component.ts",
|
|
139
|
+
errors: [{ messageId: "noTodo" }],
|
|
140
140
|
},
|
|
141
141
|
],
|
|
142
142
|
});
|
|
143
143
|
});
|
|
144
144
|
|
|
145
|
-
describe(
|
|
146
|
-
ruleTester.run(
|
|
145
|
+
describe("여러 개의 TODO 주석은 각각 감지되어야 함", () => {
|
|
146
|
+
ruleTester.run("ng-template-no-todo-comments", rule, {
|
|
147
147
|
valid: [],
|
|
148
148
|
invalid: [
|
|
149
149
|
{
|
|
150
150
|
code: createComponentWithTemplate(`<!-- TODO: 첫 번째 할 일 -->
|
|
151
151
|
<div>내용</div>
|
|
152
152
|
<!-- TODO: 두 번째 할 일 -->`),
|
|
153
|
-
filename:
|
|
154
|
-
errors: [
|
|
155
|
-
{ messageId: 'noTodo' },
|
|
156
|
-
{ messageId: 'noTodo' },
|
|
157
|
-
],
|
|
153
|
+
filename: "test.component.ts",
|
|
154
|
+
errors: [{ messageId: "noTodo" }, { messageId: "noTodo" }],
|
|
158
155
|
},
|
|
159
156
|
],
|
|
160
157
|
});
|
|
@@ -162,9 +159,9 @@ describe('ng-template-no-todo-comments 규칙 테스트', () => {
|
|
|
162
159
|
});
|
|
163
160
|
|
|
164
161
|
// ng-template 지시자 테스트
|
|
165
|
-
describe(
|
|
166
|
-
describe(
|
|
167
|
-
ruleTester.run(
|
|
162
|
+
describe("ng-template 지시자 테스트", () => {
|
|
163
|
+
describe("ng-template 안의 TODO 주석을 감지해야 함", () => {
|
|
164
|
+
ruleTester.run("ng-template-no-todo-comments", rule, {
|
|
168
165
|
valid: [],
|
|
169
166
|
invalid: [
|
|
170
167
|
{
|
|
@@ -178,15 +175,15 @@ describe('ng-template-no-todo-comments 규칙 테스트', () => {
|
|
|
178
175
|
})
|
|
179
176
|
export class TestComponent {}
|
|
180
177
|
`,
|
|
181
|
-
filename:
|
|
182
|
-
errors: [{ messageId:
|
|
178
|
+
filename: "test.component.ts",
|
|
179
|
+
errors: [{ messageId: "noTodo" }],
|
|
183
180
|
},
|
|
184
181
|
],
|
|
185
182
|
});
|
|
186
183
|
});
|
|
187
184
|
|
|
188
|
-
describe(
|
|
189
|
-
ruleTester.run(
|
|
185
|
+
describe("ng-template 지시자가 있는 경우에도 정상 작동해야 함", () => {
|
|
186
|
+
ruleTester.run("ng-template-no-todo-comments", rule, {
|
|
190
187
|
valid: [
|
|
191
188
|
{
|
|
192
189
|
code: `
|
|
@@ -204,15 +201,15 @@ describe('ng-template-no-todo-comments 규칙 테스트', () => {
|
|
|
204
201
|
})
|
|
205
202
|
export class TestComponent {}
|
|
206
203
|
`,
|
|
207
|
-
filename:
|
|
204
|
+
filename: "test.component.ts",
|
|
208
205
|
},
|
|
209
206
|
],
|
|
210
207
|
invalid: [],
|
|
211
208
|
});
|
|
212
209
|
});
|
|
213
210
|
|
|
214
|
-
describe(
|
|
215
|
-
ruleTester.run(
|
|
211
|
+
describe("ng-template 지시자가 있는 경우 TODO 주석을 감지해야 함", () => {
|
|
212
|
+
ruleTester.run("ng-template-no-todo-comments", rule, {
|
|
216
213
|
valid: [],
|
|
217
214
|
invalid: [
|
|
218
215
|
{
|
|
@@ -231,8 +228,8 @@ describe('ng-template-no-todo-comments 규칙 테스트', () => {
|
|
|
231
228
|
})
|
|
232
229
|
export class TestComponent {}
|
|
233
230
|
`,
|
|
234
|
-
filename:
|
|
235
|
-
errors: [{ messageId:
|
|
231
|
+
filename: "test.component.ts",
|
|
232
|
+
errors: [{ messageId: "noTodo" }],
|
|
236
233
|
},
|
|
237
234
|
],
|
|
238
235
|
});
|
|
@@ -240,8 +237,8 @@ describe('ng-template-no-todo-comments 규칙 테스트', () => {
|
|
|
240
237
|
});
|
|
241
238
|
|
|
242
239
|
// 정규식 테스트
|
|
243
|
-
describe(
|
|
244
|
-
describe(
|
|
240
|
+
describe("정규식 패턴 테스트", () => {
|
|
241
|
+
describe("정규식이 올바르게 TODO 주석을 감지해야 함", () => {
|
|
245
242
|
const testHtml = `
|
|
246
243
|
<!-- 일반 주석 -->
|
|
247
244
|
<!-- TODO: 할 일 항목 -->
|
|
@@ -254,7 +251,7 @@ describe('ng-template-no-todo-comments 규칙 테스트', () => {
|
|
|
254
251
|
const matches = [...testHtml.matchAll(commentRegex)];
|
|
255
252
|
|
|
256
253
|
// 매칭된 주석 중 'TODO:'가 포함된 주석 수 확인
|
|
257
|
-
const todoComments = matches.filter(match => match[0].includes(
|
|
254
|
+
const todoComments = matches.filter((match) => match[0].includes("TODO:"));
|
|
258
255
|
expect(todoComments.length).toBe(1);
|
|
259
256
|
});
|
|
260
257
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { afterAll, describe, it } from
|
|
2
|
-
import { RuleTester } from
|
|
3
|
-
import rule from
|
|
1
|
+
import { afterAll, describe, it } from "vitest";
|
|
2
|
+
import { RuleTester } from "@typescript-eslint/rule-tester";
|
|
3
|
+
import rule from "../src/rules/ts-no-buffer-in-typedarray-context.js";
|
|
4
4
|
|
|
5
5
|
// vitest 훅 바인딩
|
|
6
6
|
RuleTester.afterAll = afterAll;
|
|
@@ -12,16 +12,16 @@ const ruleTester = new RuleTester({
|
|
|
12
12
|
languageOptions: {
|
|
13
13
|
parserOptions: {
|
|
14
14
|
projectService: {
|
|
15
|
-
allowDefaultProject: [
|
|
15
|
+
allowDefaultProject: ["*.ts*"],
|
|
16
16
|
},
|
|
17
17
|
},
|
|
18
18
|
},
|
|
19
19
|
});
|
|
20
20
|
|
|
21
|
-
describe(
|
|
22
|
-
describe(
|
|
23
|
-
describe(
|
|
24
|
-
ruleTester.run(
|
|
21
|
+
describe("ts-no-buffer-in-typedarray-context 규칙", () => {
|
|
22
|
+
describe("허용되는 코드들 (valid)", () => {
|
|
23
|
+
describe("Buffer를 new TypedArray(buffer)로 감싸서 사용하는 경우", () => {
|
|
24
|
+
ruleTester.run("ts-no-buffer-in-typedarray-context", rule, {
|
|
25
25
|
valid: [
|
|
26
26
|
{
|
|
27
27
|
code: `
|
|
@@ -34,8 +34,8 @@ describe('ts-no-buffer-in-typedarray-context 규칙', () => {
|
|
|
34
34
|
});
|
|
35
35
|
});
|
|
36
36
|
|
|
37
|
-
describe(
|
|
38
|
-
ruleTester.run(
|
|
37
|
+
describe("TypedArray를 반환할 때 Buffer를 변환해서 사용하는 경우", () => {
|
|
38
|
+
ruleTester.run("ts-no-buffer-in-typedarray-context", rule, {
|
|
39
39
|
valid: [
|
|
40
40
|
{
|
|
41
41
|
code: `
|
|
@@ -50,8 +50,8 @@ describe('ts-no-buffer-in-typedarray-context 규칙', () => {
|
|
|
50
50
|
});
|
|
51
51
|
});
|
|
52
52
|
|
|
53
|
-
describe(
|
|
54
|
-
ruleTester.run(
|
|
53
|
+
describe("TypedArray를 받는 함수에 Buffer가 아닌 TypedArray 인스턴스를 넘기는 경우", () => {
|
|
54
|
+
ruleTester.run("ts-no-buffer-in-typedarray-context", rule, {
|
|
55
55
|
valid: [
|
|
56
56
|
{
|
|
57
57
|
code: `
|
|
@@ -66,9 +66,9 @@ describe('ts-no-buffer-in-typedarray-context 규칙', () => {
|
|
|
66
66
|
});
|
|
67
67
|
});
|
|
68
68
|
|
|
69
|
-
describe(
|
|
70
|
-
describe(
|
|
71
|
-
ruleTester.run(
|
|
69
|
+
describe("오류가 발생해야 하는 코드들 (invalid)", () => {
|
|
70
|
+
describe("Buffer를 TypedArray 타입 변수에 직접 할당하는 경우", () => {
|
|
71
|
+
ruleTester.run("ts-no-buffer-in-typedarray-context", rule, {
|
|
72
72
|
valid: [],
|
|
73
73
|
invalid: [
|
|
74
74
|
{
|
|
@@ -78,8 +78,8 @@ describe('ts-no-buffer-in-typedarray-context 규칙', () => {
|
|
|
78
78
|
`,
|
|
79
79
|
errors: [
|
|
80
80
|
{
|
|
81
|
-
messageId:
|
|
82
|
-
data: { expected:
|
|
81
|
+
messageId: "directBuffer",
|
|
82
|
+
data: { expected: "Uint8Array" },
|
|
83
83
|
},
|
|
84
84
|
],
|
|
85
85
|
},
|
|
@@ -87,8 +87,8 @@ describe('ts-no-buffer-in-typedarray-context 규칙', () => {
|
|
|
87
87
|
});
|
|
88
88
|
});
|
|
89
89
|
|
|
90
|
-
describe(
|
|
91
|
-
ruleTester.run(
|
|
90
|
+
describe("Buffer를 TypedArray를 기대하는 함수 인자에 직접 전달하는 경우", () => {
|
|
91
|
+
ruleTester.run("ts-no-buffer-in-typedarray-context", rule, {
|
|
92
92
|
valid: [],
|
|
93
93
|
invalid: [
|
|
94
94
|
{
|
|
@@ -99,8 +99,8 @@ describe('ts-no-buffer-in-typedarray-context 규칙', () => {
|
|
|
99
99
|
`,
|
|
100
100
|
errors: [
|
|
101
101
|
{
|
|
102
|
-
messageId:
|
|
103
|
-
data: { expected:
|
|
102
|
+
messageId: "directBuffer",
|
|
103
|
+
data: { expected: "Float32Array" },
|
|
104
104
|
},
|
|
105
105
|
],
|
|
106
106
|
},
|
|
@@ -108,8 +108,8 @@ describe('ts-no-buffer-in-typedarray-context 규칙', () => {
|
|
|
108
108
|
});
|
|
109
109
|
});
|
|
110
110
|
|
|
111
|
-
describe(
|
|
112
|
-
ruleTester.run(
|
|
111
|
+
describe("Buffer를 TypedArray를 반환해야 하는 함수에서 직접 반환하는 경우", () => {
|
|
112
|
+
ruleTester.run("ts-no-buffer-in-typedarray-context", rule, {
|
|
113
113
|
valid: [],
|
|
114
114
|
invalid: [
|
|
115
115
|
{
|
|
@@ -121,8 +121,8 @@ describe('ts-no-buffer-in-typedarray-context 규칙', () => {
|
|
|
121
121
|
`,
|
|
122
122
|
errors: [
|
|
123
123
|
{
|
|
124
|
-
messageId:
|
|
125
|
-
data: { expected:
|
|
124
|
+
messageId: "directBuffer",
|
|
125
|
+
data: { expected: "Int16Array" },
|
|
126
126
|
},
|
|
127
127
|
],
|
|
128
128
|
},
|
|
@@ -130,8 +130,8 @@ describe('ts-no-buffer-in-typedarray-context 규칙', () => {
|
|
|
130
130
|
});
|
|
131
131
|
});
|
|
132
132
|
|
|
133
|
-
describe(
|
|
134
|
-
ruleTester.run(
|
|
133
|
+
describe("TypedArray 배열에 Buffer를 직접 넣는 경우", () => {
|
|
134
|
+
ruleTester.run("ts-no-buffer-in-typedarray-context", rule, {
|
|
135
135
|
valid: [],
|
|
136
136
|
invalid: [
|
|
137
137
|
{
|
|
@@ -141,8 +141,8 @@ describe('ts-no-buffer-in-typedarray-context 규칙', () => {
|
|
|
141
141
|
`,
|
|
142
142
|
errors: [
|
|
143
143
|
{
|
|
144
|
-
messageId:
|
|
145
|
-
data: { expected:
|
|
144
|
+
messageId: "directBuffer",
|
|
145
|
+
data: { expected: "Uint8Array" },
|
|
146
146
|
},
|
|
147
147
|
],
|
|
148
148
|
},
|
|
@@ -150,8 +150,8 @@ describe('ts-no-buffer-in-typedarray-context 규칙', () => {
|
|
|
150
150
|
});
|
|
151
151
|
});
|
|
152
152
|
|
|
153
|
-
describe(
|
|
154
|
-
ruleTester.run(
|
|
153
|
+
describe("객체 속성에 TypedArray를 기대하는데 Buffer를 넣는 경우", () => {
|
|
154
|
+
ruleTester.run("ts-no-buffer-in-typedarray-context", rule, {
|
|
155
155
|
valid: [],
|
|
156
156
|
invalid: [
|
|
157
157
|
{
|
|
@@ -161,8 +161,8 @@ describe('ts-no-buffer-in-typedarray-context 규칙', () => {
|
|
|
161
161
|
`,
|
|
162
162
|
errors: [
|
|
163
163
|
{
|
|
164
|
-
messageId:
|
|
165
|
-
data: { expected:
|
|
164
|
+
messageId: "directBuffer",
|
|
165
|
+
data: { expected: "Int32Array" },
|
|
166
166
|
},
|
|
167
167
|
],
|
|
168
168
|
},
|
|
@@ -170,8 +170,8 @@ describe('ts-no-buffer-in-typedarray-context 규칙', () => {
|
|
|
170
170
|
});
|
|
171
171
|
});
|
|
172
172
|
|
|
173
|
-
describe(
|
|
174
|
-
ruleTester.run(
|
|
173
|
+
describe("조건부 표현식에서 Buffer가 TypedArray로 기대되는 경우", () => {
|
|
174
|
+
ruleTester.run("ts-no-buffer-in-typedarray-context", rule, {
|
|
175
175
|
valid: [],
|
|
176
176
|
invalid: [
|
|
177
177
|
{
|
|
@@ -181,8 +181,8 @@ describe('ts-no-buffer-in-typedarray-context 규칙', () => {
|
|
|
181
181
|
`,
|
|
182
182
|
errors: [
|
|
183
183
|
{
|
|
184
|
-
messageId:
|
|
185
|
-
data: { expected:
|
|
184
|
+
messageId: "directBuffer",
|
|
185
|
+
data: { expected: "Uint8Array" },
|
|
186
186
|
},
|
|
187
187
|
],
|
|
188
188
|
},
|
|
@@ -190,8 +190,8 @@ describe('ts-no-buffer-in-typedarray-context 규칙', () => {
|
|
|
190
190
|
});
|
|
191
191
|
});
|
|
192
192
|
|
|
193
|
-
describe(
|
|
194
|
-
ruleTester.run(
|
|
193
|
+
describe("Buffer 사용이 허용되어야 하는 Buffer.정적메서드 호출", () => {
|
|
194
|
+
ruleTester.run("ts-no-buffer-in-typedarray-context", rule, {
|
|
195
195
|
valid: [
|
|
196
196
|
{
|
|
197
197
|
code: `
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { afterAll, describe, it } from
|
|
2
|
-
import { RuleTester } from
|
|
3
|
-
import rule from
|
|
1
|
+
import { afterAll, describe, it } from "vitest";
|
|
2
|
+
import { RuleTester } from "@typescript-eslint/rule-tester";
|
|
3
|
+
import rule from "../src/rules/ts-no-exported-types.js";
|
|
4
4
|
|
|
5
5
|
RuleTester.afterAll = afterAll;
|
|
6
6
|
RuleTester.it = it;
|
|
@@ -11,31 +11,31 @@ const ruleTester = new RuleTester({
|
|
|
11
11
|
languageOptions: {
|
|
12
12
|
parserOptions: {
|
|
13
13
|
projectService: {
|
|
14
|
-
allowDefaultProject: [
|
|
14
|
+
allowDefaultProject: ["*.ts*"],
|
|
15
15
|
},
|
|
16
16
|
},
|
|
17
17
|
},
|
|
18
18
|
});
|
|
19
19
|
|
|
20
|
-
describe(
|
|
21
|
-
describe(
|
|
22
|
-
describe(
|
|
23
|
-
ruleTester.run(
|
|
20
|
+
describe("ts-no-exported-types 규칙", () => {
|
|
21
|
+
describe("허용되는 코드들 (valid)", () => {
|
|
22
|
+
describe("제한된 타입을 내부 함수에서만 사용하는 경우", () => {
|
|
23
|
+
ruleTester.run("ts-no-exported-types", rule, {
|
|
24
24
|
valid: [
|
|
25
25
|
{
|
|
26
26
|
code: `
|
|
27
27
|
type Internal = string;
|
|
28
28
|
function internalFunc(x: Internal) {}
|
|
29
29
|
`,
|
|
30
|
-
options: [{ types: [{ ban:
|
|
30
|
+
options: [{ types: [{ ban: "Foo" }] }],
|
|
31
31
|
},
|
|
32
32
|
],
|
|
33
33
|
invalid: [],
|
|
34
34
|
});
|
|
35
35
|
});
|
|
36
36
|
|
|
37
|
-
describe(
|
|
38
|
-
ruleTester.run(
|
|
37
|
+
describe("export 함수가 안전한 타입만 사용하는 경우", () => {
|
|
38
|
+
ruleTester.run("ts-no-exported-types", rule, {
|
|
39
39
|
valid: [
|
|
40
40
|
{
|
|
41
41
|
code: `
|
|
@@ -43,15 +43,15 @@ describe('ts-no-exported-types 규칙', () => {
|
|
|
43
43
|
return 1;
|
|
44
44
|
}
|
|
45
45
|
`,
|
|
46
|
-
options: [{ types: [{ ban:
|
|
46
|
+
options: [{ types: [{ ban: "Foo" }] }],
|
|
47
47
|
},
|
|
48
48
|
],
|
|
49
49
|
invalid: [],
|
|
50
50
|
});
|
|
51
51
|
});
|
|
52
52
|
|
|
53
|
-
describe(
|
|
54
|
-
ruleTester.run(
|
|
53
|
+
describe("제한된 타입을 private 속성으로만 사용하는 경우", () => {
|
|
54
|
+
ruleTester.run("ts-no-exported-types", rule, {
|
|
55
55
|
valid: [
|
|
56
56
|
{
|
|
57
57
|
code: `
|
|
@@ -59,7 +59,7 @@ describe('ts-no-exported-types 규칙', () => {
|
|
|
59
59
|
private prop: Foo;
|
|
60
60
|
}
|
|
61
61
|
`,
|
|
62
|
-
options: [{ types: [{ ban:
|
|
62
|
+
options: [{ types: [{ ban: "Foo" }] }],
|
|
63
63
|
},
|
|
64
64
|
],
|
|
65
65
|
invalid: [],
|
|
@@ -67,9 +67,9 @@ describe('ts-no-exported-types 규칙', () => {
|
|
|
67
67
|
});
|
|
68
68
|
});
|
|
69
69
|
|
|
70
|
-
describe(
|
|
71
|
-
describe(
|
|
72
|
-
ruleTester.run(
|
|
70
|
+
describe("오류가 발생해야 하는 코드들 (invalid)", () => {
|
|
71
|
+
describe("제한된 타입을 export 함수의 파라미터로 사용하는 경우", () => {
|
|
72
|
+
ruleTester.run("ts-no-exported-types", rule, {
|
|
73
73
|
valid: [],
|
|
74
74
|
invalid: [
|
|
75
75
|
{
|
|
@@ -78,11 +78,11 @@ describe('ts-no-exported-types 규칙', () => {
|
|
|
78
78
|
return 1;
|
|
79
79
|
}
|
|
80
80
|
`,
|
|
81
|
-
options: [{ types: [{ ban:
|
|
81
|
+
options: [{ types: [{ ban: "Foo" }] }],
|
|
82
82
|
errors: [
|
|
83
83
|
{
|
|
84
|
-
messageId:
|
|
85
|
-
data: { typeName:
|
|
84
|
+
messageId: "noExportedTypes",
|
|
85
|
+
data: { typeName: "Foo", safeSuggestion: "" },
|
|
86
86
|
},
|
|
87
87
|
],
|
|
88
88
|
},
|
|
@@ -90,8 +90,8 @@ describe('ts-no-exported-types 규칙', () => {
|
|
|
90
90
|
});
|
|
91
91
|
});
|
|
92
92
|
|
|
93
|
-
describe(
|
|
94
|
-
ruleTester.run(
|
|
93
|
+
describe("제한된 타입을 반환값으로 사용하는 export 함수", () => {
|
|
94
|
+
ruleTester.run("ts-no-exported-types", rule, {
|
|
95
95
|
valid: [],
|
|
96
96
|
invalid: [
|
|
97
97
|
{
|
|
@@ -100,11 +100,11 @@ describe('ts-no-exported-types 규칙', () => {
|
|
|
100
100
|
return {} as Foo;
|
|
101
101
|
}
|
|
102
102
|
`,
|
|
103
|
-
options: [{ types: [{ ban:
|
|
103
|
+
options: [{ types: [{ ban: "Foo" }] }],
|
|
104
104
|
errors: [
|
|
105
105
|
{
|
|
106
|
-
messageId:
|
|
107
|
-
data: { typeName:
|
|
106
|
+
messageId: "noExportedTypes",
|
|
107
|
+
data: { typeName: "Foo", safeSuggestion: "" },
|
|
108
108
|
},
|
|
109
109
|
],
|
|
110
110
|
},
|
|
@@ -112,8 +112,8 @@ describe('ts-no-exported-types 규칙', () => {
|
|
|
112
112
|
});
|
|
113
113
|
});
|
|
114
114
|
|
|
115
|
-
describe(
|
|
116
|
-
ruleTester.run(
|
|
115
|
+
describe("제한된 타입을 public 속성으로 사용하는 export 클래스", () => {
|
|
116
|
+
ruleTester.run("ts-no-exported-types", rule, {
|
|
117
117
|
valid: [],
|
|
118
118
|
invalid: [
|
|
119
119
|
{
|
|
@@ -122,11 +122,11 @@ describe('ts-no-exported-types 규칙', () => {
|
|
|
122
122
|
public prop: Foo;
|
|
123
123
|
}
|
|
124
124
|
`,
|
|
125
|
-
options: [{ types: [{ ban:
|
|
125
|
+
options: [{ types: [{ ban: "Foo" }] }],
|
|
126
126
|
errors: [
|
|
127
127
|
{
|
|
128
|
-
messageId:
|
|
129
|
-
data: { typeName:
|
|
128
|
+
messageId: "noExportedTypes",
|
|
129
|
+
data: { typeName: "Foo", safeSuggestion: "" },
|
|
130
130
|
},
|
|
131
131
|
],
|
|
132
132
|
},
|
|
@@ -134,8 +134,8 @@ describe('ts-no-exported-types 규칙', () => {
|
|
|
134
134
|
});
|
|
135
135
|
});
|
|
136
136
|
|
|
137
|
-
describe(
|
|
138
|
-
ruleTester.run(
|
|
137
|
+
describe("제한된 타입을 public 메서드의 파라미터로 사용하는 경우", () => {
|
|
138
|
+
ruleTester.run("ts-no-exported-types", rule, {
|
|
139
139
|
valid: [],
|
|
140
140
|
invalid: [
|
|
141
141
|
{
|
|
@@ -144,11 +144,11 @@ describe('ts-no-exported-types 규칙', () => {
|
|
|
144
144
|
method(x: Foo): void {}
|
|
145
145
|
}
|
|
146
146
|
`,
|
|
147
|
-
options: [{ types: [{ ban:
|
|
147
|
+
options: [{ types: [{ ban: "Foo" }] }],
|
|
148
148
|
errors: [
|
|
149
149
|
{
|
|
150
|
-
messageId:
|
|
151
|
-
data: { typeName:
|
|
150
|
+
messageId: "noExportedTypes",
|
|
151
|
+
data: { typeName: "Foo", safeSuggestion: "" },
|
|
152
152
|
},
|
|
153
153
|
],
|
|
154
154
|
},
|
|
@@ -156,19 +156,19 @@ describe('ts-no-exported-types 규칙', () => {
|
|
|
156
156
|
});
|
|
157
157
|
});
|
|
158
158
|
|
|
159
|
-
describe(
|
|
160
|
-
ruleTester.run(
|
|
159
|
+
describe("제한된 타입을 사용하는 export const 선언", () => {
|
|
160
|
+
ruleTester.run("ts-no-exported-types", rule, {
|
|
161
161
|
valid: [],
|
|
162
162
|
invalid: [
|
|
163
163
|
{
|
|
164
164
|
code: `
|
|
165
165
|
export const myValue: Foo = {} as Foo;
|
|
166
166
|
`,
|
|
167
|
-
options: [{ types: [{ ban:
|
|
167
|
+
options: [{ types: [{ ban: "Foo" }] }],
|
|
168
168
|
errors: [
|
|
169
169
|
{
|
|
170
|
-
messageId:
|
|
171
|
-
data: { typeName:
|
|
170
|
+
messageId: "noExportedTypes",
|
|
171
|
+
data: { typeName: "Foo", safeSuggestion: "" },
|
|
172
172
|
},
|
|
173
173
|
],
|
|
174
174
|
},
|
|
@@ -176,8 +176,8 @@ describe('ts-no-exported-types 규칙', () => {
|
|
|
176
176
|
});
|
|
177
177
|
});
|
|
178
178
|
|
|
179
|
-
describe(
|
|
180
|
-
ruleTester.run(
|
|
179
|
+
describe("제한된 타입을 생성자의 파라미터로 사용하는 경우", () => {
|
|
180
|
+
ruleTester.run("ts-no-exported-types", rule, {
|
|
181
181
|
valid: [],
|
|
182
182
|
invalid: [
|
|
183
183
|
{
|
|
@@ -186,30 +186,30 @@ describe('ts-no-exported-types 규칙', () => {
|
|
|
186
186
|
constructor(arg?: Blob | Uint8Array) {}
|
|
187
187
|
}
|
|
188
188
|
`,
|
|
189
|
-
options: [{ types: [{ ban:
|
|
190
|
-
errors: [{ messageId:
|
|
189
|
+
options: [{ types: [{ ban: "Uint8Array" }] }],
|
|
190
|
+
errors: [{ messageId: "noExportedTypes" }],
|
|
191
191
|
},
|
|
192
192
|
],
|
|
193
193
|
});
|
|
194
194
|
});
|
|
195
195
|
|
|
196
|
-
describe(
|
|
197
|
-
ruleTester.run(
|
|
196
|
+
describe("유니언 타입 중 하나가 제한된 타입이면 오류 발생해야 함 (파라미터)", () => {
|
|
197
|
+
ruleTester.run("ts-no-exported-types", rule, {
|
|
198
198
|
valid: [],
|
|
199
199
|
invalid: [
|
|
200
200
|
{
|
|
201
201
|
code: `
|
|
202
202
|
export function readData(x: Uint8Array | string): void {}
|
|
203
203
|
`,
|
|
204
|
-
options: [{ types: [{ ban:
|
|
205
|
-
errors: [{ messageId:
|
|
204
|
+
options: [{ types: [{ ban: "Uint8Array" }] }],
|
|
205
|
+
errors: [{ messageId: "noExportedTypes" }],
|
|
206
206
|
},
|
|
207
207
|
],
|
|
208
208
|
});
|
|
209
209
|
});
|
|
210
210
|
|
|
211
|
-
describe(
|
|
212
|
-
ruleTester.run(
|
|
211
|
+
describe("유니언 타입 중 하나가 제한된 타입이면 오류 발생해야 함 (반환값)", () => {
|
|
212
|
+
ruleTester.run("ts-no-exported-types", rule, {
|
|
213
213
|
valid: [],
|
|
214
214
|
invalid: [
|
|
215
215
|
{
|
|
@@ -218,15 +218,15 @@ describe('ts-no-exported-types 규칙', () => {
|
|
|
218
218
|
return new Uint8Array();
|
|
219
219
|
}
|
|
220
220
|
`,
|
|
221
|
-
options: [{ types: [{ ban:
|
|
222
|
-
errors: [{ messageId:
|
|
221
|
+
options: [{ types: [{ ban: "Uint8Array" }] }],
|
|
222
|
+
errors: [{ messageId: "noExportedTypes" }],
|
|
223
223
|
},
|
|
224
224
|
],
|
|
225
225
|
});
|
|
226
226
|
});
|
|
227
227
|
|
|
228
|
-
describe(
|
|
229
|
-
ruleTester.run(
|
|
228
|
+
describe("유니언 타입 속성에서도 제한된 타입이면 오류 발생해야 함", () => {
|
|
229
|
+
ruleTester.run("ts-no-exported-types", rule, {
|
|
230
230
|
valid: [],
|
|
231
231
|
invalid: [
|
|
232
232
|
{
|
|
@@ -235,11 +235,11 @@ describe('ts-no-exported-types 규칙', () => {
|
|
|
235
235
|
public buffer: string | Uint8Array;
|
|
236
236
|
}
|
|
237
237
|
`,
|
|
238
|
-
options: [{ types: [{ ban:
|
|
238
|
+
options: [{ types: [{ ban: "Uint8Array" }] }],
|
|
239
239
|
errors: [
|
|
240
240
|
{
|
|
241
|
-
messageId:
|
|
242
|
-
data: { typeName:
|
|
241
|
+
messageId: "noExportedTypes",
|
|
242
|
+
data: { typeName: "Uint8Array", safeSuggestion: "" },
|
|
243
243
|
},
|
|
244
244
|
],
|
|
245
245
|
},
|
|
@@ -247,20 +247,20 @@ describe('ts-no-exported-types 규칙', () => {
|
|
|
247
247
|
});
|
|
248
248
|
});
|
|
249
249
|
|
|
250
|
-
describe(
|
|
251
|
-
ruleTester.run(
|
|
250
|
+
describe("export const 선언에서도 유니언 타입 중 제한된 타입이 있으면 오류", () => {
|
|
251
|
+
ruleTester.run("ts-no-exported-types", rule, {
|
|
252
252
|
valid: [],
|
|
253
253
|
invalid: [
|
|
254
254
|
{
|
|
255
255
|
code: `
|
|
256
256
|
export const data: Uint8Array | number = new Uint8Array();
|
|
257
257
|
`,
|
|
258
|
-
options: [{ types: [{ ban:
|
|
258
|
+
options: [{ types: [{ ban: "Uint8Array", safe: "Buffer" }] }],
|
|
259
259
|
errors: [
|
|
260
260
|
{
|
|
261
|
-
messageId:
|
|
261
|
+
messageId: "noExportedTypes",
|
|
262
262
|
data: {
|
|
263
|
-
typeName:
|
|
263
|
+
typeName: "Uint8Array",
|
|
264
264
|
safeSuggestion: ' 더 안전한 대체 타입 "Buffer"을(를) 사용하세요.',
|
|
265
265
|
},
|
|
266
266
|
},
|
|
@@ -270,19 +270,19 @@ describe('ts-no-exported-types 규칙', () => {
|
|
|
270
270
|
});
|
|
271
271
|
});
|
|
272
272
|
|
|
273
|
-
describe(
|
|
274
|
-
ruleTester.run(
|
|
273
|
+
describe("Generic 안쪽에도 없어야함", () => {
|
|
274
|
+
ruleTester.run("ts-no-exported-types", rule, {
|
|
275
275
|
valid: [],
|
|
276
276
|
invalid: [
|
|
277
277
|
{
|
|
278
278
|
code: `
|
|
279
279
|
export const myValue: Foo<Bar> = {};
|
|
280
280
|
`,
|
|
281
|
-
options: [{ types: [{ ban:
|
|
281
|
+
options: [{ types: [{ ban: "Bar" }] }],
|
|
282
282
|
errors: [
|
|
283
283
|
{
|
|
284
|
-
messageId:
|
|
285
|
-
data: { typeName:
|
|
284
|
+
messageId: "noExportedTypes",
|
|
285
|
+
data: { typeName: "Bar", safeSuggestion: "" },
|
|
286
286
|
},
|
|
287
287
|
],
|
|
288
288
|
},
|
|
@@ -290,14 +290,14 @@ describe('ts-no-exported-types 규칙', () => {
|
|
|
290
290
|
});
|
|
291
291
|
});
|
|
292
292
|
|
|
293
|
-
describe(
|
|
294
|
-
ruleTester.run(
|
|
293
|
+
describe("Generic 안쪽에 있어도 ignoreInGeneric 이면 허용됨", () => {
|
|
294
|
+
ruleTester.run("ts-no-exported-types", rule, {
|
|
295
295
|
valid: [
|
|
296
296
|
{
|
|
297
297
|
code: `
|
|
298
298
|
export const myValue: Foo<Bar> = {};
|
|
299
299
|
`,
|
|
300
|
-
options: [{ types: [{ ban:
|
|
300
|
+
options: [{ types: [{ ban: "Bar", ignoreInGeneric: true }] }],
|
|
301
301
|
},
|
|
302
302
|
],
|
|
303
303
|
invalid: [],
|