@simplysm/eslint-plugin 6.4.6 → 7.0.12

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 ADDED
@@ -0,0 +1 @@
1
+ module.exports = {};
package/package.json CHANGED
@@ -1,28 +1,25 @@
1
1
  {
2
2
  "name": "@simplysm/eslint-plugin",
3
- "version": "6.4.6",
3
+ "version": "7.0.12",
4
4
  "description": "심플리즘 패키지 - ESLINT 플러그인",
5
5
  "author": "김석래",
6
- "repository": "github:kslhunter/simplysm6",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/kslhunter/simplysm7.git",
9
+ "directory": "packages/eslint-plugin"
10
+ },
7
11
  "license": "MIT",
8
- "main": "./src/index.js",
12
+ "type": "module",
13
+ "main": "src/index.cjs",
9
14
  "sideEffects": false,
10
15
  "engines": {
11
- "node": "^14"
16
+ "node": "^16"
12
17
  },
13
18
  "dependencies": {
14
- "eslint": "7.32.0",
15
- "eslint-module-utils": "^2.6.2",
16
- "@typescript-eslint/experimental-utils": "4.28.2",
17
- "@typescript-eslint/eslint-plugin": "4.28.2",
18
- "@typescript-eslint/parser": "4.28.2",
19
- "eslint-import-resolver-typescript": "^2.4.0",
20
- "eslint-plugin-import": "^2.24.1",
21
- "@angular-eslint/eslint-plugin": "12.3.1",
22
- "@angular-eslint/eslint-plugin-template": "12.3.1",
23
- "@angular-eslint/template-parser": "12.3.1",
24
- "@angular/compiler": "^12.2.2",
25
- "eslint-plugin-jsdoc": "^36.0.7",
26
- "eslint-plugin-prefer-arrow": "^1.2.3"
27
- }
19
+ "eslint": "^8.7.0",
20
+ "@typescript-eslint/parser": "^5.10.1",
21
+ "@typescript-eslint/eslint-plugin": "^5.10.1"
22
+ },
23
+ "devDependencies": {},
24
+ "peerDependencies": {}
28
25
  }
