@simplysm/eslint-plugin 10.0.60 → 10.0.61

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.60",
3
+ "version": "10.0.61",
4
4
  "description": "심플리즘 패키지 - ESLINT 플러그인",
5
5
  "author": "김석래",
6
6
  "repository": {
@@ -12,7 +12,7 @@
12
12
  "type": "module",
13
13
  "main": "src/index.cjs",
14
14
  "engines": {
15
- "node": "^18"
15
+ "node": "^16"
16
16
  },
17
17
  "dependencies": {
18
18
  "@typescript-eslint/eslint-plugin": "^6.7.3",
@@ -116,33 +116,33 @@ module.exports = {
116
116
  }],
117
117
  "@typescript-eslint/prefer-ts-expect-error": ["error"],
118
118
 
119
- // REACT
120
- "react/jsx-curly-brace-presence": ["error", {props: "always", propElementValues: "always"}],
121
- "react/jsx-key": ["error", {
122
- checkFragmentShorthand: true,
123
- checkKeyMustBeforeSpread: true,
124
- warnOnDuplicates: true
125
- }],
126
- "react/jsx-no-useless-fragment": "error",
127
- "react/jsx-pascal-case": "error",
128
- "react/jsx-wrap-multilines": ["error", {
129
- "declaration": "parens",
130
- "assignment": "parens",
131
- "return": "parens",
132
- "arrow": "parens",
133
- "condition": "parens",
134
- "logical": "parens",
135
- "prop": "parens"
136
- }],
137
- "react/no-array-index-key": "error",
138
- "react/no-deprecated": "warn",
119
+ // REACT
120
+ "react/jsx-curly-brace-presence": ["error", {props: "always", propElementValues: "always"}],
121
+ "react/jsx-key": ["error", {
122
+ checkFragmentShorthand: true,
123
+ checkKeyMustBeforeSpread: true,
124
+ warnOnDuplicates: true
125
+ }],
126
+ "react/jsx-no-useless-fragment": "error",
127
+ "react/jsx-pascal-case": "error",
128
+ "react/jsx-wrap-multilines": ["error", {
129
+ "declaration": "parens",
130
+ "assignment": "parens",
131
+ "return": "parens",
132
+ "arrow": "parens",
133
+ "condition": "parens",
134
+ "logical": "parens",
135
+ "prop": "parens"
136
+ }],
137
+ "react/no-array-index-key": "error",
138
+ "react/no-deprecated": "warn",
139
139
 
140
140
 
141
- // 심플리즘
142
- "@simplysm/ts-no-throw-not-implement-error": ["warn"],
143
- "@simplysm/ts-no-self-entry-import": ["error"],
144
- "@simplysm/ts-no-external-import": ["error"],
145
- "@simplysm/jsx-no-prop-object": ["error"],
141
+ // 심플리즘
142
+ "@simplysm/ts-no-throw-not-implement-error": ["warn"],
143
+ "@simplysm/ts-no-self-entry-import": ["error"],
144
+ "@simplysm/ts-no-external-import": ["error"],
145
+ "@simplysm/jsx-no-prop-object": ["error"],
146
146
  }
147
147
  }
148
148
  ]
@@ -1,29 +1,58 @@
1
1
  module.exports = {
2
- meta: {
3
- type: "problem",
4
- docs: {
5
- description: "'jsx'에 직접적으로 Object/Array/Function를 입력할 수 없음",
6
- },
7
- fixable: false,
8
- schema: [],
2
+ meta: {
3
+ type: "problem",
4
+ docs: {
5
+ description: "'jsx'에 직접적으로 Object/Array/Function를 입력할 수 없음",
9
6
  },
7
+ fixable: false,
8
+ schema: [],
9
+ },
10
+ create: (context) => {
11
+ let scope = context.getScope();
12
+ let variables = scope.variables;
10
13
 
11
- create: (context) => {
12
- return {
13
- JSXExpressionContainer(node){
14
- if (
15
- node.type !== 'JSXExpressionContainer'
16
- || node.expression.type === "ArrayExpression"
17
- || node.expression.type === "ObjectExpression"
18
- || node.expression.type === "ArrowFunctionExpression"
19
- || node.expression.type === "FunctionExpression"
20
- ) {
21
- context.report({
22
- node,
23
- message: "'jsx'에 직접적으로 Object/Array/Function을 넣을 수 없습니다. (필요시, $.obj, $.fn, $.getter 활용)"
24
- });
25
- }
26
- }
27
- };
28
- },
14
+ while (scope.type !== 'global') {
15
+ scope = scope.upper;
16
+ variables = scope.variables.concat(variables);
17
+ }
18
+ if (scope.childScopes.length) {
19
+ variables = scope.childScopes[0].variables.concat(variables);
20
+ if (scope.childScopes[0].childScopes.length) {
21
+ variables = scope.childScopes[0].childScopes[0].variables.concat(variables);
22
+ }
23
+ }
24
+ variables = variables.reverse();
25
+
26
+ return {
27
+ JSXExpressionContainer(node) {
28
+ if (
29
+ node.type !== 'JSXExpressionContainer'
30
+ || node.expression.type === "ArrayExpression"
31
+ || node.expression.type === "ObjectExpression"
32
+ || node.expression.type === "ArrowFunctionExpression"
33
+ || node.expression.type === "FunctionExpression"
34
+ ) {
35
+ context.report({
36
+ node,
37
+ message: "'jsx'에 직접적으로 Object/Array/Function을 넣을 수 없습니다. (필요시, $.obj, $.fn, $.getter 활용)"
38
+ });
39
+ }
40
+ else if (node.expression.type === "Identifier") {
41
+ const variable = variables.find((item) => item.name === node.expression.name);
42
+
43
+ if (
44
+ variable?.defs[0]?.node.init?.type === "ArrayExpression"
45
+ || variable?.defs[0]?.node.init?.type === "ObjectExpression"
46
+ || variable?.defs[0]?.node.init?.type === "ArrowFunctionExpression"
47
+ || variable?.defs[0]?.node.init?.type === "FunctionExpression"
48
+ ) {
49
+ context.report({
50
+ node,
51
+ message: "'jsx'에 직접적으로 Object/Array/Function을 넣을 수 없습니다. (필요시, $.obj, $.fn, $.getter 활용)"
52
+ });
53
+ }
54
+ }
55
+ }
56
+ };
57
+ },
29
58
  };
@@ -1,4 +1,4 @@
1
- const { AST_NODE_TYPES } = require("@typescript-eslint/experimental-utils");
1
+ const {AST_NODE_TYPES} = require("@typescript-eslint/experimental-utils");
2
2
 
3
3
  module.exports = {
4
4
  meta: {