eslint-plugin-graphile-export 1.0.0-rc.2 → 1.0.0-rc.4

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/CHANGELOG.md CHANGED
@@ -1,5 +1,28 @@
1
1
  # eslint-plugin-graphile-export
2
2
 
3
+ ## 1.0.0-rc.4
4
+
5
+ ### Patch Changes
6
+
7
+ - [`a3722d6`](https://github.com/graphile/crystal/commit/a3722d613bc6fb9e32f167aae9a31eaa422ceef1)
8
+ Thanks [@benjie](https://github.com/benjie)! - Refactor to enable TypeScript
9
+ options rewriteRelativeImportExtensions and erasableSyntaxOnly (including
10
+ using .ts extensions in source code)
11
+
12
+ ## 1.0.0-rc.3
13
+
14
+ ### Patch Changes
15
+
16
+ - [#2873](https://github.com/graphile/crystal/pull/2873)
17
+ [`0772086`](https://github.com/graphile/crystal/commit/0772086411a55d56b4e345cff1eef133eee31b36)
18
+ Thanks [@benjie](https://github.com/benjie)! - Update TypeScript configuration
19
+ to support Node 22 minimum
20
+
21
+ - [#2888](https://github.com/graphile/crystal/pull/2888)
22
+ [`1a56db2`](https://github.com/graphile/crystal/commit/1a56db2f53bc455a3d3ba6555a2cd777b27b271c)
23
+ Thanks [@benjaie](https://github.com/benjaie)! - Node v22+ is required for
24
+ this module.
25
+
3
26
  ## 1.0.0-rc.2
4
27
 
5
28
  ### Patch Changes
@@ -5,8 +5,8 @@
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.ExhaustiveDeps = void 0;
8
- const common_js_1 = require("./common.js");
9
- const utils_js_1 = require("./utils.js");
8
+ const common_ts_1 = require("./common.js");
9
+ const utils_ts_1 = require("./utils.js");
10
10
  function gatherDependenciesRecursively(dependencies, node, currentScope, monitoredScopes, rootNode) {
11
11
  for (const reference of currentScope.references) {
12
12
  // If this reference is not resolved or it is not declared in a pure
@@ -21,7 +21,7 @@ function gatherDependenciesRecursively(dependencies, node, currentScope, monitor
21
21
  }
22
22
  // Narrow the scope of a dependency if it is, say, a member expression.
23
23
  // Then normalize the narrowed dependency.
24
- const referenceNode = (0, common_js_1.fastFindReferenceWithParent)(node, reference.identifier);
24
+ const referenceNode = (0, common_ts_1.fastFindReferenceWithParent)(node, reference.identifier);
25
25
  if (!referenceNode) {
26
26
  console.warn("Could not find referenceNode");
27
27
  continue;
@@ -136,7 +136,7 @@ exports.ExhaustiveDeps = {
136
136
  return;
137
137
  }
138
138
  externalAssigns.add(key);
139
- (0, common_js_1.reportProblem)(context, options, {
139
+ (0, common_ts_1.reportProblem)(context, options, {
140
140
  node: writeExpr,
141
141
  message: `Assignments to the '${key}' variable from inside ` +
142
142
  `${context.sourceCode.getText(fnCall)} cannot be safely exported.`,
@@ -153,7 +153,7 @@ exports.ExhaustiveDeps = {
153
153
  const argNames = [];
154
154
  const invalid = node.params.some((arg) => {
155
155
  if (arg.type !== "Identifier") {
156
- (0, common_js_1.reportProblem)(context, options, {
156
+ (0, common_ts_1.reportProblem)(context, options, {
157
157
  node: arg,
158
158
  message: `${context.sourceCode.getText(fnCall)} has an argument which isn't a plain identifier, we don't support this currently.`,
159
159
  });
@@ -171,7 +171,7 @@ exports.ExhaustiveDeps = {
171
171
  // If the declared dependencies is not an object expression then we
172
172
  // can't verify that the user provided the correct dependencies. Tell
173
173
  // the user this in an error.
174
- (0, common_js_1.reportProblem)(context, options, {
174
+ (0, common_ts_1.reportProblem)(context, options, {
175
175
  node: declaredDependenciesNode,
176
176
  message: `${context.sourceCode.getText(fnCall)} was passed a ` +
177
177
  "dependency map that is not an array. This means we " +
@@ -187,7 +187,7 @@ exports.ExhaustiveDeps = {
187
187
  }
188
188
  // If we see a spread element then add a special warning.
189
189
  if (declaredDependencyNode.type === "SpreadElement") {
190
- (0, common_js_1.reportProblem)(context, options, {
190
+ (0, common_ts_1.reportProblem)(context, options, {
191
191
  node: declaredDependencyNode,
192
192
  message: `${context.sourceCode.getText(fnCall)} has a spread element ` +
193
193
  "in its dependency map. This means we can't " +
@@ -204,7 +204,7 @@ exports.ExhaustiveDeps = {
204
204
  });
205
205
  });
206
206
  if (node.params.length !== declaredDependenciesNode.elements.length) {
207
- (0, common_js_1.reportProblem)(context, options, {
207
+ (0, common_ts_1.reportProblem)(context, options, {
208
208
  node: declaredDependenciesNode,
209
209
  message: `${context.sourceCode.getText(fnCall)} has different arguments count (${node.params.length}) versus dependencies count (${declaredDependenciesNode.elements.length}); this is invalid.`,
210
210
  });
@@ -229,7 +229,7 @@ exports.ExhaustiveDeps = {
229
229
  (isSorted || !options.sortExports)) {
230
230
  return;
231
231
  }
232
- (0, common_js_1.reportProblem)(context, options, {
232
+ (0, common_ts_1.reportProblem)(context, options, {
233
233
  node: declaredDependenciesNode,
234
234
  message: `${context.sourceCode.getText(fnCall)} has ` +
235
235
  // To avoid a long message, show the next actionable item.
@@ -300,14 +300,14 @@ exports.ExhaustiveDeps = {
300
300
  const declaredDependenciesNode = node.arguments[callbackIndex + 1];
301
301
  // Check whether a callback is supplied.
302
302
  if (!callback) {
303
- (0, common_js_1.reportProblem)(context, options, {
303
+ (0, common_ts_1.reportProblem)(context, options, {
304
304
  node: fnCall,
305
305
  message: `EXPORTABLE must wrap a function.`,
306
306
  });
307
307
  return;
308
308
  }
309
309
  if (!declaredDependenciesNode) {
310
- (0, common_js_1.reportProblem)(context, options, {
310
+ (0, common_ts_1.reportProblem)(context, options, {
311
311
  node: fnCall,
312
312
  message: `EXPORTABLE does nothing when called with ` +
313
313
  `only one argument. Did you forget to pass an array of ` +
@@ -335,7 +335,7 @@ exports.ExhaustiveDeps = {
335
335
  return; // Handled
336
336
  case "Identifier":
337
337
  default:
338
- (0, common_js_1.reportProblem)(context, options, {
338
+ (0, common_ts_1.reportProblem)(context, options, {
339
339
  node: fnCall,
340
340
  message: `EXPORTABLE received a function whose dependencies ` +
341
341
  `are unknown. Pass an inline function instead.`,
@@ -533,7 +533,7 @@ function analyzePropertyChain(node) {
533
533
  * Returns 0 if this is a EXPORTABLE call, -1 otherwise.
534
534
  */
535
535
  function getScopesCallbackIndex(node) {
536
- if ((0, utils_js_1.isExportableCall)(node)) {
536
+ if ((0, utils_ts_1.isExportableCall)(node)) {
537
537
  return 0;
538
538
  }
539
539
  else {
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ExportInstances = void 0;
4
- const common_js_1 = require("./common.js");
5
- const NoNested_js_1 = require("./NoNested.js");
4
+ const common_ts_1 = require("./common.js");
5
+ const NoNested_ts_1 = require("./NoNested.js");
6
6
  const KNOWN_IMPORTS = [
7
7
  ["@dataplan/pg", "PgResource"],
8
8
  ["@dataplan/pg", "PgExecutor"],
@@ -53,9 +53,9 @@ exports.ExportInstances = {
53
53
  }
54
54
  // TODO: determine if the definition for this `callee` identifier is an import from any of these `possibles` (and if not, `return;`).
55
55
  //const scope = scopeManager.acquire(node);
56
- if ((0, NoNested_js_1.hasExportableParent)(node))
56
+ if ((0, NoNested_ts_1.hasExportableParent)(node))
57
57
  return;
58
- (0, common_js_1.reportProblem)(context, options, {
58
+ (0, common_ts_1.reportProblem)(context, options, {
59
59
  node: node,
60
60
  message: `${node.type === "NewExpression" ? "Construction" : "Call"} of '${constructorName}' without EXPORTABLE.`,
61
61
  suggest: [
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ExportMethods = void 0;
4
- const common_js_1 = require("./common.js");
5
- const NoNested_js_1 = require("./NoNested.js");
4
+ const common_ts_1 = require("./common.js");
5
+ const NoNested_ts_1 = require("./NoNested.js");
6
6
  const dev = process.env.GRAPHILE_ENV === "development";
7
7
  /**
8
8
  * So we don't reach too wide we only want to match objects that look like
@@ -117,12 +117,12 @@ function processNode(context, options, node, match) {
117
117
  const disallowedSiblingKeys = parentObjectKeys.filter((key) => key == null ||
118
118
  (!ALLOWED_SIBLING_KEYS.includes(key) && !options.methods.includes(key)));
119
119
  if (disallowedSiblingKeys.length === 0) {
120
- if ((0, NoNested_js_1.hasExportableParent)(node))
120
+ if ((0, NoNested_ts_1.hasExportableParent)(node))
121
121
  return;
122
122
  // Match
123
123
  if (node.type === "ObjectMethod") {
124
124
  // replace with property -> EXPORTABLE
125
- (0, common_js_1.reportProblem)(context, options, {
125
+ (0, common_ts_1.reportProblem)(context, options, {
126
126
  node: node,
127
127
  message: "is not exportable.",
128
128
  // TODO: implement the suggestion
@@ -144,7 +144,7 @@ function processNode(context, options, node, match) {
144
144
  (value.type === "FunctionExpression" ||
145
145
  value.type === "ArrowFunctionExpression")) {
146
146
  // Wrap with EXPORTABLE
147
- (0, common_js_1.reportProblem)(context, options, {
147
+ (0, common_ts_1.reportProblem)(context, options, {
148
148
  node: node,
149
149
  message: "Step value is not exportable.",
150
150
  suggest: [
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ExportPlans = void 0;
4
- const common_js_1 = require("./common.js");
5
- const NoNested_js_1 = require("./NoNested.js");
4
+ const common_ts_1 = require("./common.js");
5
+ const NoNested_ts_1 = require("./NoNested.js");
6
6
  /**
7
7
  * So we don't reach too wide we only want to match objects that look like
8
8
  * they're probably plan configurations. For now this is the GraphQLFieldConfig
@@ -58,12 +58,12 @@ exports.ExportPlans = {
58
58
  },
59
59
  };
60
60
  function processNode(context, options, node) {
61
- if ((0, NoNested_js_1.hasExportableParent)(node))
61
+ if ((0, NoNested_ts_1.hasExportableParent)(node))
62
62
  return;
63
63
  // Match
64
64
  if (node.type === "ObjectMethod") {
65
65
  // replace with property -> EXPORTABLE
66
- (0, common_js_1.reportProblem)(context, options, {
66
+ (0, common_ts_1.reportProblem)(context, options, {
67
67
  node: node,
68
68
  message: "is not exportable.",
69
69
  // TODO: implement the suggestion
@@ -85,7 +85,7 @@ function processNode(context, options, node) {
85
85
  (value.type === "FunctionExpression" ||
86
86
  value.type === "ArrowFunctionExpression")) {
87
87
  // Wrap with EXPORTABLE
88
- (0, common_js_1.reportProblem)(context, options, {
88
+ (0, common_ts_1.reportProblem)(context, options, {
89
89
  node: node,
90
90
  message: "Step value is not exportable.",
91
91
  suggest: [
@@ -2,8 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ExportSubclasses = void 0;
4
4
  const path_1 = require("path");
5
- const common_js_1 = require("./common.js");
6
- const NoNested_js_1 = require("./NoNested.js");
5
+ const common_ts_1 = require("./common.js");
6
+ const NoNested_ts_1 = require("./NoNested.js");
7
7
  const KNOWN_IMPORTS = [
8
8
  ["grafast", "Step"],
9
9
  ["grafast", "Modifier"],
@@ -55,7 +55,7 @@ exports.ExportSubclasses = {
55
55
  if (!className) {
56
56
  return;
57
57
  }
58
- if ((0, NoNested_js_1.hasExportableParent)(node))
58
+ if ((0, NoNested_ts_1.hasExportableParent)(node))
59
59
  return;
60
60
  // ENHANCE: if the definition for the `superClass` identifier is not actually an import from any of these `possibles` then we should `return;`. It just happens to share the same name?
61
61
  //const scope = scopeManager.acquire(node);
@@ -67,7 +67,7 @@ exports.ExportSubclasses = {
67
67
  def.key.name === "$$export");
68
68
  if ($$export) {
69
69
  if (!$$export.static) {
70
- (0, common_js_1.reportProblem)(context, options, {
70
+ (0, common_ts_1.reportProblem)(context, options, {
71
71
  node: $$export,
72
72
  message: `$$export should be a static property; this is probably a mistake?`,
73
73
  suggest: [
@@ -94,13 +94,13 @@ exports.ExportSubclasses = {
94
94
  const safe = !$$export.value.properties.some((prop) => prop.type === "SpreadElement") &&
95
95
  !$$export.value.properties.some((prop) => prop.type === "Property" && prop.key.type !== "Identifier");
96
96
  if (safe && !moduleName) {
97
- (0, common_js_1.reportProblem)(context, options, {
97
+ (0, common_ts_1.reportProblem)(context, options, {
98
98
  node: $$export,
99
99
  message: `$$export specifier doesn't explicitly specify 'moduleName'`,
100
100
  });
101
101
  }
102
102
  if (safe && !exportName) {
103
- (0, common_js_1.reportProblem)(context, options, {
103
+ (0, common_ts_1.reportProblem)(context, options, {
104
104
  node: $$export,
105
105
  message: `$$export specifier doesn't explicitly specify 'exportName'`,
106
106
  });
@@ -109,14 +109,14 @@ exports.ExportSubclasses = {
109
109
  if (!moduleName.value ||
110
110
  !["StringLiteral", "Literal"].includes(moduleName.value.type)) {
111
111
  console.dir(moduleName.value);
112
- (0, common_js_1.reportProblem)(context, options, {
112
+ (0, common_ts_1.reportProblem)(context, options, {
113
113
  node: $$export,
114
114
  message: `$$export has invalid value for 'moduleName' - expected a string literal.`,
115
115
  });
116
116
  }
117
117
  if (!exportName.value ||
118
118
  !["StringLiteral", "Literal"].includes(exportName.value.type)) {
119
- (0, common_js_1.reportProblem)(context, options, {
119
+ (0, common_ts_1.reportProblem)(context, options, {
120
120
  node: $$export,
121
121
  message: `$$export has invalid value for 'exportName' - expected a string literal.`,
122
122
  });
@@ -150,14 +150,14 @@ exports.ExportSubclasses = {
150
150
  };
151
151
  const exportExample = `static $$export = { moduleName: /* TODO */ ".../path/to/module.js", exportName: "${className}" }`;
152
152
  if (isGeneric) {
153
- (0, common_js_1.reportProblem)(context, options, {
153
+ (0, common_ts_1.reportProblem)(context, options, {
154
154
  node: node,
155
155
  message: `Generic class '${className}' extending '${superClassIdentifier}' cannot be safely exported. Because it's generic we cannot make it EXPORTABLE, instead make it importable by putting it in its own module and declaring a '${exportExample}' property.`,
156
156
  suggest: [convertToImportable],
157
157
  });
158
158
  }
159
159
  else {
160
- (0, common_js_1.reportProblem)(context, options, {
160
+ (0, common_ts_1.reportProblem)(context, options, {
161
161
  node: node,
162
162
  message: `Class '${className}' extends '${superClassIdentifier}' but cannot be safely exported. Either make it EXPORTABLE or make it importable and add a '${exportExample}' property to indicate this.`,
163
163
  suggest: [convertToExportable, convertToImportable],
package/dist/NoNested.js CHANGED
@@ -2,8 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.NoNested = void 0;
4
4
  exports.hasExportableParent = hasExportableParent;
5
- const common_js_1 = require("./common.js");
6
- const utils_js_1 = require("./utils.js");
5
+ const common_ts_1 = require("./common.js");
6
+ const utils_ts_1 = require("./utils.js");
7
7
  exports.NoNested = {
8
8
  meta: {
9
9
  type: "suggestion",
@@ -40,12 +40,12 @@ exports.NoNested = {
40
40
  };
41
41
  return {
42
42
  CallExpression(node) {
43
- if ((0, utils_js_1.isExportableCall)(node)) {
43
+ if ((0, utils_ts_1.isExportableCall)(node)) {
44
44
  if (hasExportableParent(node)) {
45
45
  const callback = node.arguments[0];
46
46
  if (callback.type === "ArrowFunctionExpression") {
47
47
  const body = callback.body;
48
- (0, common_js_1.reportProblem)(context, options, {
48
+ (0, common_ts_1.reportProblem)(context, options, {
49
49
  node: node,
50
50
  message: "Nested EXPORTABLE found",
51
51
  suggest: [
@@ -70,7 +70,7 @@ exports.NoNested = {
70
70
  function hasExportableParent(node) {
71
71
  let parent = node;
72
72
  while ((parent = parent.parent)) {
73
- if ((0, utils_js_1.isExportableCall)(parent)) {
73
+ if ((0, utils_ts_1.isExportableCall)(parent)) {
74
74
  return true;
75
75
  }
76
76
  }
package/dist/index.js CHANGED
@@ -2,12 +2,12 @@
2
2
  // Inspired by eslint-plugin-react-hooks
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.rules = exports.meta = exports.configs = void 0;
5
- const ExhaustiveDeps_js_1 = require("./ExhaustiveDeps.js");
6
- const ExportInstances_js_1 = require("./ExportInstances.js");
7
- const ExportMethods_js_1 = require("./ExportMethods.js");
8
- const ExportPlans_js_1 = require("./ExportPlans.js");
9
- const ExportSubclasses_js_1 = require("./ExportSubclasses.js");
10
- const NoNested_js_1 = require("./NoNested.js");
5
+ const ExhaustiveDeps_ts_1 = require("./ExhaustiveDeps.js");
6
+ const ExportInstances_ts_1 = require("./ExportInstances.js");
7
+ const ExportMethods_ts_1 = require("./ExportMethods.js");
8
+ const ExportPlans_ts_1 = require("./ExportPlans.js");
9
+ const ExportSubclasses_ts_1 = require("./ExportSubclasses.js");
10
+ const NoNested_ts_1 = require("./NoNested.js");
11
11
  exports.configs = {
12
12
  recommended: {
13
13
  name: "graphile-export/recommended",
@@ -79,12 +79,12 @@ exports.meta = {
79
79
  name: "eslint-plugin-graphile-export",
80
80
  };
81
81
  exports.rules = {
82
- "exhaustive-deps": ExhaustiveDeps_js_1.ExhaustiveDeps,
83
- "export-methods": ExportMethods_js_1.ExportMethods,
84
- "export-instances": ExportInstances_js_1.ExportInstances,
85
- "export-plans": ExportPlans_js_1.ExportPlans,
86
- "export-subclasses": ExportSubclasses_js_1.ExportSubclasses,
87
- "no-nested": NoNested_js_1.NoNested,
82
+ "exhaustive-deps": ExhaustiveDeps_ts_1.ExhaustiveDeps,
83
+ "export-methods": ExportMethods_ts_1.ExportMethods,
84
+ "export-instances": ExportInstances_ts_1.ExportInstances,
85
+ "export-plans": ExportPlans_ts_1.ExportPlans,
86
+ "export-subclasses": ExportSubclasses_ts_1.ExportSubclasses,
87
+ "no-nested": NoNested_ts_1.NoNested,
88
88
  };
89
89
  const plugin = {
90
90
  configs: exports.configs,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-graphile-export",
3
- "version": "1.0.0-rc.2",
3
+ "version": "1.0.0-rc.4",
4
4
  "description": "ESLint plugin to help ensure your schema is exportable by graphile-export",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -28,7 +28,7 @@
28
28
  "tslib": "^2.8.1"
29
29
  },
30
30
  "engines": {
31
- "node": ">=16"
31
+ "node": ">=22"
32
32
  },
33
33
  "peerDependencies": {
34
34
  "eslint": "^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0-0 || ^9.26.0"