@simplysm/eslint-plugin 10.0.37 → 10.0.40

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@simplysm/eslint-plugin",
3
- "version": "10.0.37",
3
+ "version": "10.0.40",
4
4
  "description": "심플리즘 패키지 - ESLINT 플러그인",
5
5
  "author": "김석래",
6
6
  "repository": {
@@ -15,14 +15,14 @@
15
15
  "node": "^18"
16
16
  },
17
17
  "dependencies": {
18
- "@typescript-eslint/eslint-plugin": "^5.62.0",
18
+ "@typescript-eslint/eslint-plugin": "^6.3.0",
19
19
  "@typescript-eslint/experimental-utils": "^5.62.0",
20
- "@typescript-eslint/parser": "^5.62.0",
21
- "eslint": "^8.44.0",
22
- "eslint-import-resolver-typescript": "^3.5.5",
20
+ "@typescript-eslint/parser": "^6.3.0",
21
+ "eslint": "^8.46.0",
22
+ "eslint-import-resolver-typescript": "^3.6.0",
23
23
  "eslint-module-utils": "^2.8.0",
24
- "eslint-plugin-deprecation": "^1.4.1",
25
- "eslint-plugin-import": "^2.27.5",
24
+ "eslint-plugin-deprecation": "^1.5.0",
25
+ "eslint-plugin-import": "^2.28.0",
26
26
  "typescript": "^4.9.5"
27
27
  }
28
28
  }
