eslint-plugin-graphile-export 0.0.2-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.
- package/CHANGELOG.md +9 -0
- package/LICENSE.md +20 -0
- package/README.md +69 -0
- package/dist/ExhaustiveDeps.d.ts +3 -0
- package/dist/ExhaustiveDeps.d.ts.map +1 -0
- package/dist/ExhaustiveDeps.js +561 -0
- package/dist/ExhaustiveDeps.js.map +1 -0
- package/dist/ExportInstances.d.ts +3 -0
- package/dist/ExportInstances.d.ts.map +1 -0
- package/dist/ExportInstances.js +84 -0
- package/dist/ExportInstances.js.map +1 -0
- package/dist/ExportMethods.d.ts +3 -0
- package/dist/ExportMethods.d.ts.map +1 -0
- package/dist/ExportMethods.js +183 -0
- package/dist/ExportMethods.js.map +1 -0
- package/dist/ExportSubclasses.d.ts +3 -0
- package/dist/ExportSubclasses.d.ts.map +1 -0
- package/dist/ExportSubclasses.js +171 -0
- package/dist/ExportSubclasses.js.map +1 -0
- package/dist/NoNested.d.ts +4 -0
- package/dist/NoNested.d.ts.map +1 -0
- package/dist/NoNested.js +83 -0
- package/dist/NoNested.js.map +1 -0
- package/dist/common.d.ts +28 -0
- package/dist/common.d.ts.map +1 -0
- package/dist/common.js +78 -0
- package/dist/common.js.map +1 -0
- package/dist/index.d.ts +32 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +66 -0
- package/dist/index.js.map +1 -0
- package/package.json +48 -0
package/dist/common.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { Expression, Node } from "@babel/types";
|
|
2
|
+
import type { Rule } from "eslint";
|
|
3
|
+
import type { Expression as ESTreeExpression } from "estree";
|
|
4
|
+
declare module "eslint" {
|
|
5
|
+
namespace Rule {
|
|
6
|
+
interface RuleMetaData {
|
|
7
|
+
hasSuggestions: boolean;
|
|
8
|
+
}
|
|
9
|
+
interface RuleContext {
|
|
10
|
+
getSource(node: Expression | ESTreeExpression): string;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export declare function reportProblem(context: Rule.RuleContext, options: {
|
|
15
|
+
disableAutofix: boolean;
|
|
16
|
+
}, problem: Rule.ReportDescriptor): void;
|
|
17
|
+
/**
|
|
18
|
+
* ESLint won't assign node.parent to references from context.getScope()
|
|
19
|
+
*
|
|
20
|
+
* So instead we search for the node from an ancestor assigning node.parent
|
|
21
|
+
* as we go. This mutates the AST.
|
|
22
|
+
*
|
|
23
|
+
* This traversal is:
|
|
24
|
+
* - optimized by only searching nodes with a range surrounding our target node
|
|
25
|
+
* - agnostic to AST node types, it looks for `{ type: string, ... }`
|
|
26
|
+
*/
|
|
27
|
+
export declare function fastFindReferenceWithParent(start: Node & Rule.NodeParentExtension, target: Node): (Node & Rule.NodeParentExtension) | null;
|
|
28
|
+
//# sourceMappingURL=common.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../src/common.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AACnC,OAAO,KAAK,EAAE,UAAU,IAAI,gBAAgB,EAAE,MAAM,QAAQ,CAAC;AAE7D,OAAO,QAAQ,QAAQ,CAAC;IACtB,UAAU,IAAI,CAAC;QACb,UAAU,YAAY;YACpB,cAAc,EAAE,OAAO,CAAC;SACzB;QACD,UAAU,WAAW;YACnB,SAAS,CAAC,IAAI,EAAE,UAAU,GAAG,gBAAgB,GAAG,MAAM,CAAC;SACxD;KACF;CACF;AAED,wBAAgB,aAAa,CAC3B,OAAO,EAAE,IAAI,CAAC,WAAW,EACzB,OAAO,EAAE;IAAE,cAAc,EAAE,OAAO,CAAA;CAAE,EACpC,OAAO,EAAE,IAAI,CAAC,gBAAgB,QAU/B;AAED;;;;;;;;;GASG;AACH,wBAAgB,2BAA2B,CACzC,KAAK,EAAE,IAAI,GAAG,IAAI,CAAC,mBAAmB,EACtC,MAAM,EAAE,IAAI,4CAwCb"}
|
package/dist/common.js
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.fastFindReferenceWithParent = exports.reportProblem = void 0;
|
|
4
|
+
function reportProblem(context, options, problem) {
|
|
5
|
+
if (options.disableAutofix !== true) {
|
|
6
|
+
// Used to enable legacy behavior. Dangerous.
|
|
7
|
+
// Keep this as an option until major IDEs upgrade (including VSCode FB ESLint extension).
|
|
8
|
+
if (Array.isArray(problem.suggest) && problem.suggest.length > 0) {
|
|
9
|
+
problem.fix = problem.suggest[0].fix;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
context.report(problem);
|
|
13
|
+
}
|
|
14
|
+
exports.reportProblem = reportProblem;
|
|
15
|
+
/**
|
|
16
|
+
* ESLint won't assign node.parent to references from context.getScope()
|
|
17
|
+
*
|
|
18
|
+
* So instead we search for the node from an ancestor assigning node.parent
|
|
19
|
+
* as we go. This mutates the AST.
|
|
20
|
+
*
|
|
21
|
+
* This traversal is:
|
|
22
|
+
* - optimized by only searching nodes with a range surrounding our target node
|
|
23
|
+
* - agnostic to AST node types, it looks for `{ type: string, ... }`
|
|
24
|
+
*/
|
|
25
|
+
function fastFindReferenceWithParent(start, target) {
|
|
26
|
+
const queue = [start];
|
|
27
|
+
let item = null;
|
|
28
|
+
while (queue.length) {
|
|
29
|
+
item = queue.shift();
|
|
30
|
+
const definitelyItem = item;
|
|
31
|
+
if (isSameIdentifier(definitelyItem, target)) {
|
|
32
|
+
return definitelyItem;
|
|
33
|
+
}
|
|
34
|
+
if (!isAncestorNodeOf(definitelyItem, target)) {
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
for (const [key, value] of Object.entries(definitelyItem)) {
|
|
38
|
+
if (key === "parent") {
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
if (isNodeLike(value)) {
|
|
42
|
+
const valueWithParent = Object.assign(value, {
|
|
43
|
+
parent: definitelyItem,
|
|
44
|
+
});
|
|
45
|
+
queue.push(valueWithParent);
|
|
46
|
+
}
|
|
47
|
+
else if (Array.isArray(value)) {
|
|
48
|
+
value.forEach((val) => {
|
|
49
|
+
if (isNodeLike(val)) {
|
|
50
|
+
const valWithParent = Object.assign(val, {
|
|
51
|
+
parent: definitelyItem,
|
|
52
|
+
});
|
|
53
|
+
queue.push(valWithParent);
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
exports.fastFindReferenceWithParent = fastFindReferenceWithParent;
|
|
62
|
+
function isSameIdentifier(a, b) {
|
|
63
|
+
return ((a.type === "Identifier" || a.type === "JSXIdentifier") &&
|
|
64
|
+
a.type === b.type &&
|
|
65
|
+
a.name === b.name &&
|
|
66
|
+
a.range[0] === b.range[0] &&
|
|
67
|
+
a.range[1] === b.range[1]);
|
|
68
|
+
}
|
|
69
|
+
function isNodeLike(val) {
|
|
70
|
+
return (typeof val === "object" &&
|
|
71
|
+
val !== null &&
|
|
72
|
+
!Array.isArray(val) &&
|
|
73
|
+
typeof val.type === "string");
|
|
74
|
+
}
|
|
75
|
+
function isAncestorNodeOf(a, b) {
|
|
76
|
+
return a.range[0] <= b.range[0] && a.range[1] >= b.range[1];
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=common.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common.js","sourceRoot":"","sources":["../src/common.ts"],"names":[],"mappings":";;;AAeA,SAAgB,aAAa,CAC3B,OAAyB,EACzB,OAAoC,EACpC,OAA8B;IAE9B,IAAI,OAAO,CAAC,cAAc,KAAK,IAAI,EAAE;QACnC,6CAA6C;QAC7C,0FAA0F;QAC1F,IAAI,KAAK,C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4
|
+
rules: {
|
|
5
|
+
"graphile-export/exhaustive-deps": (string | {
|
|
6
|
+
disableAutofix: boolean;
|
|
7
|
+
sortExports: boolean;
|
|
8
|
+
})[];
|
|
9
|
+
"graphile-export/export-methods": (string | {
|
|
10
|
+
disableAutofix: boolean;
|
|
11
|
+
methods: string[];
|
|
12
|
+
})[];
|
|
13
|
+
"graphile-export/export-instances": (string | {
|
|
14
|
+
disableAutofix: boolean;
|
|
15
|
+
})[];
|
|
16
|
+
"graphile-export/export-subclasses": (string | {
|
|
17
|
+
disableAutofix: boolean;
|
|
18
|
+
})[];
|
|
19
|
+
"graphile-export/no-nested": (string | {
|
|
20
|
+
disableAutofix: boolean;
|
|
21
|
+
})[];
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
export declare const rules: {
|
|
26
|
+
"exhaustive-deps": import("eslint").Rule.RuleModule;
|
|
27
|
+
"export-methods": import("eslint").Rule.RuleModule;
|
|
28
|
+
"export-instances": import("eslint").Rule.RuleModule;
|
|
29
|
+
"export-subclasses": import("eslint").Rule.RuleModule;
|
|
30
|
+
"no-nested": import("eslint").Rule.RuleModule;
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;;CAgDnB,CAAC;AAEF,eAAO,MAAM,KAAK;;;;;;CAMjB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Inspired by babel-plugin-react-hooks
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.rules = 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 ExportSubclasses_js_1 = require("./ExportSubclasses.js");
|
|
9
|
+
const NoNested_js_1 = require("./NoNested.js");
|
|
10
|
+
exports.configs = {
|
|
11
|
+
recommended: {
|
|
12
|
+
plugins: ["graphile-export"],
|
|
13
|
+
rules: {
|
|
14
|
+
"graphile-export/exhaustive-deps": [
|
|
15
|
+
"error",
|
|
16
|
+
{
|
|
17
|
+
disableAutofix: false,
|
|
18
|
+
sortExports: true,
|
|
19
|
+
},
|
|
20
|
+
],
|
|
21
|
+
"graphile-export/export-methods": [
|
|
22
|
+
"error",
|
|
23
|
+
{
|
|
24
|
+
disableAutofix: false,
|
|
25
|
+
methods: [
|
|
26
|
+
"resolve",
|
|
27
|
+
"subscribe",
|
|
28
|
+
"plan",
|
|
29
|
+
"subscribePlan",
|
|
30
|
+
"isTypeOf",
|
|
31
|
+
"resolveType",
|
|
32
|
+
"serialize",
|
|
33
|
+
"parseValue",
|
|
34
|
+
"parseLiteral",
|
|
35
|
+
],
|
|
36
|
+
},
|
|
37
|
+
],
|
|
38
|
+
"graphile-export/export-instances": [
|
|
39
|
+
"error",
|
|
40
|
+
{
|
|
41
|
+
disableAutofix: false,
|
|
42
|
+
},
|
|
43
|
+
],
|
|
44
|
+
"graphile-export/export-subclasses": [
|
|
45
|
+
"error",
|
|
46
|
+
{
|
|
47
|
+
disableAutofix: false,
|
|
48
|
+
},
|
|
49
|
+
],
|
|
50
|
+
"graphile-export/no-nested": [
|
|
51
|
+
"error",
|
|
52
|
+
{
|
|
53
|
+
disableAutofix: false,
|
|
54
|
+
},
|
|
55
|
+
],
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
exports.rules = {
|
|
60
|
+
"exhaustive-deps": ExhaustiveDeps_js_1.ExhaustiveDeps,
|
|
61
|
+
"export-methods": ExportMethods_js_1.ExportMethods,
|
|
62
|
+
"export-instances": ExportInstances_js_1.ExportInstances,
|
|
63
|
+
"export-subclasses": ExportSubclasses_js_1.ExportSubclasses,
|
|
64
|
+
"no-nested": NoNested_js_1.NoNested,
|
|
65
|
+
};
|
|
66
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,uCAAuC;;;AAEvC,2DAAqD;AACrD,6DAAuD;AACvD,yDAAmD;AACnD,+DAAyD;AACzD,+CAAyC;AAE5B,QAAA,OAAO,GAAG;IACrB,WAAW,EAAE;QACX,OAAO,EAAE,CAAC,iBAAiB,CAAC;QAC5B,KAAK,EAAE;YACL,iCAAiC,EAAE;gBACjC,OAAO;gBACP;oBACE,cAAc,EAAE,KAAK;oBACrB,WAAW,EAAE,IAAI;iBAClB;aACF;YACD,gCAAgC,EAAE;gBAChC,OAAO;gBACP;oBACE,cAAc,EAAE,KAAK;oBACrB,OAAO,EAAE;wBACP,SAAS;wBACT,WAAW;wBACX,MAAM;wBACN,eAAe;wBACf,UAAU;wBACV,aAAa;wBACb,WAAW;wBACX,YAAY;wBACZ,cAAc;qBACf;iBACF;aACF;YACD,kCAAkC,EAAE;gBAClC,OAAO;gBACP;oBACE,cAAc,EAAE,KAAK;iBACtB;aACF;YACD,mCAAmC,EAAE;gBACnC,OAAO;gBACP;oBACE,cAAc,EAAE,KAAK;iBACtB;aACF;YACD,2BAA2B,EAAE;gBAC3B,OAAO;gBACP;oBACE,cAAc,EAAE,KAAK;iBACtB;aACF;SACF;KACF;CACF,CAAC;AAEW,QAAA,KAAK,GAAG;IACnB,iBAAiB,EAAE,kCAAc;IACjC,gBAAgB,EAAE,gCAAa;IAC/B,kBAAkB,EAAE,oCAAe;IACnC,mBAAmB,EAAE,sCAAgB;IACrC,WAAW,EAAE,sBAAQ;CACtB,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "eslint-plugin-graphile-export",
|
|
3
|
+
"version": "0.0.2-0.0",
|
|
4
|
+
"description": "ESLint plugin to help ensure your schema is exportable by graphile-export",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"prepack": "tsc -b"
|
|
9
|
+
},
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "git+https://github.com/graphile/heart.git"
|
|
13
|
+
},
|
|
14
|
+
"keywords": [
|
|
15
|
+
"eslint-plugin",
|
|
16
|
+
"graphile",
|
|
17
|
+
"exporter",
|
|
18
|
+
"schema",
|
|
19
|
+
"graphite"
|
|
20
|
+
],
|
|
21
|
+
"author": "Benjie Gillam <code@benjiegillam.com>",
|
|
22
|
+
"license": "MIT",
|
|
23
|
+
"bugs": {
|
|
24
|
+
"url": "https://github.com/graphile/heart/issues"
|
|
25
|
+
},
|
|
26
|
+
"homepage": "https://graphile.org/",
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"tslib": "^2.4.0"
|
|
29
|
+
},
|
|
30
|
+
"engines": {
|
|
31
|
+
"node": ">=16"
|
|
32
|
+
},
|
|
33
|
+
"peerDependencies": {
|
|
34
|
+
"eslint": "^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0-0"
|
|
35
|
+
},
|
|
36
|
+
"files": [
|
|
37
|
+
"dist"
|
|
38
|
+
],
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@babel/types": "^7.16.0",
|
|
41
|
+
"@types/eslint": "^7.29.0",
|
|
42
|
+
"@types/estree": "^0.0.50",
|
|
43
|
+
"@types/jest": "^27.5.1",
|
|
44
|
+
"jest": "^28.1.0",
|
|
45
|
+
"ts-node": "^10.9.1",
|
|
46
|
+
"typescript": "^4.8.1-rc"
|
|
47
|
+
}
|
|
48
|
+
}
|