oxlint-appsync 0.1.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.
package/README.md ADDED
@@ -0,0 +1,94 @@
1
+ # oxlint-appsync
2
+
3
+ Oxlint (and ESLint-compatible) plugin that enforces [AWS AppSync JavaScript runtime restrictions](https://docs.aws.amazon.com/appsync/latest/devguide/supported-features.html).
4
+
5
+ Use it to catch unsupported syntax in AppSync resolver code before deployment. See [docs/code-generation-appsync.md](docs/code-generation-appsync.md) for the project-specific summary of limitations.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ npm install -D oxlint oxlint-appsync
11
+ ```
12
+
13
+ `oxlint-appsync` depends on `@oxlint/plugins` at runtime.
14
+
15
+ ## Usage with Oxlint
16
+
17
+ ### `.oxlintrc.json`
18
+
19
+ Copy [oxlintrc.example.json](oxlintrc.example.json) to `.oxlintrc.json` in your project:
20
+
21
+ ### `oxlint.config.ts`
22
+
23
+ ```ts
24
+ import { defineConfig } from "oxlint";
25
+ import plugin, { recommended } from "oxlint-appsync";
26
+
27
+ export default defineConfig({
28
+ jsPlugins: [plugin],
29
+ rules: recommended,
30
+ });
31
+ ```
32
+
33
+ Run:
34
+
35
+ ```bash
36
+ npx oxlint path/to/appsync
37
+ ```
38
+
39
+ ## Usage with ESLint
40
+
41
+ The plugin uses Oxlint's `createOnce` API wrapped with `eslintCompatPlugin`, so it also works with ESLint:
42
+
43
+ ```js
44
+ import appsync from "oxlint-appsync";
45
+ import { recommended } from "oxlint-appsync";
46
+
47
+ export default [
48
+ {
49
+ plugins: { appsync },
50
+ rules: recommended,
51
+ },
52
+ ];
53
+ ```
54
+
55
+ ## Rules
56
+
57
+ | Rule | Description |
58
+ | --- | --- |
59
+ | `appsync/no-string-constructor` | Disallow `String()` for stringification |
60
+ | `appsync/no-async-await` | Disallow `async`/`await` and async functions |
61
+ | `appsync/no-classes` | Disallow `class` declarations and expressions |
62
+ | `appsync/no-instanceof` | Disallow `instanceof` |
63
+ | `appsync/no-for-loop` | Disallow C-style `for` loops (`for-in` / `for-of` allowed) |
64
+ | `appsync/no-while` | Disallow `while` loops |
65
+ | `appsync/no-do-while` | Disallow `do-while` loops |
66
+ | `appsync/no-try` | Disallow `try`/`catch`/`finally` |
67
+ | `appsync/no-throw` | Disallow `throw` |
68
+ | `appsync/no-continue` | Disallow `continue` |
69
+ | `appsync/no-labeled-statement` | Disallow labeled statements |
70
+ | `appsync/no-new` | Disallow the `new` operator |
71
+ | `appsync/no-generators` | Disallow generator functions |
72
+ | `appsync/no-this` | Disallow `this` |
73
+ | `appsync/no-update-operators` | Disallow `++` and `--` |
74
+ | `appsync/no-bitwise-not` | Disallow bitwise NOT (`~`) |
75
+ | `appsync/no-in-operator` | Disallow `in` (use `Object.hasOwn`) |
76
+ | `appsync/no-function-arguments` | Disallow passing functions as call arguments |
77
+
78
+ ## Development
79
+
80
+ ```bash
81
+ npm install
82
+ npm run build
83
+ npm test
84
+ ```
85
+
86
+ ## References
87
+
88
+ - [Writing Oxlint JS plugins](https://oxc.rs/docs/guide/usage/linter/writing-js-plugins.html)
89
+ - [AWS AppSync supported runtime features](https://docs.aws.amazon.com/appsync/latest/devguide/supported-features.html)
90
+ - [Project AppSync code generation rules](docs/code-generation-appsync.md)
91
+
92
+ ## License
93
+
94
+ MIT
@@ -0,0 +1,39 @@
1
+ import * as _oxlint_plugins0 from "@oxlint/plugins";
2
+ import { Rule } from "eslint";
3
+
4
+ //#region src/rules/types.d.ts
5
+ type AppsyncRuleModule = {
6
+ meta: Rule.RuleMetaData;
7
+ createOnce: (context: Rule.RuleContext) => Rule.RuleListener;
8
+ };
9
+ //#endregion
10
+ //#region src/rules/index.d.ts
11
+ declare const rules: {
12
+ "no-async-await": AppsyncRuleModule;
13
+ "no-bitwise-not": AppsyncRuleModule;
14
+ "no-classes": AppsyncRuleModule;
15
+ "no-continue": AppsyncRuleModule;
16
+ "no-do-while": AppsyncRuleModule;
17
+ "no-for-loop": AppsyncRuleModule;
18
+ "no-function-arguments": AppsyncRuleModule;
19
+ "no-generators": AppsyncRuleModule;
20
+ "no-in-operator": AppsyncRuleModule;
21
+ "no-instanceof": AppsyncRuleModule;
22
+ "no-labeled-statement": AppsyncRuleModule;
23
+ "no-new": AppsyncRuleModule;
24
+ "no-string-constructor": AppsyncRuleModule;
25
+ "no-this": AppsyncRuleModule;
26
+ "no-throw": AppsyncRuleModule;
27
+ "no-try": AppsyncRuleModule;
28
+ "no-update-operators": AppsyncRuleModule;
29
+ "no-while": AppsyncRuleModule;
30
+ };
31
+ //#endregion
32
+ //#region src/plugin.d.ts
33
+ declare const plugin: _oxlint_plugins0.Plugin;
34
+ declare const recommended: Record<`appsync/${keyof typeof rules}`, "error">;
35
+ //# sourceMappingURL=plugin.d.ts.map
36
+
37
+ //#endregion
38
+ export { plugin as default, plugin, recommended };
39
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../src/rules/types.ts","../src/rules/index.ts","../src/plugin.ts"],"mappings":";;;;KAEY,iBAAA;QACJ,IAAA,CAAK;wBACW,IAAA,CAAK,gBAAgB,IAAA,CAAK;AAFlD,CAAA;;;cCkBM;;;EDlBM,YAAA,mBAAiB;EAAA,aAAA,mBAAA;eAChB,mBAAA;eACgB,mBAAA;yBAAqB,mBAAA;EAAY,eAAA,mBAAA;;;;ECgBxD,QAmBuC,mBAAA;EAAA,uBAAA,mBAAA;;;;;;;;;cCpChC,QAKX,gBAAA,CALiB;cAON,aAER,+BAA+B"}
package/dist/index.js ADDED
@@ -0,0 +1,318 @@
1
+ import { eslintCompatPlugin } from "@oxlint/plugins";
2
+ //#region src/rules/types.ts
3
+ function defineAppsyncRule(rule) {
4
+ return rule;
5
+ }
6
+ //#endregion
7
+ //#region src/rules/utils.ts
8
+ function isIdentifier(node, name) {
9
+ return node?.type === "Identifier" && node.name === name;
10
+ }
11
+ function reportDefault(context, node, messageId = "default") {
12
+ context.report({
13
+ node,
14
+ messageId
15
+ });
16
+ }
17
+ //#endregion
18
+ //#region src/rules/no-async-await.ts
19
+ var no_async_await_default = defineAppsyncRule({
20
+ meta: {
21
+ type: "problem",
22
+ docs: { description: "Disallow async functions and await expressions in AppSync resolvers" },
23
+ messages: { default: "Promises and async/await are not supported in the AppSync JS runtime" },
24
+ schema: []
25
+ },
26
+ createOnce(context) {
27
+ const reportAsyncFunction = (node) => {
28
+ if (node.async) reportDefault(context, node);
29
+ };
30
+ return {
31
+ AwaitExpression(node) {
32
+ reportDefault(context, node);
33
+ },
34
+ FunctionDeclaration: reportAsyncFunction,
35
+ FunctionExpression: reportAsyncFunction,
36
+ ArrowFunctionExpression: reportAsyncFunction
37
+ };
38
+ }
39
+ });
40
+ //#endregion
41
+ //#region src/rules/no-bitwise-not.ts
42
+ var no_bitwise_not_default = defineAppsyncRule({
43
+ meta: {
44
+ type: "problem",
45
+ docs: { description: "Disallow the bitwise NOT (~) operator in AppSync resolvers" },
46
+ messages: { default: "The ~ operator is not supported in the AppSync JS runtime" },
47
+ schema: []
48
+ },
49
+ createOnce(context) {
50
+ return { UnaryExpression(node) {
51
+ if (node.operator === "~") reportDefault(context, node);
52
+ } };
53
+ }
54
+ });
55
+ //#endregion
56
+ //#region src/rules/no-classes.ts
57
+ var no_classes_default = defineAppsyncRule({
58
+ meta: {
59
+ type: "problem",
60
+ docs: { description: "Disallow class declarations and expressions in AppSync resolvers" },
61
+ messages: { default: "Classes are not supported in the AppSync JS runtime" },
62
+ schema: []
63
+ },
64
+ createOnce(context) {
65
+ return {
66
+ ClassDeclaration(node) {
67
+ reportDefault(context, node);
68
+ },
69
+ ClassExpression(node) {
70
+ reportDefault(context, node);
71
+ }
72
+ };
73
+ }
74
+ });
75
+ //#endregion
76
+ //#region src/rules/no-continue.ts
77
+ var no_continue_default = defineAppsyncRule({
78
+ meta: {
79
+ type: "problem",
80
+ docs: { description: "Disallow continue statements in AppSync resolvers" },
81
+ messages: { default: "continue statements are not supported in the AppSync JS runtime" },
82
+ schema: []
83
+ },
84
+ createOnce(context) {
85
+ return { ContinueStatement(node) {
86
+ reportDefault(context, node);
87
+ } };
88
+ }
89
+ });
90
+ //#endregion
91
+ //#region src/rules/no-do-while.ts
92
+ var no_do_while_default = defineAppsyncRule({
93
+ meta: {
94
+ type: "problem",
95
+ docs: { description: "Disallow do-while loops in AppSync resolvers" },
96
+ messages: { default: "do-while loops are not supported in the AppSync JS runtime" },
97
+ schema: []
98
+ },
99
+ createOnce(context) {
100
+ return { DoWhileStatement(node) {
101
+ reportDefault(context, node);
102
+ } };
103
+ }
104
+ });
105
+ //#endregion
106
+ //#region src/rules/no-for-loop.ts
107
+ var no_for_loop_default = defineAppsyncRule({
108
+ meta: {
109
+ type: "problem",
110
+ docs: { description: "Disallow C-style for loops in AppSync resolvers (for-in and for-of are allowed)" },
111
+ messages: { default: "Only for-in and for-of loops are supported in the AppSync JS runtime" },
112
+ schema: []
113
+ },
114
+ createOnce(context) {
115
+ return { ForStatement(node) {
116
+ reportDefault(context, node);
117
+ } };
118
+ }
119
+ });
120
+ //#endregion
121
+ //#region src/rules/no-function-arguments.ts
122
+ const FUNCTION_ARGUMENT_TYPES = /* @__PURE__ */ new Set([
123
+ "FunctionDeclaration",
124
+ "FunctionExpression",
125
+ "ArrowFunctionExpression"
126
+ ]);
127
+ function isFunctionArgument(node) {
128
+ return FUNCTION_ARGUMENT_TYPES.has(node.type);
129
+ }
130
+ //#endregion
131
+ //#region src/rules/index.ts
132
+ const rules = {
133
+ "no-async-await": no_async_await_default,
134
+ "no-bitwise-not": no_bitwise_not_default,
135
+ "no-classes": no_classes_default,
136
+ "no-continue": no_continue_default,
137
+ "no-do-while": no_do_while_default,
138
+ "no-for-loop": no_for_loop_default,
139
+ "no-function-arguments": defineAppsyncRule({
140
+ meta: {
141
+ type: "problem",
142
+ docs: { description: "Disallow passing functions as call arguments in AppSync resolvers" },
143
+ messages: { default: "Passing functions as arguments is not supported in the AppSync JS runtime" },
144
+ schema: []
145
+ },
146
+ createOnce(context) {
147
+ return { CallExpression(node) {
148
+ for (const argument of node.arguments) if (argument.type !== "SpreadElement" && isFunctionArgument(argument)) reportDefault(context, argument);
149
+ } };
150
+ }
151
+ }),
152
+ "no-generators": defineAppsyncRule({
153
+ meta: {
154
+ type: "problem",
155
+ docs: { description: "Disallow generator functions in AppSync resolvers" },
156
+ messages: { default: "Generators are not supported in the AppSync JS runtime" },
157
+ schema: []
158
+ },
159
+ createOnce(context) {
160
+ const reportGenerator = (node) => {
161
+ if (node.generator) reportDefault(context, node);
162
+ };
163
+ return {
164
+ FunctionDeclaration: reportGenerator,
165
+ FunctionExpression: reportGenerator
166
+ };
167
+ }
168
+ }),
169
+ "no-in-operator": defineAppsyncRule({
170
+ meta: {
171
+ type: "problem",
172
+ docs: { description: "Disallow the in operator in AppSync resolvers" },
173
+ messages: { default: "The in operator is not supported in the AppSync JS runtime; use Object.hasOwn instead" },
174
+ schema: []
175
+ },
176
+ createOnce(context) {
177
+ return { BinaryExpression(node) {
178
+ if (node.operator === "in") reportDefault(context, node);
179
+ } };
180
+ }
181
+ }),
182
+ "no-instanceof": defineAppsyncRule({
183
+ meta: {
184
+ type: "problem",
185
+ docs: { description: "Disallow the instanceof operator in AppSync resolvers" },
186
+ messages: { default: "The instanceof operator is not supported in the AppSync JS runtime" },
187
+ schema: []
188
+ },
189
+ createOnce(context) {
190
+ return { BinaryExpression(node) {
191
+ if (node.operator === "instanceof") reportDefault(context, node);
192
+ } };
193
+ }
194
+ }),
195
+ "no-labeled-statement": defineAppsyncRule({
196
+ meta: {
197
+ type: "problem",
198
+ docs: { description: "Disallow labeled statements in AppSync resolvers" },
199
+ messages: { default: "Labeled statements are not supported in the AppSync JS runtime" },
200
+ schema: []
201
+ },
202
+ createOnce(context) {
203
+ return { LabeledStatement(node) {
204
+ reportDefault(context, node);
205
+ } };
206
+ }
207
+ }),
208
+ "no-new": defineAppsyncRule({
209
+ meta: {
210
+ type: "problem",
211
+ docs: { description: "Disallow the new operator in AppSync resolvers" },
212
+ messages: { default: "The new operator is not supported in the AppSync JS runtime" },
213
+ schema: []
214
+ },
215
+ createOnce(context) {
216
+ return { NewExpression(node) {
217
+ reportDefault(context, node);
218
+ } };
219
+ }
220
+ }),
221
+ "no-string-constructor": defineAppsyncRule({
222
+ meta: {
223
+ type: "problem",
224
+ docs: { description: "Disallow using String() to stringify values in AppSync resolvers" },
225
+ messages: { default: "Do not use String() to stringify variables in the AppSync JS runtime" },
226
+ schema: []
227
+ },
228
+ createOnce(context) {
229
+ return {
230
+ CallExpression(node) {
231
+ if (isIdentifier(node.callee, "String")) reportDefault(context, node);
232
+ },
233
+ NewExpression(node) {
234
+ if (isIdentifier(node.callee, "String")) reportDefault(context, node);
235
+ }
236
+ };
237
+ }
238
+ }),
239
+ "no-this": defineAppsyncRule({
240
+ meta: {
241
+ type: "problem",
242
+ docs: { description: "Disallow this expressions in AppSync resolvers" },
243
+ messages: { default: "this is not supported in the AppSync JS runtime" },
244
+ schema: []
245
+ },
246
+ createOnce(context) {
247
+ return { ThisExpression(node) {
248
+ reportDefault(context, node);
249
+ } };
250
+ }
251
+ }),
252
+ "no-throw": defineAppsyncRule({
253
+ meta: {
254
+ type: "problem",
255
+ docs: { description: "Disallow throw statements in AppSync resolvers" },
256
+ messages: { default: "throw statements are not supported in the AppSync JS runtime" },
257
+ schema: []
258
+ },
259
+ createOnce(context) {
260
+ return { ThrowStatement(node) {
261
+ reportDefault(context, node);
262
+ } };
263
+ }
264
+ }),
265
+ "no-try": defineAppsyncRule({
266
+ meta: {
267
+ type: "problem",
268
+ docs: { description: "Disallow try/catch/finally statements in AppSync resolvers" },
269
+ messages: { default: "try/catch/finally statements are not supported in the AppSync JS runtime" },
270
+ schema: []
271
+ },
272
+ createOnce(context) {
273
+ return { TryStatement(node) {
274
+ reportDefault(context, node);
275
+ } };
276
+ }
277
+ }),
278
+ "no-update-operators": defineAppsyncRule({
279
+ meta: {
280
+ type: "problem",
281
+ docs: { description: "Disallow ++ and -- operators in AppSync resolvers" },
282
+ messages: { default: "++ and -- operators are not supported in the AppSync JS runtime" },
283
+ schema: []
284
+ },
285
+ createOnce(context) {
286
+ return { UpdateExpression(node) {
287
+ reportDefault(context, node);
288
+ } };
289
+ }
290
+ }),
291
+ "no-while": defineAppsyncRule({
292
+ meta: {
293
+ type: "problem",
294
+ docs: { description: "Disallow while loops in AppSync resolvers" },
295
+ messages: { default: "while loops are not supported in the AppSync JS runtime" },
296
+ schema: []
297
+ },
298
+ createOnce(context) {
299
+ return { WhileStatement(node) {
300
+ reportDefault(context, node);
301
+ } };
302
+ }
303
+ })
304
+ };
305
+ //#endregion
306
+ //#region src/plugin.ts
307
+ const plugin = eslintCompatPlugin({
308
+ meta: { name: "appsync" },
309
+ rules
310
+ });
311
+ const recommended = Object.fromEntries(Object.keys(rules).map((ruleName) => [`appsync/${ruleName}`, "error"]));
312
+ //#endregion
313
+ //#region src/index.ts
314
+ var src_default = plugin;
315
+ //#endregion
316
+ export { src_default as default, plugin, recommended };
317
+
318
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["noAsyncAwait","noBitwiseNot","noClasses","noContinue","noDoWhile","noForLoop","noFunctionArguments","noGenerators","noInOperator","noInstanceof","noLabeledStatement","noNew","noStringConstructor","noThis","noThrow","noTry","noUpdateOperators","noWhile"],"sources":["../src/rules/types.ts","../src/rules/utils.ts","../src/rules/no-async-await.ts","../src/rules/no-bitwise-not.ts","../src/rules/no-classes.ts","../src/rules/no-continue.ts","../src/rules/no-do-while.ts","../src/rules/no-for-loop.ts","../src/rules/no-function-arguments.ts","../src/rules/no-generators.ts","../src/rules/no-in-operator.ts","../src/rules/no-instanceof.ts","../src/rules/no-labeled-statement.ts","../src/rules/no-new.ts","../src/rules/no-string-constructor.ts","../src/rules/no-this.ts","../src/rules/no-throw.ts","../src/rules/no-try.ts","../src/rules/no-update-operators.ts","../src/rules/no-while.ts","../src/rules/index.ts","../src/plugin.ts","../src/index.ts"],"sourcesContent":["import type { Rule } from \"eslint\";\n\nexport type AppsyncRuleModule = {\n meta: Rule.RuleMetaData;\n createOnce: (context: Rule.RuleContext) => Rule.RuleListener;\n};\n\nexport function defineAppsyncRule(rule: AppsyncRuleModule): AppsyncRuleModule {\n return rule;\n}\n","import type { Rule } from \"eslint\";\n\ntype NodeWithType = { type: string };\n\nexport function isIdentifier(\n node: NodeWithType | null | undefined,\n name: string,\n): boolean {\n return node?.type === \"Identifier\" && (node as { name: string }).name === name;\n}\n\nexport function reportDefault(\n context: Rule.RuleContext,\n node: Rule.Node,\n messageId = \"default\",\n): void {\n context.report({ node, messageId });\n}\n","import { defineAppsyncRule } from \"./types.js\";\nimport { reportDefault } from \"./utils.js\";\n\nexport default defineAppsyncRule({\n meta: {\n type: \"problem\",\n docs: {\n description:\n \"Disallow async functions and await expressions in AppSync resolvers\",\n },\n messages: {\n default:\n \"Promises and async/await are not supported in the AppSync JS runtime\",\n },\n schema: [],\n },\n createOnce(context) {\n const reportAsyncFunction = (node: { async?: boolean }) => {\n if (node.async) {\n reportDefault(context, node as never);\n }\n };\n\n return {\n AwaitExpression(node) {\n reportDefault(context, node);\n },\n FunctionDeclaration: reportAsyncFunction,\n FunctionExpression: reportAsyncFunction,\n ArrowFunctionExpression: reportAsyncFunction,\n };\n },\n});\n","import { defineAppsyncRule } from \"./types.js\";\nimport { reportDefault } from \"./utils.js\";\n\nexport default defineAppsyncRule({\n meta: {\n type: \"problem\",\n docs: {\n description: \"Disallow the bitwise NOT (~) operator in AppSync resolvers\",\n },\n messages: {\n default: \"The ~ operator is not supported in the AppSync JS runtime\",\n },\n schema: [],\n },\n createOnce(context) {\n return {\n UnaryExpression(node) {\n if (node.operator === \"~\") {\n reportDefault(context, node);\n }\n },\n };\n },\n});\n","import { defineAppsyncRule } from \"./types.js\";\nimport { reportDefault } from \"./utils.js\";\n\nexport default defineAppsyncRule({\n meta: {\n type: \"problem\",\n docs: {\n description: \"Disallow class declarations and expressions in AppSync resolvers\",\n },\n messages: {\n default: \"Classes are not supported in the AppSync JS runtime\",\n },\n schema: [],\n },\n createOnce(context) {\n return {\n ClassDeclaration(node) {\n reportDefault(context, node);\n },\n ClassExpression(node) {\n reportDefault(context, node);\n },\n };\n },\n});\n","import { defineAppsyncRule } from \"./types.js\";\nimport { reportDefault } from \"./utils.js\";\n\nexport default defineAppsyncRule({\n meta: {\n type: \"problem\",\n docs: {\n description: \"Disallow continue statements in AppSync resolvers\",\n },\n messages: {\n default: \"continue statements are not supported in the AppSync JS runtime\",\n },\n schema: [],\n },\n createOnce(context) {\n return {\n ContinueStatement(node) {\n reportDefault(context, node);\n },\n };\n },\n});\n","import { defineAppsyncRule } from \"./types.js\";\nimport { reportDefault } from \"./utils.js\";\n\nexport default defineAppsyncRule({\n meta: {\n type: \"problem\",\n docs: {\n description: \"Disallow do-while loops in AppSync resolvers\",\n },\n messages: {\n default: \"do-while loops are not supported in the AppSync JS runtime\",\n },\n schema: [],\n },\n createOnce(context) {\n return {\n DoWhileStatement(node) {\n reportDefault(context, node);\n },\n };\n },\n});\n","import { defineAppsyncRule } from \"./types.js\";\nimport { reportDefault } from \"./utils.js\";\n\nexport default defineAppsyncRule({\n meta: {\n type: \"problem\",\n docs: {\n description:\n \"Disallow C-style for loops in AppSync resolvers (for-in and for-of are allowed)\",\n },\n messages: {\n default:\n \"Only for-in and for-of loops are supported in the AppSync JS runtime\",\n },\n schema: [],\n },\n createOnce(context) {\n return {\n ForStatement(node) {\n reportDefault(context, node);\n },\n };\n },\n});\n","import type { Rule } from \"eslint\";\nimport { defineAppsyncRule } from \"./types.js\";\nimport { reportDefault } from \"./utils.js\";\n\nconst FUNCTION_ARGUMENT_TYPES = new Set([\n \"FunctionDeclaration\",\n \"FunctionExpression\",\n \"ArrowFunctionExpression\",\n]);\n\nfunction isFunctionArgument(node: Rule.Node): boolean {\n return FUNCTION_ARGUMENT_TYPES.has(node.type);\n}\n\nexport default defineAppsyncRule({\n meta: {\n type: \"problem\",\n docs: {\n description:\n \"Disallow passing functions as call arguments in AppSync resolvers\",\n },\n messages: {\n default:\n \"Passing functions as arguments is not supported in the AppSync JS runtime\",\n },\n schema: [],\n },\n createOnce(context) {\n return {\n CallExpression(node) {\n for (const argument of node.arguments) {\n if (argument.type !== \"SpreadElement\" && isFunctionArgument(argument)) {\n reportDefault(context, argument);\n }\n }\n },\n };\n },\n});\n","import { defineAppsyncRule } from \"./types.js\";\nimport { reportDefault } from \"./utils.js\";\n\nexport default defineAppsyncRule({\n meta: {\n type: \"problem\",\n docs: {\n description: \"Disallow generator functions in AppSync resolvers\",\n },\n messages: {\n default: \"Generators are not supported in the AppSync JS runtime\",\n },\n schema: [],\n },\n createOnce(context) {\n const reportGenerator = (node: { generator?: boolean }) => {\n if (node.generator) {\n reportDefault(context, node as never);\n }\n };\n\n return {\n FunctionDeclaration: reportGenerator,\n FunctionExpression: reportGenerator,\n };\n },\n});\n","import { defineAppsyncRule } from \"./types.js\";\nimport { reportDefault } from \"./utils.js\";\n\nexport default defineAppsyncRule({\n meta: {\n type: \"problem\",\n docs: {\n description: \"Disallow the in operator in AppSync resolvers\",\n },\n messages: {\n default:\n \"The in operator is not supported in the AppSync JS runtime; use Object.hasOwn instead\",\n },\n schema: [],\n },\n createOnce(context) {\n return {\n BinaryExpression(node) {\n if (node.operator === \"in\") {\n reportDefault(context, node);\n }\n },\n };\n },\n});\n","import { defineAppsyncRule } from \"./types.js\";\nimport { reportDefault } from \"./utils.js\";\n\nexport default defineAppsyncRule({\n meta: {\n type: \"problem\",\n docs: {\n description: \"Disallow the instanceof operator in AppSync resolvers\",\n },\n messages: {\n default: \"The instanceof operator is not supported in the AppSync JS runtime\",\n },\n schema: [],\n },\n createOnce(context) {\n return {\n BinaryExpression(node) {\n if (node.operator === \"instanceof\") {\n reportDefault(context, node);\n }\n },\n };\n },\n});\n","import { defineAppsyncRule } from \"./types.js\";\nimport { reportDefault } from \"./utils.js\";\n\nexport default defineAppsyncRule({\n meta: {\n type: \"problem\",\n docs: {\n description: \"Disallow labeled statements in AppSync resolvers\",\n },\n messages: {\n default: \"Labeled statements are not supported in the AppSync JS runtime\",\n },\n schema: [],\n },\n createOnce(context) {\n return {\n LabeledStatement(node) {\n reportDefault(context, node);\n },\n };\n },\n});\n","import { defineAppsyncRule } from \"./types.js\";\nimport { reportDefault } from \"./utils.js\";\n\nexport default defineAppsyncRule({\n meta: {\n type: \"problem\",\n docs: {\n description: \"Disallow the new operator in AppSync resolvers\",\n },\n messages: {\n default: \"The new operator is not supported in the AppSync JS runtime\",\n },\n schema: [],\n },\n createOnce(context) {\n return {\n NewExpression(node) {\n reportDefault(context, node);\n },\n };\n },\n});\n","import { defineAppsyncRule } from \"./types.js\";\nimport { isIdentifier, reportDefault } from \"./utils.js\";\n\nexport default defineAppsyncRule({\n meta: {\n type: \"problem\",\n docs: {\n description:\n \"Disallow using String() to stringify values in AppSync resolvers\",\n },\n messages: {\n default:\n \"Do not use String() to stringify variables in the AppSync JS runtime\",\n },\n schema: [],\n },\n createOnce(context) {\n return {\n CallExpression(node) {\n if (isIdentifier(node.callee, \"String\")) {\n reportDefault(context, node);\n }\n },\n NewExpression(node) {\n if (isIdentifier(node.callee, \"String\")) {\n reportDefault(context, node);\n }\n },\n };\n },\n});\n","import { defineAppsyncRule } from \"./types.js\";\nimport { reportDefault } from \"./utils.js\";\n\nexport default defineAppsyncRule({\n meta: {\n type: \"problem\",\n docs: {\n description: \"Disallow this expressions in AppSync resolvers\",\n },\n messages: {\n default: \"this is not supported in the AppSync JS runtime\",\n },\n schema: [],\n },\n createOnce(context) {\n return {\n ThisExpression(node) {\n reportDefault(context, node);\n },\n };\n },\n});\n","import { defineAppsyncRule } from \"./types.js\";\nimport { reportDefault } from \"./utils.js\";\n\nexport default defineAppsyncRule({\n meta: {\n type: \"problem\",\n docs: {\n description: \"Disallow throw statements in AppSync resolvers\",\n },\n messages: {\n default: \"throw statements are not supported in the AppSync JS runtime\",\n },\n schema: [],\n },\n createOnce(context) {\n return {\n ThrowStatement(node) {\n reportDefault(context, node);\n },\n };\n },\n});\n","import { defineAppsyncRule } from \"./types.js\";\nimport { reportDefault } from \"./utils.js\";\n\nexport default defineAppsyncRule({\n meta: {\n type: \"problem\",\n docs: {\n description:\n \"Disallow try/catch/finally statements in AppSync resolvers\",\n },\n messages: {\n default:\n \"try/catch/finally statements are not supported in the AppSync JS runtime\",\n },\n schema: [],\n },\n createOnce(context) {\n return {\n TryStatement(node) {\n reportDefault(context, node);\n },\n };\n },\n});\n","import { defineAppsyncRule } from \"./types.js\";\nimport { reportDefault } from \"./utils.js\";\n\nexport default defineAppsyncRule({\n meta: {\n type: \"problem\",\n docs: {\n description: \"Disallow ++ and -- operators in AppSync resolvers\",\n },\n messages: {\n default: \"++ and -- operators are not supported in the AppSync JS runtime\",\n },\n schema: [],\n },\n createOnce(context) {\n return {\n UpdateExpression(node) {\n reportDefault(context, node);\n },\n };\n },\n});\n","import { defineAppsyncRule } from \"./types.js\";\nimport { reportDefault } from \"./utils.js\";\n\nexport default defineAppsyncRule({\n meta: {\n type: \"problem\",\n docs: {\n description: \"Disallow while loops in AppSync resolvers\",\n },\n messages: {\n default: \"while loops are not supported in the AppSync JS runtime\",\n },\n schema: [],\n },\n createOnce(context) {\n return {\n WhileStatement(node) {\n reportDefault(context, node);\n },\n };\n },\n});\n","import noAsyncAwait from \"./no-async-await.js\";\nimport noBitwiseNot from \"./no-bitwise-not.js\";\nimport noClasses from \"./no-classes.js\";\nimport noContinue from \"./no-continue.js\";\nimport noDoWhile from \"./no-do-while.js\";\nimport noForLoop from \"./no-for-loop.js\";\nimport noFunctionArguments from \"./no-function-arguments.js\";\nimport noGenerators from \"./no-generators.js\";\nimport noInOperator from \"./no-in-operator.js\";\nimport noInstanceof from \"./no-instanceof.js\";\nimport noLabeledStatement from \"./no-labeled-statement.js\";\nimport noNew from \"./no-new.js\";\nimport noStringConstructor from \"./no-string-constructor.js\";\nimport noThis from \"./no-this.js\";\nimport noThrow from \"./no-throw.js\";\nimport noTry from \"./no-try.js\";\nimport noUpdateOperators from \"./no-update-operators.js\";\nimport noWhile from \"./no-while.js\";\nimport type { AppsyncRuleModule } from \"./types.js\";\n\nconst rules = {\n \"no-async-await\": noAsyncAwait,\n \"no-bitwise-not\": noBitwiseNot,\n \"no-classes\": noClasses,\n \"no-continue\": noContinue,\n \"no-do-while\": noDoWhile,\n \"no-for-loop\": noForLoop,\n \"no-function-arguments\": noFunctionArguments,\n \"no-generators\": noGenerators,\n \"no-in-operator\": noInOperator,\n \"no-instanceof\": noInstanceof,\n \"no-labeled-statement\": noLabeledStatement,\n \"no-new\": noNew,\n \"no-string-constructor\": noStringConstructor,\n \"no-this\": noThis,\n \"no-throw\": noThrow,\n \"no-try\": noTry,\n \"no-update-operators\": noUpdateOperators,\n \"no-while\": noWhile,\n} satisfies Record<string, AppsyncRuleModule>;\n\nexport type AppsyncRuleName = keyof typeof rules;\n\nexport default rules;\n","import { eslintCompatPlugin } from \"@oxlint/plugins\";\nimport rules from \"./rules/index.js\";\n\nexport const plugin = eslintCompatPlugin({\n meta: {\n name: \"appsync\",\n },\n rules,\n});\n\nexport const recommended = Object.fromEntries(\n Object.keys(rules).map((ruleName) => [`appsync/${ruleName}`, \"error\"]),\n) as Record<`appsync/${keyof typeof rules}`, \"error\">;\n","import { plugin, recommended } from \"./plugin.js\";\n\nexport { plugin, recommended };\nexport default plugin;\n"],"mappings":";;AAOA,SAAgB,kBAAkB,MAA4C;CAC5E,OAAO;AACT;;;ACLA,SAAgB,aACd,MACA,MACS;CACT,OAAO,MAAM,SAAS,gBAAiB,KAA0B,SAAS;AAC5E;AAEA,SAAgB,cACd,SACA,MACA,YAAY,WACN;CACN,QAAQ,OAAO;EAAE;EAAM;CAAU,CAAC;AACpC;;;ACdA,IAAA,yBAAe,kBAAkB;CAC/B,MAAM;EACJ,MAAM;EACN,MAAM,EACJ,aACE,sEACJ;EACA,UAAU,EACR,SACE,uEACJ;EACA,QAAQ,CAAC;CACX;CACA,WAAW,SA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AAe"}
package/package.json ADDED
@@ -0,0 +1,63 @@
1
+ {
2
+ "name": "oxlint-appsync",
3
+ "version": "0.1.0",
4
+ "description": "Oxlint plugin that enforces AWS AppSync JavaScript runtime restrictions",
5
+ "type": "module",
6
+ "license": "MIT",
7
+ "author": "",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/temporal-orbit/oxlint-appsync.git"
11
+ },
12
+ "keywords": [
13
+ "oxlint",
14
+ "eslint",
15
+ "appsync",
16
+ "aws",
17
+ "graphql",
18
+ "linter"
19
+ ],
20
+ "files": [
21
+ "dist"
22
+ ],
23
+ "main": "./dist/index.js",
24
+ "module": "./dist/index.js",
25
+ "types": "./dist/index.d.ts",
26
+ "exports": {
27
+ ".": {
28
+ "types": "./dist/index.d.ts",
29
+ "import": "./dist/index.js"
30
+ }
31
+ },
32
+ "scripts": {
33
+ "build": "tsdown",
34
+ "prepublishOnly": "npm test",
35
+ "test": "npm run build && vitest run",
36
+ "test:unit": "vitest run tests/rules",
37
+ "lint": "oxlint src tests/helpers tests/smoke.test.ts vitest.config.ts tsdown.config.ts"
38
+ },
39
+ "dependencies": {
40
+ "@oxlint/plugins": "^1.42.0"
41
+ },
42
+ "peerDependencies": {
43
+ "eslint": ">=8.0.0",
44
+ "oxlint": ">=1.0.0"
45
+ },
46
+ "peerDependenciesMeta": {
47
+ "eslint": {
48
+ "optional": true
49
+ },
50
+ "oxlint": {
51
+ "optional": true
52
+ }
53
+ },
54
+ "devDependencies": {
55
+ "@types/eslint": "^9.6.1",
56
+ "@types/node": "^22.15.21",
57
+ "eslint": "^9.27.0",
58
+ "oxlint": "^1.42.0",
59
+ "tsdown": "^0.12.9",
60
+ "typescript": "^5.8.3",
61
+ "vitest": "^3.2.1"
62
+ }
63
+ }