@cedarjs/eslint-plugin 6.0.0-canary.2739 → 6.0.0-canary.2742
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -35
- package/dist/process-env-computed.js +6 -30
- package/dist/service-type-annotations.js +10 -34
- package/dist/unsupported-route-components.js +11 -35
- package/package.json +5 -5
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ESLintUtils } from '@typescript-eslint/utils';
|
|
2
2
|
export declare const meta: {
|
|
3
3
|
name: string;
|
|
4
|
-
version:
|
|
4
|
+
version: string;
|
|
5
5
|
};
|
|
6
6
|
export declare const rules: {
|
|
7
7
|
'process-env-computed': ESLintUtils.RuleModule<"unexpected", [], unknown, ESLintUtils.RuleListener>;
|
|
@@ -11,7 +11,7 @@ export declare const rules: {
|
|
|
11
11
|
declare const plugin: {
|
|
12
12
|
meta: {
|
|
13
13
|
name: string;
|
|
14
|
-
version:
|
|
14
|
+
version: string;
|
|
15
15
|
};
|
|
16
16
|
rules: {
|
|
17
17
|
'process-env-computed': ESLintUtils.RuleModule<"unexpected", [], unknown, ESLintUtils.RuleListener>;
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA;AAQ3D,eAAO,MAAM,IAAI;;;CAGhB,CAAA;AAED,eAAO,MAAM,KAAK;;;;CAIwC,CAAA;AAE1D,QAAA,MAAM,MAAM;;;;;;;;;;CAAkB,CAAA;AAE9B,eAAe,MAAM,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,44 +1,20 @@
|
|
|
1
|
-
"
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var index_exports = {};
|
|
20
|
-
__export(index_exports, {
|
|
21
|
-
default: () => index_default,
|
|
22
|
-
meta: () => meta,
|
|
23
|
-
rules: () => rules
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(index_exports);
|
|
26
|
-
var import_process_env_computed = require("./process-env-computed.js");
|
|
27
|
-
var import_service_type_annotations = require("./service-type-annotations.js");
|
|
28
|
-
var import_unsupported_route_components = require("./unsupported-route-components.js");
|
|
1
|
+
import pkgJson from "../package.json" with { type: "json" };
|
|
2
|
+
import { processEnvComputedRule } from "./process-env-computed.js";
|
|
3
|
+
import { serviceTypeAnnotations } from "./service-type-annotations.js";
|
|
4
|
+
import { unsupportedRouteComponents } from "./unsupported-route-components.js";
|
|
29
5
|
const meta = {
|
|
30
6
|
name: "@cedarjs/eslint-plugin",
|
|
31
|
-
version:
|
|
7
|
+
version: pkgJson.version
|
|
32
8
|
};
|
|
33
9
|
const rules = {
|
|
34
|
-
"process-env-computed":
|
|
35
|
-
"service-type-annotations":
|
|
36
|
-
"unsupported-route-components":
|
|
10
|
+
"process-env-computed": processEnvComputedRule,
|
|
11
|
+
"service-type-annotations": serviceTypeAnnotations,
|
|
12
|
+
"unsupported-route-components": unsupportedRouteComponents
|
|
37
13
|
};
|
|
38
14
|
const plugin = { meta, rules };
|
|
39
15
|
var index_default = plugin;
|
|
40
|
-
|
|
41
|
-
|
|
16
|
+
export {
|
|
17
|
+
index_default as default,
|
|
42
18
|
meta,
|
|
43
19
|
rules
|
|
44
|
-
}
|
|
20
|
+
};
|
|
@@ -1,33 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var process_env_computed_exports = {};
|
|
20
|
-
__export(process_env_computed_exports, {
|
|
21
|
-
processEnvComputedRule: () => processEnvComputedRule
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(process_env_computed_exports);
|
|
24
|
-
var import_utils = require("@typescript-eslint/utils");
|
|
25
|
-
const createRule = import_utils.ESLintUtils.RuleCreator.withoutDocs;
|
|
1
|
+
import { ESLintUtils, AST_NODE_TYPES } from "@typescript-eslint/utils";
|
|
2
|
+
const createRule = ESLintUtils.RuleCreator.withoutDocs;
|
|
26
3
|
function isProcessEnv(node) {
|
|
27
|
-
return node.type ===
|
|
4
|
+
return node.type === AST_NODE_TYPES.MemberExpression && hasName(node.object, "process") && hasName(node.property, "env");
|
|
28
5
|
}
|
|
29
6
|
function hasName(node, name) {
|
|
30
|
-
return node.type ===
|
|
7
|
+
return node.type === AST_NODE_TYPES.Identifier && node.name === name;
|
|
31
8
|
}
|
|
32
9
|
function isTestFile(filename) {
|
|
33
10
|
return filename.endsWith(".test.ts") || filename.endsWith(".test.js") || filename.endsWith(".test.tsx") || filename.endsWith(".test.jsx") || filename.endsWith(".test.mts") || filename.endsWith(".test.mjs") || filename.endsWith(".test.cjs") || filename.endsWith(".spec.ts") || filename.endsWith(".spec.js") || filename.endsWith(".spec.tsx") || filename.endsWith(".spec.jsx") || filename.endsWith(".spec.mts") || filename.endsWith(".spec.mjs") || filename.endsWith(".spec.cjs") || filename.includes("/__tests__/");
|
|
@@ -59,7 +36,6 @@ const processEnvComputedRule = createRule({
|
|
|
59
36
|
};
|
|
60
37
|
}
|
|
61
38
|
});
|
|
62
|
-
|
|
63
|
-
0 && (module.exports = {
|
|
39
|
+
export {
|
|
64
40
|
processEnvComputedRule
|
|
65
|
-
}
|
|
41
|
+
};
|
|
@@ -1,29 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var service_type_annotations_exports = {};
|
|
20
|
-
__export(service_type_annotations_exports, {
|
|
21
|
-
serviceTypeAnnotations: () => serviceTypeAnnotations
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(service_type_annotations_exports);
|
|
24
|
-
var import_node_path = require("node:path");
|
|
25
|
-
var import_utils = require("@typescript-eslint/utils");
|
|
26
|
-
const createRule = import_utils.ESLintUtils.RuleCreator.withoutDocs;
|
|
1
|
+
import { basename } from "node:path";
|
|
2
|
+
import { ESLintUtils, AST_NODE_TYPES } from "@typescript-eslint/utils";
|
|
3
|
+
const createRule = ESLintUtils.RuleCreator.withoutDocs;
|
|
27
4
|
const capitalizeFirstLetter = (str) => str.charAt(0).toUpperCase() + str.slice(1);
|
|
28
5
|
const serviceTypeAnnotations = createRule({
|
|
29
6
|
meta: {
|
|
@@ -39,7 +16,7 @@ const serviceTypeAnnotations = createRule({
|
|
|
39
16
|
},
|
|
40
17
|
defaultOptions: [],
|
|
41
18
|
create(context) {
|
|
42
|
-
const thisFilename =
|
|
19
|
+
const thisFilename = basename(context.filename);
|
|
43
20
|
const sansTS = thisFilename.replace(".ts", "");
|
|
44
21
|
const thisFileCorrespondingImport = `types/${sansTS}`;
|
|
45
22
|
let importForThisFile = null;
|
|
@@ -51,18 +28,18 @@ const serviceTypeAnnotations = createRule({
|
|
|
51
28
|
},
|
|
52
29
|
// Then start looking at every exported fn/const
|
|
53
30
|
ExportNamedDeclaration(node) {
|
|
54
|
-
if (node.declaration?.type !==
|
|
31
|
+
if (node.declaration?.type !== AST_NODE_TYPES.VariableDeclaration) {
|
|
55
32
|
return;
|
|
56
33
|
}
|
|
57
34
|
node.declaration.declarations.forEach((vd) => {
|
|
58
|
-
if (vd.type ===
|
|
35
|
+
if (vd.type === AST_NODE_TYPES.VariableDeclarator && vd.id.type === AST_NODE_TYPES.Identifier) {
|
|
59
36
|
if (vd.id.name.startsWith("_")) {
|
|
60
37
|
return;
|
|
61
38
|
}
|
|
62
39
|
const isGlobalOrMutationResolver = /^[a-z]/.test(vd.id.name);
|
|
63
40
|
const suffix = isGlobalOrMutationResolver ? "Resolver" : "TypeResolvers";
|
|
64
41
|
const typeName = capitalizeFirstLetter(vd.id.name) + suffix;
|
|
65
|
-
if (isGlobalOrMutationResolver && vd.init?.type !==
|
|
42
|
+
if (isGlobalOrMutationResolver && vd.init?.type !== AST_NODE_TYPES.ArrowFunctionExpression) {
|
|
66
43
|
return;
|
|
67
44
|
}
|
|
68
45
|
const tsID = vd.id;
|
|
@@ -98,7 +75,7 @@ const serviceTypeAnnotations = createRule({
|
|
|
98
75
|
if (!("typeName" in type)) {
|
|
99
76
|
return;
|
|
100
77
|
}
|
|
101
|
-
const isCorrectType = type.typeName?.type ===
|
|
78
|
+
const isCorrectType = type.typeName?.type === AST_NODE_TYPES.Identifier && type.typeName?.name === typeName;
|
|
102
79
|
if (isCorrectType) {
|
|
103
80
|
return;
|
|
104
81
|
}
|
|
@@ -134,7 +111,6 @@ const serviceTypeAnnotations = createRule({
|
|
|
134
111
|
};
|
|
135
112
|
}
|
|
136
113
|
});
|
|
137
|
-
|
|
138
|
-
0 && (module.exports = {
|
|
114
|
+
export {
|
|
139
115
|
serviceTypeAnnotations
|
|
140
|
-
}
|
|
116
|
+
};
|
|
@@ -1,35 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var unsupported_route_components_exports = {};
|
|
20
|
-
__export(unsupported_route_components_exports, {
|
|
21
|
-
unsupportedRouteComponents: () => unsupportedRouteComponents
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(unsupported_route_components_exports);
|
|
24
|
-
var import_utils = require("@typescript-eslint/utils");
|
|
25
|
-
const createRule = import_utils.ESLintUtils.RuleCreator.withoutDocs;
|
|
1
|
+
import { AST_NODE_TYPES, ESLintUtils } from "@typescript-eslint/utils";
|
|
2
|
+
const createRule = ESLintUtils.RuleCreator.withoutDocs;
|
|
26
3
|
function isAllowedElement(name) {
|
|
27
4
|
const allowedElements = ["Router", "Route", "Set", "PrivateSet", "Private"];
|
|
28
5
|
return allowedElements.includes(name);
|
|
29
6
|
}
|
|
30
7
|
function checkNodes(nodesToCheck, context) {
|
|
31
|
-
if (nodesToCheck.type ===
|
|
32
|
-
const name = nodesToCheck.openingElement.name.type ===
|
|
8
|
+
if (nodesToCheck.type === AST_NODE_TYPES.JSXElement) {
|
|
9
|
+
const name = nodesToCheck.openingElement.name.type === AST_NODE_TYPES.JSXIdentifier ? nodesToCheck.openingElement.name.name : null;
|
|
33
10
|
if (name && !isAllowedElement(name)) {
|
|
34
11
|
context.report({
|
|
35
12
|
node: nodesToCheck,
|
|
@@ -59,11 +36,11 @@ const unsupportedRouteComponents = createRule({
|
|
|
59
36
|
VariableDeclaration(node) {
|
|
60
37
|
if (isRoutesRenderBlock(node.declarations[0])) {
|
|
61
38
|
const routesDeclaration = node.declarations[0].init;
|
|
62
|
-
if (routesDeclaration?.type ===
|
|
63
|
-
if (routesDeclaration.body.type ===
|
|
39
|
+
if (routesDeclaration?.type === AST_NODE_TYPES.ArrowFunctionExpression) {
|
|
40
|
+
if (routesDeclaration.body.type === AST_NODE_TYPES.JSXElement) {
|
|
64
41
|
checkNodes(routesDeclaration.body, context);
|
|
65
|
-
} else if (routesDeclaration.body.type ===
|
|
66
|
-
if (routesDeclaration.body.body[0].type ===
|
|
42
|
+
} else if (routesDeclaration.body.type === AST_NODE_TYPES.BlockStatement) {
|
|
43
|
+
if (routesDeclaration.body.body[0].type === AST_NODE_TYPES.ReturnStatement && routesDeclaration.body.body[0].argument?.type === AST_NODE_TYPES.JSXElement) {
|
|
67
44
|
const routesReturnStatement = routesDeclaration.body.body[0].argument;
|
|
68
45
|
checkNodes(routesReturnStatement, context);
|
|
69
46
|
}
|
|
@@ -75,9 +52,8 @@ const unsupportedRouteComponents = createRule({
|
|
|
75
52
|
}
|
|
76
53
|
});
|
|
77
54
|
function isRoutesRenderBlock(node) {
|
|
78
|
-
return node?.type ===
|
|
55
|
+
return node?.type === AST_NODE_TYPES.VariableDeclarator && node?.id.type === AST_NODE_TYPES.Identifier && node?.id.name === "Routes";
|
|
79
56
|
}
|
|
80
|
-
|
|
81
|
-
0 && (module.exports = {
|
|
57
|
+
export {
|
|
82
58
|
unsupportedRouteComponents
|
|
83
|
-
}
|
|
59
|
+
};
|
package/package.json
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cedarjs/eslint-plugin",
|
|
3
|
-
"version": "6.0.0-canary.
|
|
3
|
+
"version": "6.0.0-canary.2742",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/cedarjs/cedar.git",
|
|
7
7
|
"directory": "packages/eslint-plugin"
|
|
8
8
|
},
|
|
9
9
|
"license": "MIT",
|
|
10
|
-
"type": "
|
|
10
|
+
"type": "module",
|
|
11
11
|
"main": "./dist/index.js",
|
|
12
12
|
"types": "./dist/index.d.ts",
|
|
13
13
|
"files": [
|
|
14
14
|
"dist"
|
|
15
15
|
],
|
|
16
16
|
"scripts": {
|
|
17
|
-
"build": "node ./build.mts
|
|
17
|
+
"build": "node ./build.mts",
|
|
18
18
|
"build:pack": "yarn pack -o cedarjs-eslint-plugin.tgz",
|
|
19
|
-
"build:types": "tsc --build --verbose",
|
|
19
|
+
"build:types": "tsc --build --verbose ./tsconfig.build.json",
|
|
20
20
|
"build:watch": "nodemon --watch src --ext \"js,jsx,ts,tsx\" --ignore dist --exec \"yarn build\"",
|
|
21
21
|
"prepublishOnly": "NODE_ENV=production yarn build",
|
|
22
22
|
"test": "vitest run",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"eslint": "8.57.1"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@cedarjs/framework-tools": "6.0.0-canary.
|
|
30
|
+
"@cedarjs/framework-tools": "6.0.0-canary.2742",
|
|
31
31
|
"@types/eslint": "8.56.12",
|
|
32
32
|
"@types/estree": "1.0.9",
|
|
33
33
|
"@typescript-eslint/parser": "8.60.1",
|