@simplysm/eslint-plugin 7.0.223 → 7.0.233
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/.eslintrc.cjs +1 -1
- package/package.json +7 -8
- package/src/configs/angular-template.cjs +10 -10
- package/src/configs/angular.cjs +5 -5
- package/src/configs/base.cjs +25 -24
- package/src/configs/typescript.cjs +70 -70
- package/src/index.cjs +13 -13
- package/src/rules/ng-template-no-todo-comments.cjs +45 -45
- package/src/rules/ts-no-self-entry-import.cjs +63 -63
- package/src/rules/ts-no-throw-not-implement-error.cjs +72 -72
package/.eslintrc.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
module.exports = {};
|
|
1
|
+
module.exports = {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@simplysm/eslint-plugin",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.0.233",
|
|
4
4
|
"description": "심플리즘 패키지 - ESLINT 플러그인",
|
|
5
5
|
"author": "김석래",
|
|
6
6
|
"repository": {
|
|
@@ -16,18 +16,17 @@
|
|
|
16
16
|
"node": "^16"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"eslint": "^8.7.0",
|
|
20
|
-
"@typescript-eslint/parser": "^5.10.1",
|
|
21
|
-
"@typescript-eslint/eslint-plugin": "^5.10.1",
|
|
22
19
|
"@angular-eslint/eslint-plugin": "^13.0.1",
|
|
23
20
|
"@angular-eslint/eslint-plugin-template": "^13.0.1",
|
|
24
21
|
"@angular-eslint/template-parser": "^13.0.1",
|
|
22
|
+
"@typescript-eslint/eslint-plugin": "^5.10.1",
|
|
25
23
|
"@typescript-eslint/experimental-utils": "^5.10.2",
|
|
24
|
+
"@typescript-eslint/parser": "^5.10.1",
|
|
25
|
+
"eslint": "^8.7.0",
|
|
26
|
+
"eslint-import-resolver-typescript": "^2.5.0",
|
|
26
27
|
"eslint-module-utils": "^2.7.3",
|
|
27
28
|
"eslint-plugin-deprecation": "^1.3.2",
|
|
28
29
|
"eslint-plugin-import": "^2.25.4",
|
|
29
|
-
"
|
|
30
|
-
}
|
|
31
|
-
"devDependencies": {},
|
|
32
|
-
"peerDependencies": {}
|
|
30
|
+
"typescript": "~4.5.5"
|
|
31
|
+
}
|
|
33
32
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
parser: "@angular-eslint/template-parser",
|
|
3
|
-
plugins: [
|
|
4
|
-
"@angular-eslint/template",
|
|
5
|
-
"@simplysm"
|
|
6
|
-
],
|
|
7
|
-
rules: {
|
|
8
|
-
"@simplysm/ng-template-no-todo-comments": "warn"
|
|
9
|
-
}
|
|
10
|
-
};
|
|
1
|
+
module.exports = {
|
|
2
|
+
parser: "@angular-eslint/template-parser",
|
|
3
|
+
plugins: [
|
|
4
|
+
"@angular-eslint/template",
|
|
5
|
+
"@simplysm"
|
|
6
|
+
],
|
|
7
|
+
rules: {
|
|
8
|
+
"@simplysm/ng-template-no-todo-comments": "warn"
|
|
9
|
+
}
|
|
10
|
+
};
|
package/src/configs/angular.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
plugins: ["@angular-eslint"],
|
|
3
|
-
processor: "@angular-eslint/template/extract-inline-html",
|
|
4
|
-
rules: {}
|
|
5
|
-
};
|
|
1
|
+
module.exports = {
|
|
2
|
+
plugins: ["@angular-eslint"],
|
|
3
|
+
processor: "@angular-eslint/template/extract-inline-html",
|
|
4
|
+
rules: {}
|
|
5
|
+
};
|
package/src/configs/base.cjs
CHANGED
|
@@ -1,24 +1,25 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
env: {
|
|
3
|
-
node: true,
|
|
4
|
-
es2020: true
|
|
5
|
-
},
|
|
6
|
-
plugins: ["import"],
|
|
7
|
-
rules: {
|
|
8
|
-
// import
|
|
9
|
-
"import/no-extraneous-dependencies": ["error"],
|
|
10
|
-
|
|
11
|
-
"no-console": ["warn"],
|
|
12
|
-
"no-warning-comments": ["warn"],
|
|
13
|
-
|
|
14
|
-
"require-await": ["error"],
|
|
15
|
-
"quotes": ["error", "double", { avoidEscape: true, allowTemplateLiterals: true }],
|
|
16
|
-
"semi": ["error"],
|
|
17
|
-
"no-shadow": ["error"],
|
|
18
|
-
"no-duplicate-imports": ["error"],
|
|
19
|
-
"no-unused-expressions": ["error"],
|
|
20
|
-
"no-unused-vars": ["error"],
|
|
21
|
-
"no-undef": ["error"],
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
1
|
+
module.exports = {
|
|
2
|
+
env: {
|
|
3
|
+
node: true,
|
|
4
|
+
es2020: true
|
|
5
|
+
},
|
|
6
|
+
plugins: ["import"],
|
|
7
|
+
rules: {
|
|
8
|
+
// import
|
|
9
|
+
"import/no-extraneous-dependencies": ["error"],
|
|
10
|
+
|
|
11
|
+
"no-console": ["warn"],
|
|
12
|
+
"no-warning-comments": ["warn"],
|
|
13
|
+
|
|
14
|
+
"require-await": ["error"],
|
|
15
|
+
"quotes": ["error", "double", { avoidEscape: true, allowTemplateLiterals: true }],
|
|
16
|
+
"semi": ["error"],
|
|
17
|
+
"no-shadow": ["error"],
|
|
18
|
+
"no-duplicate-imports": ["error"],
|
|
19
|
+
"no-unused-expressions": ["error"],
|
|
20
|
+
"no-unused-vars": ["error"],
|
|
21
|
+
"no-undef": ["error"],
|
|
22
|
+
"linebreak-style": ["error", "unix"]
|
|
23
|
+
// "comma-dangle": ["error"]
|
|
24
|
+
}
|
|
25
|
+
};
|
|
@@ -1,70 +1,70 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
parser: "@typescript-eslint/parser",
|
|
3
|
-
plugins: [
|
|
4
|
-
"@typescript-eslint",
|
|
5
|
-
"deprecation",
|
|
6
|
-
"import",
|
|
7
|
-
"@simplysm"
|
|
8
|
-
],
|
|
9
|
-
// extends: [
|
|
10
|
-
// "eslint:all",
|
|
11
|
-
// "plugin:@typescript-eslint/all",
|
|
12
|
-
// "plugin:import/recommended",
|
|
13
|
-
// "plugin:import/typescript"
|
|
14
|
-
// ],
|
|
15
|
-
settings: {
|
|
16
|
-
"import/parsers": {
|
|
17
|
-
"@typescript-eslint/parser": [".ts", ".tsx"]
|
|
18
|
-
}
|
|
19
|
-
},
|
|
20
|
-
rules: {
|
|
21
|
-
// 기본
|
|
22
|
-
"no-console": ["warn"],
|
|
23
|
-
"no-warning-comments": ["warn"],
|
|
24
|
-
|
|
25
|
-
// Deprecation
|
|
26
|
-
"deprecation/deprecation": ["warn"],
|
|
27
|
-
|
|
28
|
-
// import
|
|
29
|
-
"import/no-extraneous-dependencies": ["error"],
|
|
30
|
-
|
|
31
|
-
// 심플리즘
|
|
32
|
-
"@simplysm/ts-no-throw-not-implement-error": ["warn"],
|
|
33
|
-
"@simplysm/ts-no-self-entry-import": ["error"],
|
|
34
|
-
|
|
35
|
-
// 타입스크립트
|
|
36
|
-
"@typescript-eslint/explicit-member-accessibility": ["error"],
|
|
37
|
-
"@typescript-eslint/require-await": ["error"],
|
|
38
|
-
"@typescript-eslint/await-thenable": ["error"],
|
|
39
|
-
"@typescript-eslint/quotes": ["error", "double", { avoidEscape: true, allowTemplateLiterals: true }],
|
|
40
|
-
"@typescript-eslint/semi": ["error"],
|
|
41
|
-
"@typescript-eslint/no-shadow": ["error"],
|
|
42
|
-
"@typescript-eslint/member-delimiter-style": ["error"],
|
|
43
|
-
"@typescript-eslint/no-unnecessary-condition": ["error", { allowConstantLoopConditions: true }],
|
|
44
|
-
"@typescript-eslint/no-unnecessary-type-assertion": ["error"],
|
|
45
|
-
"@typescript-eslint/non-nullable-type-assertion-style": ["error"],
|
|
46
|
-
"@typescript-eslint/prefer-reduce-type-parameter": ["error"],
|
|
47
|
-
"@typescript-eslint/prefer-return-this-type": ["error"],
|
|
48
|
-
"@typescript-eslint/no-duplicate-imports": ["error"],
|
|
49
|
-
"@typescript-eslint/prefer-readonly": ["error"],
|
|
50
|
-
"@typescript-eslint/typedef": ["error"],
|
|
51
|
-
"@typescript-eslint/explicit-function-return-type": ["error", {
|
|
52
|
-
allowExpressions: true,
|
|
53
|
-
allowTypedFunctionExpressions: true,
|
|
54
|
-
allowHigherOrderFunctions: true,
|
|
55
|
-
allowDirectConstAssertionInArrowFunctions: true,
|
|
56
|
-
allowConciseArrowFunctionExpressionsStartingWithVoid: true
|
|
57
|
-
}],
|
|
58
|
-
"@typescript-eslint/no-unused-expressions": ["error"],
|
|
59
|
-
"@typescript-eslint/no-unused-vars": ["warn", { args: "none" }],
|
|
60
|
-
"@typescript-eslint/strict-boolean-expressions": ["error", {
|
|
61
|
-
allowNullableBoolean: true,
|
|
62
|
-
allowNullableObject: true
|
|
63
|
-
}],
|
|
64
|
-
"@typescript-eslint/explicit-module-boundary-types": ["error", { allowArgumentsExplicitlyTypedAsAny: true }],
|
|
65
|
-
"@typescript-eslint/return-await": ["error", "always"],
|
|
66
|
-
"@typescript-eslint/no-floating-promises": ["error"],
|
|
67
|
-
// "@typescript-eslint/comma-dangle": ["error"]
|
|
68
|
-
"@typescript-eslint/prefer-ts-expect-error": ["error"]
|
|
69
|
-
}
|
|
70
|
-
};
|
|
1
|
+
module.exports = {
|
|
2
|
+
parser: "@typescript-eslint/parser",
|
|
3
|
+
plugins: [
|
|
4
|
+
"@typescript-eslint",
|
|
5
|
+
"deprecation",
|
|
6
|
+
"import",
|
|
7
|
+
"@simplysm"
|
|
8
|
+
],
|
|
9
|
+
// extends: [
|
|
10
|
+
// "eslint:all",
|
|
11
|
+
// "plugin:@typescript-eslint/all",
|
|
12
|
+
// "plugin:import/recommended",
|
|
13
|
+
// "plugin:import/typescript"
|
|
14
|
+
// ],
|
|
15
|
+
settings: {
|
|
16
|
+
"import/parsers": {
|
|
17
|
+
"@typescript-eslint/parser": [".ts", ".tsx"]
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
rules: {
|
|
21
|
+
// 기본
|
|
22
|
+
"no-console": ["warn"],
|
|
23
|
+
"no-warning-comments": ["warn"],
|
|
24
|
+
|
|
25
|
+
// Deprecation
|
|
26
|
+
"deprecation/deprecation": ["warn"],
|
|
27
|
+
|
|
28
|
+
// import
|
|
29
|
+
"import/no-extraneous-dependencies": ["error"],
|
|
30
|
+
|
|
31
|
+
// 심플리즘
|
|
32
|
+
"@simplysm/ts-no-throw-not-implement-error": ["warn"],
|
|
33
|
+
"@simplysm/ts-no-self-entry-import": ["error"],
|
|
34
|
+
|
|
35
|
+
// 타입스크립트
|
|
36
|
+
"@typescript-eslint/explicit-member-accessibility": ["error"],
|
|
37
|
+
"@typescript-eslint/require-await": ["error"],
|
|
38
|
+
"@typescript-eslint/await-thenable": ["error"],
|
|
39
|
+
"@typescript-eslint/quotes": ["error", "double", { avoidEscape: true, allowTemplateLiterals: true }],
|
|
40
|
+
"@typescript-eslint/semi": ["error"],
|
|
41
|
+
"@typescript-eslint/no-shadow": ["error"],
|
|
42
|
+
"@typescript-eslint/member-delimiter-style": ["error"],
|
|
43
|
+
"@typescript-eslint/no-unnecessary-condition": ["error", { allowConstantLoopConditions: true }],
|
|
44
|
+
"@typescript-eslint/no-unnecessary-type-assertion": ["error"],
|
|
45
|
+
"@typescript-eslint/non-nullable-type-assertion-style": ["error"],
|
|
46
|
+
"@typescript-eslint/prefer-reduce-type-parameter": ["error"],
|
|
47
|
+
"@typescript-eslint/prefer-return-this-type": ["error"],
|
|
48
|
+
"@typescript-eslint/no-duplicate-imports": ["error"],
|
|
49
|
+
"@typescript-eslint/prefer-readonly": ["error"],
|
|
50
|
+
"@typescript-eslint/typedef": ["error"],
|
|
51
|
+
"@typescript-eslint/explicit-function-return-type": ["error", {
|
|
52
|
+
allowExpressions: true,
|
|
53
|
+
allowTypedFunctionExpressions: true,
|
|
54
|
+
allowHigherOrderFunctions: true,
|
|
55
|
+
allowDirectConstAssertionInArrowFunctions: true,
|
|
56
|
+
allowConciseArrowFunctionExpressionsStartingWithVoid: true
|
|
57
|
+
}],
|
|
58
|
+
"@typescript-eslint/no-unused-expressions": ["error"],
|
|
59
|
+
"@typescript-eslint/no-unused-vars": ["warn", { args: "none" }],
|
|
60
|
+
"@typescript-eslint/strict-boolean-expressions": ["error", {
|
|
61
|
+
allowNullableBoolean: true,
|
|
62
|
+
allowNullableObject: true
|
|
63
|
+
}],
|
|
64
|
+
"@typescript-eslint/explicit-module-boundary-types": ["error", { allowArgumentsExplicitlyTypedAsAny: true }],
|
|
65
|
+
"@typescript-eslint/return-await": ["error", "always"],
|
|
66
|
+
"@typescript-eslint/no-floating-promises": ["error"],
|
|
67
|
+
// "@typescript-eslint/comma-dangle": ["error"]
|
|
68
|
+
"@typescript-eslint/prefer-ts-expect-error": ["error"]
|
|
69
|
+
}
|
|
70
|
+
};
|
package/src/index.cjs
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
configs: {
|
|
3
|
-
"base": require("./configs/base.cjs"),
|
|
4
|
-
"typescript": require("./configs/typescript.cjs"),
|
|
5
|
-
"angular": require("./configs/angular.cjs"),
|
|
6
|
-
"angular-template": require("./configs/angular-template.cjs")
|
|
7
|
-
},
|
|
8
|
-
rules: {
|
|
9
|
-
"ts-no-self-entry-import": require("./rules/ts-no-self-entry-import.cjs"),
|
|
10
|
-
"ts-no-throw-not-implement-error": require("./rules/ts-no-throw-not-implement-error.cjs"),
|
|
11
|
-
"ng-template-no-todo-comments": require("./rules/ng-template-no-todo-comments.cjs")
|
|
12
|
-
}
|
|
13
|
-
};
|
|
1
|
+
module.exports = {
|
|
2
|
+
configs: {
|
|
3
|
+
"base": require("./configs/base.cjs"),
|
|
4
|
+
"typescript": require("./configs/typescript.cjs"),
|
|
5
|
+
"angular": require("./configs/angular.cjs"),
|
|
6
|
+
"angular-template": require("./configs/angular-template.cjs")
|
|
7
|
+
},
|
|
8
|
+
rules: {
|
|
9
|
+
"ts-no-self-entry-import": require("./rules/ts-no-self-entry-import.cjs"),
|
|
10
|
+
"ts-no-throw-not-implement-error": require("./rules/ts-no-throw-not-implement-error.cjs"),
|
|
11
|
+
"ng-template-no-todo-comments": require("./rules/ng-template-no-todo-comments.cjs")
|
|
12
|
+
}
|
|
13
|
+
};
|
|
@@ -1,45 +1,45 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
meta: {
|
|
3
|
-
type: "suggestion",
|
|
4
|
-
docs: {
|
|
5
|
-
description: "HTML의 'TODO' 주석 경고"
|
|
6
|
-
},
|
|
7
|
-
|
|
8
|
-
schema: []
|
|
9
|
-
},
|
|
10
|
-
|
|
11
|
-
create: (context) => {
|
|
12
|
-
// const parserServices = context.parserServices;
|
|
13
|
-
return {
|
|
14
|
-
Program(node) {
|
|
15
|
-
if (node.value) {
|
|
16
|
-
const comments = node.value.match(/<!--(((?!-->)[\s\S])*)-->/g);
|
|
17
|
-
if (!comments) return;
|
|
18
|
-
|
|
19
|
-
let cursor = 0;
|
|
20
|
-
for (const comment of comments) {
|
|
21
|
-
if (!comment.includes("TODO:")) continue;
|
|
22
|
-
|
|
23
|
-
const index = node.value.slice(cursor).indexOf(comment) + cursor;
|
|
24
|
-
const line = node.value.slice(0, index).split("\n").length;
|
|
25
|
-
const column = index - node.value.slice(0, index).lastIndexOf("\n") - 1;
|
|
26
|
-
|
|
27
|
-
const endIndex = index + comment.length;
|
|
28
|
-
const endLine = node.value.slice(0, endIndex).split("\n").length;
|
|
29
|
-
const endColumn = endIndex - node.value.slice(0, endIndex).lastIndexOf("\n") - 1;
|
|
30
|
-
|
|
31
|
-
cursor += index;
|
|
32
|
-
|
|
33
|
-
context.report({
|
|
34
|
-
loc: {
|
|
35
|
-
start: { line, column },
|
|
36
|
-
end: { line: endLine, column: endColumn }
|
|
37
|
-
},
|
|
38
|
-
message: comment.match(/<!--(((?!-->)[\s\S])*)-->/)[1].trim()
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
};
|
|
1
|
+
module.exports = {
|
|
2
|
+
meta: {
|
|
3
|
+
type: "suggestion",
|
|
4
|
+
docs: {
|
|
5
|
+
description: "HTML의 'TODO' 주석 경고"
|
|
6
|
+
},
|
|
7
|
+
|
|
8
|
+
schema: []
|
|
9
|
+
},
|
|
10
|
+
|
|
11
|
+
create: (context) => {
|
|
12
|
+
// const parserServices = context.parserServices;
|
|
13
|
+
return {
|
|
14
|
+
Program(node) {
|
|
15
|
+
if (node.value) {
|
|
16
|
+
const comments = node.value.match(/<!--(((?!-->)[\s\S])*)-->/g);
|
|
17
|
+
if (!comments) return;
|
|
18
|
+
|
|
19
|
+
let cursor = 0;
|
|
20
|
+
for (const comment of comments) {
|
|
21
|
+
if (!comment.includes("TODO:")) continue;
|
|
22
|
+
|
|
23
|
+
const index = node.value.slice(cursor).indexOf(comment) + cursor;
|
|
24
|
+
const line = node.value.slice(0, index).split("\n").length;
|
|
25
|
+
const column = index - node.value.slice(0, index).lastIndexOf("\n") - 1;
|
|
26
|
+
|
|
27
|
+
const endIndex = index + comment.length;
|
|
28
|
+
const endLine = node.value.slice(0, endIndex).split("\n").length;
|
|
29
|
+
const endColumn = endIndex - node.value.slice(0, endIndex).lastIndexOf("\n") - 1;
|
|
30
|
+
|
|
31
|
+
cursor += index;
|
|
32
|
+
|
|
33
|
+
context.report({
|
|
34
|
+
loc: {
|
|
35
|
+
start: { line, column },
|
|
36
|
+
end: { line: endLine, column: endColumn }
|
|
37
|
+
},
|
|
38
|
+
message: comment.match(/<!--(((?!-->)[\s\S])*)-->/)[1].trim()
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
};
|
|
@@ -1,64 +1,64 @@
|
|
|
1
|
-
const resolve = require("eslint-module-utils/resolve").default;
|
|
2
|
-
const path = require("path");
|
|
3
|
-
|
|
4
|
-
module.exports = {
|
|
5
|
-
meta: {
|
|
6
|
-
type: "problem",
|
|
7
|
-
docs: {
|
|
8
|
-
description: "동일 패키지 내의 index.ts 파일 import 금지"
|
|
9
|
-
},
|
|
10
|
-
|
|
11
|
-
schema: []
|
|
12
|
-
},
|
|
13
|
-
create: (context) => {
|
|
14
|
-
const filePath = context.getFilename();
|
|
15
|
-
const importMap = new Map();
|
|
16
|
-
|
|
17
|
-
function append(requirePath, node) {
|
|
18
|
-
if (filePath !== "<text>" && (requirePath.endsWith(".") || requirePath.endsWith("/"))) {
|
|
19
|
-
const resolvedPath = (resolve(requirePath, context) || requirePath).toLowerCase();
|
|
20
|
-
if (resolvedPath) {
|
|
21
|
-
if (importMap.has(resolvedPath)) {
|
|
22
|
-
importMap.get(resolvedPath).push(node);
|
|
23
|
-
}
|
|
24
|
-
else {
|
|
25
|
-
importMap.set(resolvedPath, [node]);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
return {
|
|
32
|
-
"ImportDeclaration": (node) => {
|
|
33
|
-
append(node.source.value, node);
|
|
34
|
-
},
|
|
35
|
-
"CallExpression": (node) => {
|
|
36
|
-
if (
|
|
37
|
-
node
|
|
38
|
-
&& node.callee
|
|
39
|
-
&& node.callee.type === "Identifier"
|
|
40
|
-
&& node.callee.name === "require"
|
|
41
|
-
&& node.arguments.length === 1
|
|
42
|
-
&& node.arguments[0].type === "Literal"
|
|
43
|
-
&& typeof node.arguments[0].value === "string"
|
|
44
|
-
) {
|
|
45
|
-
append(node.arguments[0].value, node);
|
|
46
|
-
}
|
|
47
|
-
},
|
|
48
|
-
"Program:exit": () => {
|
|
49
|
-
const rootFileNames = context.parserServices.program.getRootFileNames()
|
|
50
|
-
.map((item) => path.normalize(item).toLowerCase());
|
|
51
|
-
for (const rootFileName of rootFileNames) {
|
|
52
|
-
if (importMap.has(rootFileName)) {
|
|
53
|
-
for (const node of importMap.get(rootFileName)) {
|
|
54
|
-
context.report({
|
|
55
|
-
node,
|
|
56
|
-
message: "동일 패키지상의 index.ts 파일을 import 하고 있습니다."
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
}
|
|
1
|
+
const resolve = require("eslint-module-utils/resolve").default;
|
|
2
|
+
const path = require("path");
|
|
3
|
+
|
|
4
|
+
module.exports = {
|
|
5
|
+
meta: {
|
|
6
|
+
type: "problem",
|
|
7
|
+
docs: {
|
|
8
|
+
description: "동일 패키지 내의 index.ts 파일 import 금지"
|
|
9
|
+
},
|
|
10
|
+
|
|
11
|
+
schema: []
|
|
12
|
+
},
|
|
13
|
+
create: (context) => {
|
|
14
|
+
const filePath = context.getFilename();
|
|
15
|
+
const importMap = new Map();
|
|
16
|
+
|
|
17
|
+
function append(requirePath, node) {
|
|
18
|
+
if (filePath !== "<text>" && (requirePath.endsWith(".") || requirePath.endsWith("/"))) {
|
|
19
|
+
const resolvedPath = (resolve(requirePath, context) || requirePath).toLowerCase();
|
|
20
|
+
if (resolvedPath) {
|
|
21
|
+
if (importMap.has(resolvedPath)) {
|
|
22
|
+
importMap.get(resolvedPath).push(node);
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
importMap.set(resolvedPath, [node]);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return {
|
|
32
|
+
"ImportDeclaration": (node) => {
|
|
33
|
+
append(node.source.value, node);
|
|
34
|
+
},
|
|
35
|
+
"CallExpression": (node) => {
|
|
36
|
+
if (
|
|
37
|
+
node
|
|
38
|
+
&& node.callee
|
|
39
|
+
&& node.callee.type === "Identifier"
|
|
40
|
+
&& node.callee.name === "require"
|
|
41
|
+
&& node.arguments.length === 1
|
|
42
|
+
&& node.arguments[0].type === "Literal"
|
|
43
|
+
&& typeof node.arguments[0].value === "string"
|
|
44
|
+
) {
|
|
45
|
+
append(node.arguments[0].value, node);
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
"Program:exit": () => {
|
|
49
|
+
const rootFileNames = context.parserServices.program.getRootFileNames()
|
|
50
|
+
.map((item) => path.normalize(item).toLowerCase());
|
|
51
|
+
for (const rootFileName of rootFileNames) {
|
|
52
|
+
if (importMap.has(rootFileName)) {
|
|
53
|
+
for (const node of importMap.get(rootFileName)) {
|
|
54
|
+
context.report({
|
|
55
|
+
node,
|
|
56
|
+
message: "동일 패키지상의 index.ts 파일을 import 하고 있습니다."
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
64
|
};
|
|
@@ -1,73 +1,73 @@
|
|
|
1
|
-
const { AST_NODE_TYPES } = require("@typescript-eslint/experimental-utils");
|
|
2
|
-
|
|
3
|
-
module.exports = {
|
|
4
|
-
meta: {
|
|
5
|
-
type: "suggestion",
|
|
6
|
-
docs: {
|
|
7
|
-
description: "'NotImplementError' 사용 경고"
|
|
8
|
-
},
|
|
9
|
-
|
|
10
|
-
schema: []
|
|
11
|
-
},
|
|
12
|
-
create: (context) => {
|
|
13
|
-
const parserServices = context.parserServices;
|
|
14
|
-
const program = parserServices.program;
|
|
15
|
-
const checker = program.getTypeChecker();
|
|
16
|
-
|
|
17
|
-
function tryGetThrowArgumentType(node) {
|
|
18
|
-
switch (node.type) {
|
|
19
|
-
case AST_NODE_TYPES.Identifier:
|
|
20
|
-
case AST_NODE_TYPES.CallExpression:
|
|
21
|
-
case AST_NODE_TYPES.NewExpression:
|
|
22
|
-
case AST_NODE_TYPES.MemberExpression: {
|
|
23
|
-
const tsNode = parserServices.esTreeNodeToTSNodeMap.get(node);
|
|
24
|
-
return checker.getTypeAtLocation(tsNode);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
case AST_NODE_TYPES.AssignmentExpression:
|
|
28
|
-
return tryGetThrowArgumentType(node.right);
|
|
29
|
-
|
|
30
|
-
case AST_NODE_TYPES.SequenceExpression:
|
|
31
|
-
return tryGetThrowArgumentType(node.expressions[node.expressions.length - 1]);
|
|
32
|
-
|
|
33
|
-
case AST_NODE_TYPES.LogicalExpression: {
|
|
34
|
-
const left = tryGetThrowArgumentType(node.left);
|
|
35
|
-
return left === undefined ? tryGetThrowArgumentType(node.right) : left;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
case AST_NODE_TYPES.ConditionalExpression: {
|
|
39
|
-
const consequent = tryGetThrowArgumentType(node.consequent);
|
|
40
|
-
return consequent === undefined ? tryGetThrowArgumentType(node.alternate) : consequent;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
default:
|
|
44
|
-
return undefined;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
function checkThrowArgument(node) {
|
|
49
|
-
if (
|
|
50
|
-
node.type === AST_NODE_TYPES.AwaitExpression
|
|
51
|
-
|| node.type === AST_NODE_TYPES.YieldExpression
|
|
52
|
-
) {
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
const type = tryGetThrowArgumentType(node);
|
|
57
|
-
if (type && type.getSymbol() && type.getSymbol().getName() === "NotImplementError") {
|
|
58
|
-
context.report({
|
|
59
|
-
node,
|
|
60
|
-
message: node.arguments.value || "구현되어있지 않습니다" //"'NotImplementError'를 'throw'하고 있습니다."
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
return {
|
|
66
|
-
ThrowStatement(node) {
|
|
67
|
-
if (node.argument) {
|
|
68
|
-
checkThrowArgument(node.argument);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
}
|
|
1
|
+
const { AST_NODE_TYPES } = require("@typescript-eslint/experimental-utils");
|
|
2
|
+
|
|
3
|
+
module.exports = {
|
|
4
|
+
meta: {
|
|
5
|
+
type: "suggestion",
|
|
6
|
+
docs: {
|
|
7
|
+
description: "'NotImplementError' 사용 경고"
|
|
8
|
+
},
|
|
9
|
+
|
|
10
|
+
schema: []
|
|
11
|
+
},
|
|
12
|
+
create: (context) => {
|
|
13
|
+
const parserServices = context.parserServices;
|
|
14
|
+
const program = parserServices.program;
|
|
15
|
+
const checker = program.getTypeChecker();
|
|
16
|
+
|
|
17
|
+
function tryGetThrowArgumentType(node) {
|
|
18
|
+
switch (node.type) {
|
|
19
|
+
case AST_NODE_TYPES.Identifier:
|
|
20
|
+
case AST_NODE_TYPES.CallExpression:
|
|
21
|
+
case AST_NODE_TYPES.NewExpression:
|
|
22
|
+
case AST_NODE_TYPES.MemberExpression: {
|
|
23
|
+
const tsNode = parserServices.esTreeNodeToTSNodeMap.get(node);
|
|
24
|
+
return checker.getTypeAtLocation(tsNode);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
case AST_NODE_TYPES.AssignmentExpression:
|
|
28
|
+
return tryGetThrowArgumentType(node.right);
|
|
29
|
+
|
|
30
|
+
case AST_NODE_TYPES.SequenceExpression:
|
|
31
|
+
return tryGetThrowArgumentType(node.expressions[node.expressions.length - 1]);
|
|
32
|
+
|
|
33
|
+
case AST_NODE_TYPES.LogicalExpression: {
|
|
34
|
+
const left = tryGetThrowArgumentType(node.left);
|
|
35
|
+
return left === undefined ? tryGetThrowArgumentType(node.right) : left;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
case AST_NODE_TYPES.ConditionalExpression: {
|
|
39
|
+
const consequent = tryGetThrowArgumentType(node.consequent);
|
|
40
|
+
return consequent === undefined ? tryGetThrowArgumentType(node.alternate) : consequent;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
default:
|
|
44
|
+
return undefined;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function checkThrowArgument(node) {
|
|
49
|
+
if (
|
|
50
|
+
node.type === AST_NODE_TYPES.AwaitExpression
|
|
51
|
+
|| node.type === AST_NODE_TYPES.YieldExpression
|
|
52
|
+
) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const type = tryGetThrowArgumentType(node);
|
|
57
|
+
if (type && type.getSymbol() && type.getSymbol().getName() === "NotImplementError") {
|
|
58
|
+
context.report({
|
|
59
|
+
node,
|
|
60
|
+
message: node.arguments.value || "구현되어있지 않습니다" //"'NotImplementError'를 'throw'하고 있습니다."
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return {
|
|
66
|
+
ThrowStatement(node) {
|
|
67
|
+
if (node.argument) {
|
|
68
|
+
checkThrowArgument(node.argument);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
73
|
};
|