eslint-cdk-plugin 3.0.0 → 3.0.2

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/dist/index.cjs CHANGED
@@ -26,7 +26,7 @@ function _interopNamespaceDefault(e) {
26
26
  var path__namespace = /*#__PURE__*/_interopNamespaceDefault(path);
27
27
 
28
28
  var name = "eslint-cdk-plugin";
29
- var version = "2.2.0";
29
+ var version = "3.0.1";
30
30
 
31
31
  const isConstructOrStackType = (type, ignoredClasses = ["App", "Stage"]) => {
32
32
  if (ignoredClasses.includes(type.symbol?.name ?? "")) return false;
@@ -114,6 +114,14 @@ const validateConstructorProperty = (constructor, context) => {
114
114
  }
115
115
  };
116
116
 
117
+ const SYMBOL_FLAGS = {
118
+ CLASS: 32
119
+ };
120
+ const SYNTAX_KIND = {
121
+ CLASS_DECLARATION: 263,
122
+ CONSTRUCTOR: 176
123
+ };
124
+
117
125
  const noConstructInInterface = utils.ESLintUtils.RuleCreator.withoutDocs({
118
126
  meta: {
119
127
  type: "problem",
@@ -136,6 +144,8 @@ const noConstructInInterface = utils.ESLintUtils.RuleCreator.withoutDocs({
136
144
  }
137
145
  const type = parserServices.getTypeAtLocation(property);
138
146
  if (!isConstructOrStackType(type)) continue;
147
+ const isClass = type.symbol.flags === SYMBOL_FLAGS.CLASS;
148
+ if (!isClass) continue;
139
149
  context.report({
140
150
  node: property,
141
151
  messageId: "invalidInterfaceProperty",
@@ -195,6 +205,8 @@ const validatePublicPropertyOfConstruct = (node, context, parserServices) => {
195
205
  if (!property.typeAnnotation) continue;
196
206
  const type = parserServices.getTypeAtLocation(property);
197
207
  if (!isConstructOrStackType(type)) continue;
208
+ const isClass = type.symbol.flags === SYMBOL_FLAGS.CLASS;
209
+ if (!isClass) continue;
198
210
  context.report({
199
211
  node: property,
200
212
  messageId: "invalidPublicPropertyOfConstruct",
@@ -216,6 +228,8 @@ const validateConstructorParameterProperty = (constructor, context, parserServic
216
228
  if (!param.parameter.typeAnnotation) continue;
217
229
  const type = parserServices.getTypeAtLocation(param);
218
230
  if (!isConstructOrStackType(type)) continue;
231
+ const isClass = type.symbol.flags === SYMBOL_FLAGS.CLASS;
232
+ if (!isClass) continue;
219
233
  context.report({
220
234
  node: param,
221
235
  messageId: "invalidPublicPropertyOfConstruct",
@@ -235,11 +249,6 @@ const toPascalCase = (str) => {
235
249
  }).join("");
236
250
  };
237
251
 
238
- const SYNTAX_KIND = {
239
- CLASS_DECLARATION: 263,
240
- CONSTRUCTOR: 176
241
- };
242
-
243
252
  const getConstructorPropertyNames = (type) => {
244
253
  const declarations = type.symbol?.declarations;
245
254
  if (!declarations?.length) return [];
package/dist/index.mjs CHANGED
@@ -3,7 +3,7 @@ import { ESLintUtils, AST_NODE_TYPES, AST_TOKEN_TYPES } from '@typescript-eslint
3
3
  import * as path from 'path';
4
4
 
5
5
  var name = "eslint-cdk-plugin";
6
- var version = "2.2.0";
6
+ var version = "3.0.1";
7
7
 
8
8
  const isConstructOrStackType = (type, ignoredClasses = ["App", "Stage"]) => {
9
9
  if (ignoredClasses.includes(type.symbol?.name ?? "")) return false;
@@ -91,6 +91,14 @@ const validateConstructorProperty = (constructor, context) => {
91
91
  }
92
92
  };
93
93
 
94
+ const SYMBOL_FLAGS = {
95
+ CLASS: 32
96
+ };
97
+ const SYNTAX_KIND = {
98
+ CLASS_DECLARATION: 263,
99
+ CONSTRUCTOR: 176
100
+ };
101
+
94
102
  const noConstructInInterface = ESLintUtils.RuleCreator.withoutDocs({
95
103
  meta: {
96
104
  type: "problem",
@@ -113,6 +121,8 @@ const noConstructInInterface = ESLintUtils.RuleCreator.withoutDocs({
113
121
  }
114
122
  const type = parserServices.getTypeAtLocation(property);
115
123
  if (!isConstructOrStackType(type)) continue;
124
+ const isClass = type.symbol.flags === SYMBOL_FLAGS.CLASS;
125
+ if (!isClass) continue;
116
126
  context.report({
117
127
  node: property,
118
128
  messageId: "invalidInterfaceProperty",
@@ -172,6 +182,8 @@ const validatePublicPropertyOfConstruct = (node, context, parserServices) => {
172
182
  if (!property.typeAnnotation) continue;
173
183
  const type = parserServices.getTypeAtLocation(property);
174
184
  if (!isConstructOrStackType(type)) continue;
185
+ const isClass = type.symbol.flags === SYMBOL_FLAGS.CLASS;
186
+ if (!isClass) continue;
175
187
  context.report({
176
188
  node: property,
177
189
  messageId: "invalidPublicPropertyOfConstruct",
@@ -193,6 +205,8 @@ const validateConstructorParameterProperty = (constructor, context, parserServic
193
205
  if (!param.parameter.typeAnnotation) continue;
194
206
  const type = parserServices.getTypeAtLocation(param);
195
207
  if (!isConstructOrStackType(type)) continue;
208
+ const isClass = type.symbol.flags === SYMBOL_FLAGS.CLASS;
209
+ if (!isClass) continue;
196
210
  context.report({
197
211
  node: param,
198
212
  messageId: "invalidPublicPropertyOfConstruct",
@@ -212,11 +226,6 @@ const toPascalCase = (str) => {
212
226
  }).join("");
213
227
  };
214
228
 
215
- const SYNTAX_KIND = {
216
- CLASS_DECLARATION: 263,
217
- CONSTRUCTOR: 176
218
- };
219
-
220
229
  const getConstructorPropertyNames = (type) => {
221
230
  const declarations = type.symbol?.declarations;
222
231
  if (!declarations?.length) return [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-cdk-plugin",
3
- "version": "3.0.0",
3
+ "version": "3.0.2",
4
4
  "description": "eslint plugin for AWS CDK projects",
5
5
  "main": "./dist/index.mjs",
6
6
  "types": "./dist/index.d.ts",
@@ -1,5 +1,6 @@
1
1
  import { AST_NODE_TYPES, ESLintUtils } from "@typescript-eslint/utils";
2
2
 
3
+ import { SYMBOL_FLAGS } from "../constants/tsInternalFlags";
3
4
  import { isConstructOrStackType } from "../utils/typeCheck";
4
5
 
5
6
  /**
@@ -37,6 +38,12 @@ export const noConstructInInterface = ESLintUtils.RuleCreator.withoutDocs({
37
38
  const type = parserServices.getTypeAtLocation(property);
38
39
  if (!isConstructOrStackType(type)) continue;
39
40
 
41
+ // NOTE: In order not to make it dependent on the typescript library, it defines its own unions.
42
+ // Therefore, the type information structures do not match.
43
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison
44
+ const isClass = type.symbol.flags === SYMBOL_FLAGS.CLASS;
45
+ if (!isClass) continue;
46
+
40
47
  context.report({
41
48
  node: property,
42
49
  messageId: "invalidInterfaceProperty",
@@ -6,12 +6,10 @@ import {
6
6
  TSESTree,
7
7
  } from "@typescript-eslint/utils";
8
8
 
9
+ import { SYMBOL_FLAGS } from "../constants/tsInternalFlags";
9
10
  import { isConstructOrStackType } from "../utils/typeCheck";
10
11
 
11
- type Context = TSESLint.RuleContext<
12
- "invalidPublicPropertyOfConstruct",
13
- []
14
- >;
12
+ type Context = TSESLint.RuleContext<"invalidPublicPropertyOfConstruct", []>;
15
13
 
16
14
  /**
17
15
  * Disallow Construct types in public property of Construct
@@ -94,6 +92,12 @@ const validatePublicPropertyOfConstruct = (
94
92
  const type = parserServices.getTypeAtLocation(property);
95
93
  if (!isConstructOrStackType(type)) continue;
96
94
 
95
+ // NOTE: In order not to make it dependent on the typescript library, it defines its own unions.
96
+ // Therefore, the type information structures do not match.
97
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison
98
+ const isClass = type.symbol.flags === SYMBOL_FLAGS.CLASS;
99
+ if (!isClass) continue;
100
+
97
101
  context.report({
98
102
  node: property,
99
103
  messageId: "invalidPublicPropertyOfConstruct",
@@ -133,6 +137,12 @@ const validateConstructorParameterProperty = (
133
137
  const type = parserServices.getTypeAtLocation(param);
134
138
  if (!isConstructOrStackType(type)) continue;
135
139
 
140
+ // NOTE: In order not to make it dependent on the typescript library, it defines its own unions.
141
+ // Therefore, the type information structures do not match.
142
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison
143
+ const isClass = type.symbol.flags === SYMBOL_FLAGS.CLASS;
144
+ if (!isClass) continue;
145
+
136
146
  context.report({
137
147
  node: param,
138
148
  messageId: "invalidPublicPropertyOfConstruct",