@cdklabs/eslint-plugin 0.0.0

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.
@@ -0,0 +1,4 @@
1
+
2
+ import { Construct as CoreConstruct } from 'constructs';
3
+
4
+ const x: CoreConstruct;
@@ -0,0 +1,10 @@
1
+ import * as cdk from '@aws-cdk/core';
2
+ import * as constructs from 'constructs';
3
+ import * as somethingElse from 'somewhereElse';
4
+
5
+ const x: constructs.Construct;
6
+ const y: somethingElse.Things;
7
+ function fn1(z: constructs.Construct) {}
8
+
9
+ const p: constructs.IConstruct;
10
+ function fn2(p: constructs.IConstruct) {}
@@ -0,0 +1,10 @@
1
+ import { AnImport } from '@aws-cdk/core';
2
+ import { IConstruct, Construct } from 'constructs';
3
+
4
+ const x: Construct;
5
+ const y: Construct;
6
+
7
+ const p: IConstruct;
8
+ function fn2(q: IConstruct);
9
+
10
+ const a: AnImport;
@@ -0,0 +1,5 @@
1
+ import { AnImport } from '@aws-cdk/core';
2
+ import { Construct } from 'constructs';
3
+
4
+ const x: Construct;
5
+ const y: Construct;
@@ -0,0 +1,8 @@
1
+
2
+ import { IConstruct, Construct } from 'constructs';
3
+
4
+ const x: Construct;
5
+ function fn1(y: Construct) {}
6
+
7
+ const p: IConstruct;
8
+ function fn2(q: IConstruct);
package/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,38 @@
1
+ # eslint-plugin-cdk
2
+
3
+ Eslint plugin for the CDK repository. Contains rules that need to be applied specific to the CDK repository.
4
+
5
+ ## Rules
6
+
7
+ * `invalid-cfn-imports`: Ensures that imports of `Cfn<Resource>` L1 resources come from the stable
8
+ `aws-cdk-lib` package and not the alpha packages. Rule only applies to alpha modules.
9
+
10
+ * `no-core-construct`: Forbid the use of `Construct` and `IConstruct` from the "@aws-cdk/core" module.
11
+ Instead use `Construct` and `IConstruct` from the "constructs" module.
12
+ Rule only applies to typescript files under the `test/` folder.
13
+
14
+ * `no-invalid-path`: Checks paths specified using `path.join()` for validity, including not going backwards (`'..'`)
15
+ multiple times in the path and not going backwards beyond a package's `package.json`.
16
+
17
+ * `no-literal-partition`: Forbids the use of literal partitions (usually `aws`). Instead, use
18
+ `Aws.PARTITION` to ensure that the code works for other partitions too.
19
+
20
+ * `consider-promise-all`: when using `Promise.all()`, attest that there is no unbounded parallelism.
21
+
22
+ ## How to add new rules
23
+
24
+ * Make a new file in `lib/rules`. It should export one function called `create`. The
25
+ `create` function should return a visitor object.
26
+ * Add the new file to `lib/index.ts`.
27
+ * Add a fixture directory under `test/fixtures/<rule name>`. Copy and adjust an `eslintrc.js` file
28
+ from another test.
29
+ * Add a testing `.ts` file, and be sure to add either an `expected.ts` or an `.error.txt` variant
30
+ as well!
31
+ * You can now run the test in debugging mode (make sure to have `npx tsc -w` running, then from a debugging terminal, `npx jest --no-coverage -it 'your rule name'`), set a breakpoint, and inspect the typeless objects.
32
+
33
+ Use <https://ts-ast-viewer.com/> to get a feel for the AST you're trying to analyze. Note
34
+ that eslint uses `estree` to model AST nodes (not the TypeScript AST nodes), but they are
35
+ often comparable. Add type-testing TypeScript helpers to `type-checkers.ts` for typing
36
+ assistance.
37
+
38
+ To activate it for real on the repo, also add it to `cdk-build-tools/config/eslintrc.js`.
package/lib/index.d.ts ADDED
@@ -0,0 +1,11 @@
1
+ export declare const meta: {
2
+ name: any;
3
+ version: any;
4
+ };
5
+ export declare const rules: {
6
+ 'no-core-construct': any;
7
+ 'invalid-cfn-imports': any;
8
+ 'no-literal-partition': any;
9
+ 'no-invalid-path': any;
10
+ 'promiseall-no-unbounded-parallelism': any;
11
+ };
package/lib/index.js ADDED
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ /* eslint-disable @typescript-eslint/no-require-imports */
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.rules = exports.meta = void 0;
5
+ exports.meta = {
6
+ name: require('../package.json').name,
7
+ version: require('../package.json').version,
8
+ };
9
+ exports.rules = {
10
+ 'no-core-construct': require('./rules/no-core-construct'),
11
+ 'invalid-cfn-imports': require('./rules/invalid-cfn-imports'),
12
+ 'no-literal-partition': require('./rules/no-literal-partition'),
13
+ 'no-invalid-path': require('./rules/no-invalid-path'),
14
+ 'promiseall-no-unbounded-parallelism': require('./rules/promiseall-no-unbounded-parallelism'),
15
+ };
16
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLDBEQUEwRDs7O0FBRTdDLFFBQUEsSUFBSSxHQUFHO0lBQ2xCLElBQUksRUFBRSxPQUFPLENBQUMsaUJBQWlCLENBQUMsQ0FBQyxJQUFJO0lBQ3JDLE9BQU8sRUFBRSxPQUFPLENBQUMsaUJBQWlCLENBQUMsQ0FBQyxPQUFPO0NBQzVDLENBQUM7QUFFVyxRQUFBLEtBQUssR0FBRztJQUNuQixtQkFBbUIsRUFBRSxPQUFPLENBQUMsMkJBQTJCLENBQUM7SUFDekQscUJBQXFCLEVBQUUsT0FBTyxDQUFDLDZCQUE2QixDQUFDO0lBQzdELHNCQUFzQixFQUFFLE9BQU8sQ0FBQyw4QkFBOEIsQ0FBQztJQUMvRCxpQkFBaUIsRUFBRSxPQUFPLENBQUMseUJBQXlCLENBQUM7SUFDckQscUNBQXFDLEVBQUUsT0FBTyxDQUFDLDZDQUE2QyxDQUFDO0NBQzlGLENBQUMiLCJzb3VyY2VzQ29udGVudCI6WyIvKiBlc2xpbnQtZGlzYWJsZSBAdHlwZXNjcmlwdC1lc2xpbnQvbm8tcmVxdWlyZS1pbXBvcnRzICovXG5cbmV4cG9ydCBjb25zdCBtZXRhID0ge1xuICBuYW1lOiByZXF1aXJlKCcuLi9wYWNrYWdlLmpzb24nKS5uYW1lLFxuICB2ZXJzaW9uOiByZXF1aXJlKCcuLi9wYWNrYWdlLmpzb24nKS52ZXJzaW9uLFxufTtcblxuZXhwb3J0IGNvbnN0IHJ1bGVzID0ge1xuICAnbm8tY29yZS1jb25zdHJ1Y3QnOiByZXF1aXJlKCcuL3J1bGVzL25vLWNvcmUtY29uc3RydWN0JyksXG4gICdpbnZhbGlkLWNmbi1pbXBvcnRzJzogcmVxdWlyZSgnLi9ydWxlcy9pbnZhbGlkLWNmbi1pbXBvcnRzJyksXG4gICduby1saXRlcmFsLXBhcnRpdGlvbic6IHJlcXVpcmUoJy4vcnVsZXMvbm8tbGl0ZXJhbC1wYXJ0aXRpb24nKSxcbiAgJ25vLWludmFsaWQtcGF0aCc6IHJlcXVpcmUoJy4vcnVsZXMvbm8taW52YWxpZC1wYXRoJyksXG4gICdwcm9taXNlYWxsLW5vLXVuYm91bmRlZC1wYXJhbGxlbGlzbSc6IHJlcXVpcmUoJy4vcnVsZXMvcHJvbWlzZWFsbC1uby11bmJvdW5kZWQtcGFyYWxsZWxpc20nKSxcbn07XG4iXX0=
@@ -0,0 +1,15 @@
1
+ export interface ImportCacheKey {
2
+ readonly fileName: string;
3
+ readonly typeName: string;
4
+ }
5
+ export type Node = any;
6
+ export interface ImportCacheRecord extends ImportCacheKey {
7
+ readonly importNode: Node;
8
+ readonly localName: string;
9
+ }
10
+ export declare class ImportCache {
11
+ private records;
12
+ record(record: ImportCacheRecord): void;
13
+ find(key: ImportCacheKey): ImportCacheRecord | undefined;
14
+ get imports(): ImportCacheRecord[];
15
+ }
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.ImportCache = void 0;
27
+ const crypto = __importStar(require("crypto"));
28
+ class ImportCache {
29
+ constructor() {
30
+ this.records = {};
31
+ }
32
+ record(record) {
33
+ const key = {
34
+ fileName: record.fileName,
35
+ typeName: record.typeName,
36
+ };
37
+ this.records[hashed(key)] = record;
38
+ }
39
+ find(key) {
40
+ return this.records[hashed(key)];
41
+ }
42
+ get imports() {
43
+ return Object.values(this.records);
44
+ }
45
+ }
46
+ exports.ImportCache = ImportCache;
47
+ function hashed(key) {
48
+ const hash = crypto.createHash('md5');
49
+ hash.update(JSON.stringify(key));
50
+ return hash.digest('hex');
51
+ }
52
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW1wb3J0LWNhY2hlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3ByaXZhdGUvaW1wb3J0LWNhY2hlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7O0FBQUEsK0NBQWlDO0FBaUJqQyxNQUFhLFdBQVc7SUFBeEI7UUFDVSxZQUFPLEdBQXlDLEVBQUUsQ0FBQztJQWlCN0Q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gfCB1bmRlZmluZWQge1xuICAgIHJldHVybiB0aGlzLnJlY29yZHNbaGFzaGVkKGtleSldO1xuICB9XG5cbiAgcHVibGljIGdldCBpbXBvcnRzKCk6IEltcG9ydENhY2hlUmVjb3JkW10ge1xuICAgIHJldHVybiBPYmplY3QudmFsdWVzKHRoaXMucmVjb3Jkcyk7XG4gIH1cbn1cblxuZnVuY3Rpb24gaGFzaGVkKGtleToge30pOiBzdHJpbmcge1xuICBjb25zdCBoYXNoID0gY3J5cHRvLmNyZWF0ZUhhc2goJ21kNScpO1xuICBoYXNoLnVwZGF0ZShKU09OLnN0cmluZ2lmeShrZXkpKTtcbiAgcmV0dXJuIGhhc2guZGlnZXN0KCdoZXgnKTtcbn0iXX0=
@@ -0,0 +1,4 @@
1
+ /**
2
+ * We don't care about project test files (in a /test/ directory, excluding our fixtures)
3
+ */
4
+ export declare function isProdFile(filename: string): boolean;
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.isProdFile = isProdFile;
27
+ const path = __importStar(require("path"));
28
+ /**
29
+ * We don't care about project test files (in a /test/ directory, excluding our fixtures)
30
+ */
31
+ function isProdFile(filename) {
32
+ const isInTestFolder = new RegExp(/\/test\//).test(filename);
33
+ const isTestingPackage = new RegExp(/@aws-cdk-testing/).test(filename);
34
+ const isInOurTestFolder = path.resolve(filename).startsWith(path.resolve(__dirname, '..', '..', 'test'));
35
+ return (!isInTestFolder && !isTestingPackage) || isInOurTestFolder;
36
+ }
37
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaXMtcHJvZC1maWxlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3ByaXZhdGUvaXMtcHJvZC1maWxlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7QUFLQSxnQ0FPQztBQVpELDJDQUE2QjtBQUU3Qjs7R0FFRztBQUNILFNBQWdCLFVBQVUsQ0FBQyxRQUFnQjtJQUN6QyxNQUFNLGNBQWMsR0FBRyxJQUFJLE1BQU0sQ0FBQyxVQUFVLENBQUMsQ0FBQyxJQUFJLENBQUMsUUFBUSxDQUFDLENBQUM7SUFDN0QsTUFBTSxnQkFBZ0IsR0FBRyxJQUFJLE1BQU0sQ0FBQyxrQkFBa0IsQ0FBQyxDQUFDLElBQUksQ0FBQyxRQUFRLENBQUMsQ0FBQztJQUV2RSxNQUFNLGlCQUFpQixHQUFHLElBQUksQ0FBQyxPQUFPLENBQUMsUUFBUSxDQUFDLENBQUMsVUFBVSxDQUFDLElBQUksQ0FBQyxPQUFPLENBQUMsU0FBUyxFQUFFLElBQUksRUFBRSxJQUFJLEVBQUUsTUFBTSxDQUFDLENBQUMsQ0FBQztJQUV6RyxPQUFPLENBQUMsQ0FBQyxjQUFjLElBQUksQ0FBQyxnQkFBZ0IsQ0FBQyxJQUFJLGlCQUFpQixDQUFDO0FBQ3JFLENBQUMiLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgKiBhcyBwYXRoIGZyb20gJ3BhdGgnO1xuXG4vKipcbiAqIFdlIGRvbid0IGNhcmUgYWJvdXQgcHJvamVjdCB0ZXN0IGZpbGVzIChpbiBhIC90ZXN0LyBkaXJlY3RvcnksIGV4Y2x1ZGluZyBvdXIgZml4dHVyZXMpXG4gKi9cbmV4cG9ydCBmdW5jdGlvbiBpc1Byb2RGaWxlKGZpbGVuYW1lOiBzdHJpbmcpIHtcbiAgY29uc3QgaXNJblRlc3RGb2xkZXIgPSBuZXcgUmVnRXhwKC9cXC90ZXN0XFwvLykudGVzdChmaWxlbmFtZSk7XG4gIGNvbnN0IGlzVGVzdGluZ1BhY2thZ2UgPSBuZXcgUmVnRXhwKC9AYXdzLWNkay10ZXN0aW5nLykudGVzdChmaWxlbmFtZSk7XG5cbiAgY29uc3QgaXNJbk91clRlc3RGb2xkZXIgPSBwYXRoLnJlc29sdmUoZmlsZW5hbWUpLnN0YXJ0c1dpdGgocGF0aC5yZXNvbHZlKF9fZGlybmFtZSwgJy4uJywgJy4uJywgJ3Rlc3QnKSk7XG5cbiAgcmV0dXJuICghaXNJblRlc3RGb2xkZXIgJiYgIWlzVGVzdGluZ1BhY2thZ2UpIHx8IGlzSW5PdXJUZXN0Rm9sZGVyO1xufVxuIl19
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Matching the AST is a perennial problem. Here are some helpers.
3
+ *
4
+ * (NOTE: variable binding here does not support backtracking yet.
5
+ * That requires either explicitly keeping a stack somewhere, or using
6
+ * continuation-passing style everywhere so that we can use JS for
7
+ * backtracking. We don't need it yet and it's a bit of work, so it's not in
8
+ * here.)
9
+ */
10
+ export interface Match {
11
+ }
12
+ export type Pattern = (x: unknown, state: Match) => Match | undefined;
13
+ export declare function match(value: unknown, pattern: Pattern): Match | undefined;
14
+ /**
15
+ * Match any value
16
+ */
17
+ export declare function matchAny(): Pattern;
18
+ /**
19
+ * Make a Pattern that matches a literal value.
20
+ */
21
+ export declare function matchLiteral(x: any): Pattern;
22
+ /**
23
+ * Match an object's fields
24
+ */
25
+ export declare function matchObject(fields: Record<string, unknown>): Pattern;
26
+ /**
27
+ * Turn any value into a Pattern
28
+ *
29
+ * If it is already a Pattern (function0, return. Otherwise,
30
+ * make a Pattern that matches a literal value.
31
+ */
32
+ export declare function makePattern(x: unknown): Function;
33
+ /**
34
+ * Create a capturable variable in the matching
35
+ *
36
+ * The variable can have an `inner` pattern, which it will only match if the inner
37
+ * matcher succeeds.
38
+ *
39
+ * It optionally can also have a type tester, to validate that `variable.get()` will
40
+ * not lie about the type it has captured later on.
41
+ */
42
+ export declare function variable<T>(inner?: Pattern, tester?: (x: any) => x is T): Variable<T>;
43
+ export interface Variable<T> extends Pattern {
44
+ get(m: Match): T;
45
+ }
@@ -0,0 +1,85 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.match = match;
4
+ exports.matchAny = matchAny;
5
+ exports.matchLiteral = matchLiteral;
6
+ exports.matchObject = matchObject;
7
+ exports.makePattern = makePattern;
8
+ exports.variable = variable;
9
+ function match(value, pattern) {
10
+ return pattern(value, {});
11
+ }
12
+ /**
13
+ * Match any value
14
+ */
15
+ function matchAny() {
16
+ return function matchAny(_, state) { return state; };
17
+ }
18
+ /**
19
+ * Make a Pattern that matches a literal value.
20
+ */
21
+ function matchLiteral(x) {
22
+ return function matchLiteral(value, state) {
23
+ return value === x ? state : undefined;
24
+ };
25
+ }
26
+ /**
27
+ * Match an object's fields
28
+ */
29
+ function matchObject(fields) {
30
+ const patFields = Object.fromEntries(Object.entries(fields).map(([key, pat]) => [key, makePattern(pat)]));
31
+ return function matchObject(value, state) {
32
+ if (!value || typeof value !== 'object') {
33
+ return undefined;
34
+ }
35
+ for (const [field, pattern] of Object.entries(patFields)) {
36
+ state = pattern(value[field], state);
37
+ if (!state) {
38
+ break;
39
+ }
40
+ }
41
+ return state;
42
+ };
43
+ }
44
+ /**
45
+ * Turn any value into a Pattern
46
+ *
47
+ * If it is already a Pattern (function0, return. Otherwise,
48
+ * make a Pattern that matches a literal value.
49
+ */
50
+ function makePattern(x) {
51
+ return typeof x === 'function' ? x : matchLiteral(x);
52
+ }
53
+ /**
54
+ * Create a capturable variable in the matching
55
+ *
56
+ * The variable can have an `inner` pattern, which it will only match if the inner
57
+ * matcher succeeds.
58
+ *
59
+ * It optionally can also have a type tester, to validate that `variable.get()` will
60
+ * not lie about the type it has captured later on.
61
+ */
62
+ function variable(inner, tester) {
63
+ if (!inner) {
64
+ inner = matchAny;
65
+ }
66
+ const sym = Symbol();
67
+ const ret = function variable(x, state) {
68
+ const newState = inner(x, state);
69
+ if (!newState) {
70
+ return undefined;
71
+ }
72
+ if (tester && !tester(x)) {
73
+ throw new Error(`${JSON.stringify(x)} should be of type ${tester.name}, but doesn't`);
74
+ }
75
+ Object.defineProperty(newState, sym, {
76
+ value: x,
77
+ });
78
+ return newState;
79
+ };
80
+ ret.get = (m) => {
81
+ return m[sym];
82
+ };
83
+ return ret;
84
+ }
85
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibWF0Y2gtYXN0LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3ByaXZhdGUvbWF0Y2gtYXN0LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7O0FBY0Esc0JBRUM7QUFLRCw0QkFFQztBQUtELG9DQUlDO0FBS0Qsa0NBZUM7QUFRRCxrQ0FFQztBQVdELDRCQXdCQztBQW5GRCxTQUFnQixLQUFLLENBQUMsS0FBYyxFQUFFLE9BQWdCO0lBQ3BELE9BQU8sT0FBTyxDQUFDLEtBQUssRUFBRSxFQUFFLENBQUMsQ0FBQztBQUM1QixDQUFDO0FBRUQ7O0dBRUc7QUFDSCxTQUFnQixRQUFRO0lB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PT4geCBpcyBUKTogVmFyaWFibGU8VD4ge1xuICBpZiAoIWlubmVyKSB7XG4gICAgaW5uZXIgPSBtYXRjaEFueTtcbiAgfVxuXG4gIGNvbnN0IHN5bSA9IFN5bWJvbCgpO1xuICBjb25zdCByZXQgPSBmdW5jdGlvbiB2YXJpYWJsZSh4OiB1bmtub3duLCBzdGF0ZTogTWF0Y2gpIHtcbiAgICBjb25zdCBuZXdTdGF0ZSA9IGlubmVyKHgsIHN0YXRlKTtcbiAgICBpZiAoIW5ld1N0YXRlKSB7XG4gICAgICByZXR1cm4gdW5kZWZpbmVkO1xuICAgIH1cbiAgICBpZiAodGVzdGVyICYmICF0ZXN0ZXIoeCkpIHtcbiAgICAgIHRocm93IG5ldyBFcnJvcihgJHtKU09OLnN0cmluZ2lmeSh4KX0gc2hvdWxkIGJlIG9mIHR5cGUgJHt0ZXN0ZXIubmFtZX0sIGJ1dCBkb2Vzbid0YCk7XG4gICAgfVxuICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShuZXdTdGF0ZSwgc3ltLCB7XG4gICAgICB2YWx1ZTogeCxcbiAgICB9KTtcblxuICAgIHJldHVybiBuZXdTdGF0ZTtcbiAgfTtcbiAgcmV0LmdldCA9IChtOiBNYXRjaCkgPT4ge1xuICAgIHJldHVybiAobSBhcyBhbnkpW3N5bV07XG4gIH07XG4gIHJldHVybiByZXQ7XG59XG5cbmV4cG9ydCBpbnRlcmZhY2UgVmFyaWFibGU8VD4gZXh0ZW5kcyBQYXR0ZXJuIHtcbiAgZ2V0KG06IE1hdGNoKTogVDtcbn1cbiJdfQ==
@@ -0,0 +1,16 @@
1
+ import type * as estree from 'estree';
2
+ export declare function isMemberExpression(x: estree.BaseNode): x is estree.MemberExpression;
3
+ export declare function isIdentifier(x: estree.BaseNode): x is estree.Identifier;
4
+ export declare function matchMemberExpression(details?: NodeDetails<estree.MemberExpression>): import("./match-ast").Pattern;
5
+ export declare function matchIdentifier(name: string): import("./match-ast").Pattern;
6
+ /**
7
+ * The type of additional node fields (except its type)
8
+ */
9
+ type NodeDetails<T extends estree.BaseNode> = {
10
+ [k in Exclude<keyof T, 'type'>]?: unknown;
11
+ };
12
+ /**
13
+ * Match an ESTree node of a given type with given subfields
14
+ */
15
+ export declare function matchEstree<T extends estree.BaseNode>(type: T['type'], details?: NodeDetails<T>): import("./match-ast").Pattern;
16
+ export {};
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ // ESTree is supposed to be used dynamically typed (from JavaScript) and
3
+ // `@types/estree` only adds interface declarations, not helper functions to
4
+ // type guard objects. Therefore, we make a bunch here.
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.isMemberExpression = isMemberExpression;
7
+ exports.isIdentifier = isIdentifier;
8
+ exports.matchMemberExpression = matchMemberExpression;
9
+ exports.matchIdentifier = matchIdentifier;
10
+ exports.matchEstree = matchEstree;
11
+ const match_ast_1 = require("./match-ast");
12
+ function isMemberExpression(x) {
13
+ return x.type === 'MemberExpression';
14
+ }
15
+ function isIdentifier(x) {
16
+ return x.type === 'Identifier';
17
+ }
18
+ function matchMemberExpression(details) {
19
+ return matchEstree('MemberExpression', details);
20
+ }
21
+ function matchIdentifier(name) {
22
+ return matchEstree('Identifier', { name });
23
+ }
24
+ /**
25
+ * Match an ESTree node of a given type with given subfields
26
+ */
27
+ function matchEstree(type, details) {
28
+ return (0, match_ast_1.matchObject)({
29
+ type,
30
+ ...details,
31
+ });
32
+ }
33
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHlwZS1jaGVja2Vycy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9wcml2YXRlL3R5cGUtY2hlY2tlcnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLHdFQUF3RTtBQUN4RSw0RUFBNEU7QUFDNUUsdURBQXVEOztBQUt2RCxnREFFQztBQUVELG9DQUVDO0FBRUQsc0RBRUM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iAqL1xuZXhwb3J0IGZ1bmN0aW9uIG1hdGNoRXN0cmVlPFQgZXh0ZW5kcyBlc3RyZWUuQmFzZU5vZGU+KHR5cGU6IFRbJ3R5cGUnXSwgZGV0YWlscz86IE5vZGVEZXRhaWxzPFQ+KSB7XG4gIHJldHVybiBtYXRjaE9iamVjdCh7XG4gICAgdHlwZSxcbiAgICAuLi5kZXRhaWxzLFxuICB9KTtcbn1cbiJdfQ==
@@ -0,0 +1,2 @@
1
+ import { Rule } from 'eslint';
2
+ export declare function create(context: Rule.RuleContext): Rule.NodeListener;