@@ -0,0 +1,116 @@
1
+ module.exports = {
2
+ ignorePatterns: [
3
+ "**/node_modules/**",
4
+ "**/.cache/**",
5
+ "**/dist/**",
6
+ "**/.*/**"
7
+ ],
8
+ env: {
9
+ node: true,
10
+ es2021: true
11
+ },
12
+ parserOptions: {
13
+ ecmaVersion: 2021,
14
+ sourceType: "module"
15
+ },
16
+ overrides: [
17
+ {
18
+ files: ["*.js", "*.cjs", "*.mjs"],
19
+ plugins: ["import"],
20
+ rules: {
21
+ // import
22
+ "import/no-extraneous-dependencies": ["error"], // 느림
23
+
24
+ "no-console": ["warn"],
25
+ "no-warning-comments": ["warn"],
26
+
27
+ "require-await": ["error"],
28
+ "semi": ["error"],
29
+ "no-shadow": ["error"],
30
+ "no-duplicate-imports": ["error"],
31
+ "no-unused-expressions": ["error"],
32
+ "no-unused-vars": ["error"],
33
+ "no-undef": ["error"],
34
+ // "linebreak-style": ["error", "unix"]
35
+ },
36
+ },
37
+ {
38
+ files: ["*.ts", "*.tsx"],
39
+ parser: "@typescript-eslint/parser",
40
+ parserOptions: {
41
+ project: "packages/*/tsconfig.json"
42
+ },
43
+ plugins: [
44
+ "@typescript-eslint",
45
+ "deprecation",
46
+ "import",
47
+ "@simplysm"
48
+ ],
49
+ settings: {
50
+ "import/parsers": {
51
+ "@typescript-eslint/parser": [".ts", ".tsx"]
52
+ },
53
+ "import/resolver": {
54
+ "typescript": {
55
+ project: "packages/*/tsconfig.json",
56
+ }
57
+ }
58
+ },
59
+ rules: {
60
+ // 기본
61
+ "no-console": ["warn"],
62
+ "no-warning-comments": ["warn"],
63
+ // "linebreak-style": ["error", "unix"],
64
+
65
+ // Deprecation
66
+ // "deprecation/deprecation": ["warn"], // 느림
67
+
68
+ // import
69
+ "import/no-extraneous-dependencies": ["error"], // 느림
70
+ // "import/no-duplicates": ["error"], // 느림
71
+
72
+ // 심플리즘
73
+ "@simplysm/ts-no-throw-not-implement-error": ["warn"],
74
+ "@simplysm/ts-no-self-entry-import": ["error"],
75
+ "@simplysm/ts-no-external-import": ["error"],
76
+
77
+ // 타입스크립트
78
+ "@typescript-eslint/explicit-member-accessibility": ["error"],
79
+ "@typescript-eslint/require-await": ["error"],
80
+ "@typescript-eslint/await-thenable": ["error"],
81
+ "@typescript-eslint/return-await": ["error", "always"],
82
+ "@typescript-eslint/no-floating-promises": ["error"],
83
+ "@typescript-eslint/semi": ["error"],
84
+ "@typescript-eslint/no-shadow": ["error"],
85
+ // "@typescript-eslint/member-delimiter-style": ["error"],
86
+ // "@typescript-eslint/no-unnecessary-condition": ["error", { allowConstantLoopConditions: true }],
87
+ // "@typescript-eslint/no-unnecessary-type-assertion": ["error"],
88
+ "@typescript-eslint/non-nullable-type-assertion-style": ["error"],
89
+ "@typescript-eslint/prefer-reduce-type-parameter": ["error"],
90
+ "@typescript-eslint/prefer-return-this-type": ["error"],
91
+ "@typescript-eslint/prefer-readonly": ["error"],
92
+ "@typescript-eslint/typedef": ["error"],
93
+ "@typescript-eslint/explicit-function-return-type": ["error", {
94
+ allowExpressions: true,
95
+ allowTypedFunctionExpressions: true,
96
+ allowHigherOrderFunctions: true,
97
+ allowDirectConstAssertionInArrowFunctions: true,
98
+ allowConciseArrowFunctionExpressionsStartingWithVoid: true,
99
+ allowFunctionsWithoutTypeParameters: true
100
+ }],
101
+ "@typescript-eslint/explicit-module-boundary-types": ["error", {
102
+ allowArgumentsExplicitlyTypedAsAny: true,
103
+ }],
104
+ "@typescript-eslint/no-unused-expressions": ["error"],
105
+ "@typescript-eslint/no-unused-vars": ["error", { args: "none" }],
106
+ "@typescript-eslint/strict-boolean-expressions": ["error", {
107
+ allowString: true,
108
+ allowNumber: true,
109
+ allowNullableBoolean: true,
110
+ allowNullableObject: true
111
+ }],
112
+ "@typescript-eslint/prefer-ts-expect-error": ["error"]
113
+ }
114
+ }
115
+ ]
116
+ };
package/src/index.cjs CHANGED
@@ -1,9 +1,9 @@
1
1
  module.exports = {
2
2
  configs: {
3
- "base": require("./configs/base.cjs"),
4
- "typescript": require("./configs/typescript.cjs")
3
+ "root": require("./configs/root.cjs")
5
4
  },
6
5
  rules: {
6
+ "ts-no-external-import": require("./rules/ts-no-external-import.cjs"),
7
7
  "ts-no-self-entry-import": require("./rules/ts-no-self-entry-import.cjs"),
8
8
  "ts-no-throw-not-implement-error": require("./rules/ts-no-throw-not-implement-error.cjs")
9
9
  }
@@ -0,0 +1,72 @@
1
+ const resolve = require("eslint-module-utils/resolve").default;
2
+ const path = require("path");
3
+ const fs = require("fs");
4
+
5
+ module.exports = {
6
+ meta: {
7
+ type: "problem",
8
+ docs: {
9
+ description: "패키지 외부의 파일 직접 import 금지"
10
+ },
11
+ fixable: true,
12
+ schema: [],
13
+ },
14
+ create: (context) => {
15
+ const filePath = context.getFilename();
16
+
17
+ function getPkgPath(currFilePath) {
18
+ let curr = path.dirname(currFilePath);
19
+ while (true) {
20
+ if (fs.existsSync(path.resolve(curr, "package.json"))) {
21
+ break;
22
+ }
23
+
24
+ curr = path.dirname(curr);
25
+ if (!curr) break;
26
+ }
27
+
28
+ return curr;
29
+ }
30
+
31
+ function append(node) {
32
+ const requirePath = node.value;
33
+ if (filePath !== "<text>" && requirePath.startsWith("..")) {
34
+ const resolvedPath = (resolve(requirePath, context) || requirePath).toLowerCase();
35
+ if (resolvedPath) {
36
+ const pkgPath = getPkgPath(filePath);
37
+ const relativePath = path.relative(pkgPath, resolvedPath);
38
+ const isChildPath = Boolean(relativePath) && !relativePath.startsWith("..") && !path.isAbsolute(relativePath);
39
+ if (!isChildPath) {
40
+ context.report({
41
+ node,
42
+ message: "패키지 외부의 파일을 직접 import 하고 있습니다.",
43
+ fix(fixer) {
44
+ const reqPkgNpmConf = JSON.parse(fs.readFileSync(path.resolve(getPkgPath(resolvedPath), "package.json"), "utf-8"));
45
+ return fixer.replaceText(node, `"${reqPkgNpmConf.name}"`);
46
+ }
47
+ });
48
+ }
49
+ }
50
+ }
51
+ }
52
+
53
+ return {
54
+ "ImportDeclaration": (node) => {
55
+ append(node.source);
56
+ },
57
+ "CallExpression": (node) => {
58
+ if (
59
+ node
60
+ && node.callee
61
+ && node.callee.type === "Identifier"
62
+ && node.callee.name === "require"
63
+ && node.arguments.length === 1
64
+ && node.arguments[0].type === "Literal"
65
+ && typeof node.arguments[0].value === "string"
66
+ ) {
67
+ append(node.arguments[0]);
68
+ }
69
+ }
70
+ };
71
+ }
72
+ };
@@ -7,7 +7,6 @@ module.exports = {
7
7
  docs: {
8
8
  description: "동일 패키지 내의 index.ts 파일 import 금지"
9
9
  },
10
-
11
10
  schema: []
12
11
  },
13
12
  create: (context) => {
@@ -6,7 +6,6 @@ module.exports = {
6
6
  docs: {
7
7
  description: "'NotImplementError' 사용 경고"
8
8
  },
9
-
10
9
  schema: []
11
10
  },
12
11
  create: (context) => {
@@ -70,4 +69,4 @@ module.exports = {
70
69
  }
71
70
  };
72
71
  }
73
- };
72
+ };
package/.eslintrc.cjs DELETED
@@ -1 +0,0 @@
1
- module.exports = {};
@@ -1,23 +0,0 @@
1
- module.exports = {
2
- env: {
3
- node: true,
4
- es2021: 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
- "semi": ["error"],
16
- "no-shadow": ["error"],
17
- "no-duplicate-imports": ["error"],
18
- "no-unused-expressions": ["error"],
19
- "no-unused-vars": ["error"],
20
- "no-undef": ["error"],
21
- "linebreak-style": ["error", "unix"]
22
- }
23
- };
@@ -1,68 +0,0 @@
1
- module.exports = {
2
- parser: "@typescript-eslint/parser",
3
- plugins: [
4
- "@typescript-eslint",
5
- "deprecation",
6
- "import",
7
- "@simplysm"
8
- ],
9
- settings: {
10
- "import/parsers": {
11
- "@typescript-eslint/parser": [".ts", ".tsx"]
12
- }
13
- },
14
- rules: {
15
- // 기본
16
- "no-console": ["warn"],
17
- "no-warning-comments": ["warn"],
18
- "linebreak-style": ["error", "unix"],
19
-
20
- // Deprecation
21
- // "deprecation/deprecation": ["warn"], // 느림
22
-
23
- // import
24
- // "import/no-extraneous-dependencies": ["error"], // 느림
25
-
26
- // 심플리즘
27
- "@simplysm/ts-no-throw-not-implement-error": ["warn"],
28
- "@simplysm/ts-no-self-entry-import": ["error"],
29
-
30
- // 타입스크립트
31
- "@typescript-eslint/explicit-member-accessibility": ["error"],
32
- "@typescript-eslint/require-await": ["error"],
33
- "@typescript-eslint/await-thenable": ["error"],
34
- "@typescript-eslint/return-await": ["error", "always"],
35
- "@typescript-eslint/no-floating-promises": ["error"],
36
- "@typescript-eslint/semi": ["error"],
37
- "@typescript-eslint/no-shadow": ["error"],
38
- // "@typescript-eslint/member-delimiter-style": ["error"],
39
- // "@typescript-eslint/no-unnecessary-condition": ["error", { allowConstantLoopConditions: true }],
40
- // "@typescript-eslint/no-unnecessary-type-assertion": ["error"],
41
- "@typescript-eslint/non-nullable-type-assertion-style": ["error"],
42
- "@typescript-eslint/prefer-reduce-type-parameter": ["error"],
43
- "@typescript-eslint/prefer-return-this-type": ["error"],
44
- "@typescript-eslint/no-duplicate-imports": ["error"],
45
- "@typescript-eslint/prefer-readonly": ["error"],
46
- "@typescript-eslint/typedef": ["error"],
47
- "@typescript-eslint/explicit-function-return-type": ["error", {
48
- allowExpressions: true,
49
- allowTypedFunctionExpressions: true,
50
- allowHigherOrderFunctions: true,
51
- allowDirectConstAssertionInArrowFunctions: true,
52
- allowConciseArrowFunctionExpressionsStartingWithVoid: true,
53
- allowFunctionsWithoutTypeParameters: true
54
- }],
55
- "@typescript-eslint/explicit-module-boundary-types": ["error", {
56
- allowArgumentsExplicitlyTypedAsAny: 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
- allowString: true,
62
- allowNumber: true,
63
- allowNullableBoolean: true,
64
- allowNullableObject: true
65
- }],
66
- "@typescript-eslint/prefer-ts-expect-error": ["error"]
67
- }
68
- };