@@ -0,0 +1,11 @@
1
+ module.exports = {
2
+ rules: {
3
+ "require-await": ["error"],
4
+ "quotes": ["error"],
5
+ "semi": ["error"],
6
+ "no-shadow": ["error"],
7
+ "no-duplicate-imports": ["error"],
8
+ "no-unused-expressions": ["error"],
9
+ "no-unused-vars": ["error"]
10
+ }
11
+ };
@@ -0,0 +1,33 @@
1
+ module.exports = {
2
+ parser: "@typescript-eslint/parser",
3
+ plugins: ["@typescript-eslint"],
4
+ /*extends: [
5
+ "plugin:@typescript-eslint/all"
6
+ ],*/
7
+ rules: {
8
+ "@typescript-eslint/explicit-member-accessibility": ["error"],
9
+ "@typescript-eslint/require-await": ["error"],
10
+ "@typescript-eslint/await-thenable": ["error"],
11
+ "@typescript-eslint/quotes": ["error"],
12
+ "@typescript-eslint/semi": ["error"],
13
+ "@typescript-eslint/no-shadow": ["error"],
14
+ "@typescript-eslint/member-delimiter-style": ["error"],
15
+ "@typescript-eslint/no-unnecessary-condition": ["error", { allowConstantLoopConditions: true }],
16
+ "@typescript-eslint/no-unnecessary-type-assertion": ["error"],
17
+ "@typescript-eslint/non-nullable-type-assertion-style": ["error"],
18
+ "@typescript-eslint/prefer-reduce-type-parameter": ["error"],
19
+ "@typescript-eslint/prefer-return-this-type": ["error"],
20
+ "@typescript-eslint/no-duplicate-imports": ["error"],
21
+ "@typescript-eslint/prefer-readonly": ["error"],
22
+ "@typescript-eslint/typedef": ["error"],
23
+ "@typescript-eslint/explicit-function-return-type": ["error", {
24
+ allowExpressions: true,
25
+ allowTypedFunctionExpressions: true,
26
+ allowHigherOrderFunctions: true,
27
+ allowDirectConstAssertionInArrowFunctions: true,
28
+ allowConciseArrowFunctionExpressionsStartingWithVoid: true
29
+ }],
30
+ "@typescript-eslint/no-unused-expressions": ["error"],
31
+ "@typescript-eslint/no-unused-vars": ["error"]
32
+ }
33
+ };
package/src/index.cjs ADDED
@@ -0,0 +1,8 @@
1
+ module.exports = {
2
+ configs: {
3
+ "base": require("./configs/base.cjs"),
4
+ "typescript": require("./configs/typescript.cjs")
5
+ },
6
+ rules: {},
7
+ processors: {}
8
+ };
@@ -1,20 +0,0 @@
1
- module.exports = {
2
- parser: "@angular-eslint/template-parser",
3
- plugins: [
4
- "@angular-eslint/template",
5
- "@simplysm"
6
- ],
7
- extends: ["plugin:@angular-eslint/template/all"],
8
- rules: {
9
- "@angular-eslint/template/cyclomatic-complexity": "off",
10
- "@angular-eslint/template/no-call-expression": "off",
11
- "@angular-eslint/template/i18n": "off",
12
- "@angular-eslint/template/no-any": "off",
13
- "@angular-eslint/template/click-events-have-key-events": "off",
14
- "@angular-eslint/template/accessibility-alt-text": "off",
15
- "@angular-eslint/template/accessibility-label-for": "off",
16
- "@angular-eslint/template/conditional-complexity": "off",
17
- "@angular-eslint/template/accessibility-label-has-associated-control": "off",
18
- "@simplysm/ng-template-no-todo-comments": "warn"
19
- }
20
- };
@@ -1,33 +0,0 @@
1
- module.exports = {
2
- plugins: ["@angular-eslint"],
3
- extends: ["plugin:@angular-eslint/all"],
4
- rules: {
5
- "@angular-eslint/component-class-suffix": ["error", {
6
- suffixes: ["Page", "Component", "Modal", "Control", "PrintTemplate", "Toast"]
7
- }],
8
- "@angular-eslint/directive-selector": [
9
- "error",
10
- {
11
- type: "attribute",
12
- prefix: "app",
13
- style: "camelCase"
14
- }
15
- ],
16
- "@angular-eslint/component-selector": [
17
- "error",
18
- {
19
- type: "element",
20
- prefix: "app",
21
- style: "kebab-case"
22
- }
23
- ],
24
- "@angular-eslint/no-output-native": "off",
25
- "@angular-eslint/no-input-rename": "off",
26
- "@angular-eslint/component-max-inline-declarations": "off",
27
- "@angular-eslint/no-forward-ref": "off",
28
- "@angular-eslint/no-output-rename": "off",
29
- "@angular-eslint/contextual-decorator": "off",
30
- "@angular-eslint/sort-ngmodule-metadata-arrays": "off",
31
- "@angular-eslint/no-empty-lifecycle-method": "warn"
32
- }
33
- };
@@ -1,105 +0,0 @@
1
- module.exports = {
2
- extends: [
3
- "eslint:all",
4
- "plugin:import/recommended"
5
- ],
6
- rules: {
7
- //-- warn
8
- "no-console": "warn",
9
- "no-warning-comments": "warn",
10
-
11
- //-- performance
12
- "import/namespace": "off",
13
- "import/export": "off",
14
-
15
- //-- consistent
16
- "function-call-argument-newline": ["error", "consistent"],
17
- "function-paren-newline": ["error", "consistent"],
18
- "quote-props": ["error", "consistent"],
19
- "array-element-newline": ["error", "consistent"],
20
- "array-bracket-newline": ["error", "consistent"],
21
- "object-property-newline": ["error", { allowAllPropertiesOnSameLine: true }],
22
-
23
- //-- comment
24
- "capitalized-comments": "off",
25
- "no-inline-comments": "off",
26
- "line-comment-position": "off",
27
- "spaced-comment": "off",
28
- "multiline-comment-style": "off",
29
- "lines-around-comment": "off",
30
-
31
- //-- size
32
- "max-statements": "off",
33
- "max-len": "off",
34
- "max-lines-per-function": "off",
35
- "max-params": "off",
36
- "max-lines": "off",
37
- "max-classes-per-file": "off",
38
- "max-depth": "off",
39
- "id-length": "off",
40
-
41
- //-- func
42
- "func-style": "off",
43
- "func-names": "off",
44
-
45
- //-- ternary
46
- "no-ternary": "off",
47
- "multiline-ternary": "off",
48
- "no-nested-ternary": "off",
49
-
50
- //-- etc
51
- "linebreak-style": ["error", "windows"],
52
- "indent": ["error", 2, { FunctionExpression: { parameters: "first" }, SwitchCase: 1 }],
53
- "sort-keys": "off",
54
- "no-magic-numbers": "off",
55
- "object-curly-spacing": ["error", "always"],
56
- "padded-blocks": ["error", "never"],
57
- "no-trailing-spaces": "off",
58
- "eol-last": "off",
59
- "no-negated-condition": "off",
60
- "no-undefined": "off",
61
- "no-plusplus": "off",
62
- "one-var": ["error", "never"],
63
- "no-await-in-loop": "off",
64
- "sort-imports": "off",
65
- "no-extra-boolean-cast": "off",
66
- "operator-linebreak": ["error", "before"],
67
- "no-underscore-dangle": "off",
68
- "dot-location": ["error", "property"],
69
- "class-methods-use-this": "off",
70
- "prefer-destructuring": "off",
71
- "prefer-template": "off",
72
- "require-unicode-regexp": "off",
73
- "newline-per-chained-call": "off",
74
- "complexity": "off",
75
- "no-eq-null": "off",
76
- "eqeqeq": ["error", "always", { null: "never" }],
77
- "no-else-return": "off",
78
- "prefer-named-capture-group": "off",
79
- "no-multi-spaces": ["error", { ignoreEOLComments: true }],
80
- "no-bitwise": "off",
81
- "curly": ["error", "multi-line"],
82
- "no-continue": "off",
83
- "consistent-this": "off",
84
- "no-constant-condition": ["error", { checkLoops: false }],
85
- "new-cap": ["error", { capIsNew: false, newIsCap: false }],
86
- "no-extend-native": "off",
87
- "no-control-regex": "off",
88
- "require-atomic-updates": "off",
89
- "space-before-function-paren": ["error", {
90
- anonymous: "ignore",
91
- named: "never",
92
- asyncArrow: "always"
93
- }],
94
- "no-empty": "off",
95
- "no-async-promise-executor": "off",
96
- "array-bracket-spacing": "off",
97
- "no-alert": "off",
98
- "no-lonely-if": "off",
99
- "brace-style": ["error", "stroustrup"],
100
- "accessor-pairs": "off",
101
- "arrow-body-style": "off",
102
- "no-extra-parens": "off",
103
- "no-useless-escape": "off"
104
- }
105
- };
@@ -1,119 +0,0 @@
1
- module.exports = {
2
- extends: [
3
- "plugin:import/typescript",
4
- "plugin:@typescript-eslint/all"
5
- ],
6
- plugins: ["@simplysm"],
7
- settings: {
8
- "import/parsers": {
9
- "@typescript-eslint/parser": [".ts"]
10
- }
11
- },
12
- rules: {
13
- //-- simplysm
14
- "@simplysm/ts-no-throw-not-implement-error": "warn",
15
- "@simplysm/ts-no-self-entry-import": "error",
16
-
17
- //-- performance
18
- "@typescript-eslint/no-implied-eval": "off",
19
-
20
- //-- any
21
- "@typescript-eslint/no-unsafe-member-access": "off",
22
- "@typescript-eslint/no-unsafe-call": "off",
23
- "@typescript-eslint/no-unsafe-return": "off",
24
- "@typescript-eslint/no-unsafe-assignment": "off",
25
- "@typescript-eslint/no-explicit-any": "off",
26
- "@typescript-eslint/no-unsafe-argument": "off",
27
-
28
- //-- etc
29
- "@typescript-eslint/method-signature-style": "off",
30
- // "@typescript-eslint/indent": ["error", 2, { FunctionExpression: { parameters: "first" }, SwitchCase: 1 }], // 퍼포먼스 이슈
31
- "@typescript-eslint/indent": "off", // 퍼포먼스 이슈
32
- "@typescript-eslint/prefer-readonly-parameter-types": "off",
33
- "@typescript-eslint/explicit-function-return-type": ["error", {
34
- allowExpressions: true,
35
- allowTypedFunctionExpressions: true,
36
- allowHigherOrderFunctions: true,
37
- allowDirectConstAssertionInArrowFunctions: true,
38
- allowConciseArrowFunctionExpressionsStartingWithVoid: true
39
- }],
40
- "@typescript-eslint/return-await": "off", // 버그가 있어서 끔
41
- "@typescript-eslint/no-magic-numbers": "off",
42
- "@typescript-eslint/no-extraneous-class": ["error", {
43
- allowStaticOnly: true,
44
- allowEmpty: true
45
- }],
46
- "@typescript-eslint/brace-style": ["error", "stroustrup"],
47
- "@typescript-eslint/space-before-function-paren": ["error", {
48
- anonymous: "ignore",
49
- named: "never",
50
- asyncArrow: "always"
51
- }],
52
- "@typescript-eslint/unified-signatures": "off",
53
- "@typescript-eslint/no-implicit-any-catch": "off",
54
- "@typescript-eslint/unbound-method": "off",
55
- "@typescript-eslint/init-declarations": "off",
56
- "@typescript-eslint/dot-notation": "off",
57
- "@typescript-eslint/no-parameter-properties": "off",
58
- "@typescript-eslint/no-misused-promises": ["error", { checksVoidReturn: false }],
59
- "@typescript-eslint/no-non-null-assertion": "off",
60
- "@typescript-eslint/consistent-type-imports": "off",
61
- "@typescript-eslint/explicit-module-boundary-types": ["error", { allowArgumentsExplicitlyTypedAsAny: true }],
62
- "@typescript-eslint/no-extra-parens": "off",
63
- "@typescript-eslint/no-inferrable-types": ["error", { ignoreParameters: true }],
64
- "@typescript-eslint/no-type-alias": ["error", {
65
- allowConstructors: "always",
66
- allowConditionalTypes: "always",
67
- allowAliases: "always",
68
- allowMappedTypes: "always",
69
- allowLiterals: "always",
70
- allowCallbacks: "always"
71
- }],
72
- "@typescript-eslint/member-ordering": "off",
73
- "@typescript-eslint/ban-types": "off",
74
- "@typescript-eslint/strict-boolean-expressions": ["error", { allowNullableBoolean: true }],
75
- "@typescript-eslint/no-dynamic-delete": "off",
76
- "@typescript-eslint/no-this-alias": "off",
77
- "@typescript-eslint/no-unnecessary-condition": ["error", { allowConstantLoopConditions: true }],
78
- "@typescript-eslint/no-empty-function": "off",
79
- "@typescript-eslint/no-empty-interface": "off",
80
- "@typescript-eslint/naming-convention": [
81
- "error",
82
- {
83
- selector: "default",
84
- format: ["camelCase", "UPPER_CASE"]
85
- },
86
- {
87
- selector: "default",
88
- modifiers: ["private"],
89
- format: ["camelCase", "UPPER_CASE"],
90
- leadingUnderscore: "require"
91
- },
92
- {
93
- selector: "typeLike",
94
- format: ["PascalCase", "UPPER_CASE"]
95
- },
96
- {
97
- selector: "memberLike",
98
- format: null
99
- }
100
- ],
101
- "@typescript-eslint/lines-between-class-members": "off",
102
- "@typescript-eslint/restrict-plus-operands": "off", // 버그가 있어서 끔
103
- "@typescript-eslint/no-invalid-void-type": "off",
104
- "@typescript-eslint/no-invalid-this": "off",
105
- "@typescript-eslint/no-loop-func": "off",
106
- "@typescript-eslint/no-unused-vars": ["warn", { args: "none" }],
107
- "@typescript-eslint/ban-ts-comment": "off",
108
- "@typescript-eslint/quotes": ["error", "double", {
109
- avoidEscape: true,
110
- allowTemplateLiterals: true
111
- }],
112
- "@typescript-eslint/no-require-imports": "off",
113
- "@typescript-eslint/no-var-requires": "off",
114
- "@typescript-eslint/no-use-before-define": "off",
115
- // "@typescript-eslint/no-floating-promises": "off", // 퍼포먼스 이슈, 그래도 필요함..
116
- "@typescript-eslint/sort-type-union-intersection-members": "off",
117
- "@typescript-eslint/object-curly-spacing": ["error", "always"]
118
- }
119
- };
package/src/index.js DELETED
@@ -1,16 +0,0 @@
1
- module.exports = {
2
- configs: {
3
- "base": require("./configs/base"),
4
- "typescript": require("./configs/typescript"),
5
- "angular": require("./configs/angular"),
6
- "angular-template": require("./configs/angular-template")
7
- },
8
- rules: {
9
- "ts-no-self-entry-import": require("./rules/ts-no-self-entry-import"),
10
- "ts-no-throw-not-implement-error": require("./rules/ts-no-throw-not-implement-error"),
11
- "ng-template-no-todo-comments": require("./rules/ng-template-no-todo-comments")
12
- },
13
- processors: {
14
- "extract-angular-inline-html": require("./processors/extract-angular-inline-html")
15
- }
16
- };
@@ -1,186 +0,0 @@
1
- const ts = require("typescript");
2
- const path = require("path");
3
-
4
- const multipleComponentsPerFileError
5
- = "@simplysm/eslint-plugin currently only supports 1 Component per file";
6
-
7
-
8
- const rangeMap = new Map();
9
-
10
- function quickGetRangeForTemplate(text, template) {
11
- //const start = text.indexOf(template);
12
- const start = text.indexOf(" template: `") + 13;
13
- return [start, start + template.length];
14
- }
15
-
16
- module.exports = {
17
- preprocess(text, filename) {
18
- try {
19
- const sourceFile = ts.createSourceFile(filename, text, ts.ScriptTarget.Latest, true);
20
-
21
- const classDeclarations = sourceFile.statements.filter((s) => ts.isClassDeclaration(s));
22
- if (!classDeclarations.length) {
23
- return [text];
24
- }
25
-
26
- /**
27
- * Find all the Component decorators
28
- */
29
- const componentDecoratorNodes = [];
30
- for (const classDeclaration of classDeclarations) {
31
- if (classDeclaration.decorators) {
32
- for (const decorator of classDeclaration.decorators) {
33
- if (
34
- ts.isCallExpression(decorator.expression)
35
- && ts.isIdentifier(decorator.expression.expression)
36
- && decorator.expression.expression.text === "Component"
37
- ) {
38
- componentDecoratorNodes.push(decorator);
39
- }
40
- }
41
- }
42
- }
43
-
44
- /**
45
- * Ignore malformed Component files
46
- */
47
- if (!componentDecoratorNodes.length) {
48
- return [text];
49
- }
50
-
51
- /**
52
- * Only support one component per file for now...
53
- * I don't know if people actually use multiple components per file in practice
54
- * and I think it makes sense to wait until people complain about this before
55
- * attempting to figure out support for it (rather than having something half-baked)
56
- */
57
- if (componentDecoratorNodes.length > 1) {
58
- throw new Error(multipleComponentsPerFileError);
59
- }
60
-
61
- const componentDecoratorNode = componentDecoratorNodes[0];
62
- /**
63
- * Ignore malformed component metadata
64
- */
65
- if (
66
- !ts.isDecorator(componentDecoratorNode)
67
- || !ts.isCallExpression(componentDecoratorNode.expression)
68
- || componentDecoratorNode.expression.arguments.length !== 1
69
- ) {
70
- return [text];
71
- }
72
-
73
- const metadata = componentDecoratorNode.expression.arguments[0];
74
- if (!ts.isObjectLiteralExpression(metadata)) {
75
- return [text];
76
- }
77
-
78
- /**
79
- * Ignore Components which have external template files, they will be linted directly,
80
- * and any that have inline templates which are malformed
81
- */
82
- const templateProperty = metadata.properties.find((id) => id && id.name && id.name.getText() === "template");
83
- if (
84
- metadata.properties.find((id) => id && id.name && id.name.getText() === "templateUrl")
85
- || !templateProperty
86
- ) {
87
- return [text];
88
- }
89
-
90
- if (
91
- !ts.isPropertyAssignment(templateProperty)
92
- || !ts.isStringLiteralLike(templateProperty.initializer)
93
- ) {
94
- return [text];
95
- }
96
-
97
- const templateText = templateProperty.initializer.text;
98
- const realTemplateText = templateText
99
- .replace(/\n/g, "\r\n")
100
- .replace(/`/g, "\\`");
101
-
102
- const range = quickGetRangeForTemplate(text, realTemplateText);
103
-
104
- rangeMap.set(filename, {
105
- range,
106
- lineAndCharacter: {
107
- start: sourceFile.getLineAndCharacterOfPosition(range[0]),
108
- end: sourceFile.getLineAndCharacterOfPosition(range[1])
109
- }
110
- });
111
-
112
- /**
113
- * We return an array containing both the original source, and a new fragment
114
- * representing the inline HTML template. It must have an appropriate .html
115
- * extension so that it can be linted using the right rules and plugins.
116
- *
117
- * The postprocessor will handle tying things back to the right position
118
- * in the original file, so this temporary filename will never be visible
119
- * to the end user.
120
- */
121
- return [
122
- text,
123
- {
124
- text: realTemplateText,
125
- filename: path.basename(filename).replace(/\.ts$/, ".html")
126
- }
127
- ];
128
- }
129
- catch (err) {
130
- // Rethrow known error
131
- if (err.message === multipleComponentsPerFileError) {
132
- throw err;
133
- }
134
-
135
- err.message = "preprocess: ERROR could not parse @Component() metadata " + filename + "\n=> " + err.message;
136
- // eslint-disable-next-line no-console
137
- console.error(err);
138
- return [text];
139
- }
140
- },
141
- postprocess(multiDimensionalMessages, filename) {
142
- const messagesFromComponentSource = multiDimensionalMessages[0];
143
- const messagesFromInlineTemplateHTML = multiDimensionalMessages[1];
144
- /**
145
- * If the Component did not have an inline template the second item
146
- * in the multiDimensionalMessages will not exist
147
- */
148
- if (
149
- !messagesFromInlineTemplateHTML
150
- || !messagesFromInlineTemplateHTML.length
151
- ) {
152
- return messagesFromComponentSource;
153
- }
154
- const rangeData = rangeMap.get(filename);
155
- if (rangeData === undefined) {
156
- return messagesFromComponentSource;
157
- }
158
-
159
- /**
160
- * Adjust message location data to apply it back to the
161
- * original file
162
- */
163
- return [
164
- ...messagesFromComponentSource,
165
- ...messagesFromInlineTemplateHTML.map(
166
- (message) => {
167
- message.line += rangeData.lineAndCharacter.start.line;
168
- // message.column = message.column;
169
-
170
- message.endLine += rangeData.lineAndCharacter.start.line;
171
- // message.endColumn = message.endColumn;
172
-
173
- const startOffset = rangeData.range[0];
174
- if (message.fix) {
175
- message.fix.range = [
176
- startOffset + message.fix.range[0],
177
- startOffset + message.fix.range[1]
178
- ];
179
- }
180
- return message;
181
- }
182
- )
183
- ];
184
- },
185
- supportsAutofix: true
186
- };
@@ -1,45 +0,0 @@
1
- module.exports = {
2
- meta: {
3
- type: "suggestion",
4
- docs: {
5
- description: "'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 +0,0 @@
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
- };
@@ -1,73 +0,0 @@
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
- };