@conorroberts/utils 0.0.51 → 0.0.53
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/oxlint/jsx-component-pascal-case.d.mts +8 -8
- package/dist/oxlint/no-component-date-instantiation.d.mts +8 -8
- package/dist/oxlint/no-emoji.d.mts +4 -4
- package/dist/oxlint/no-finally.d.mts +4 -4
- package/dist/oxlint/no-function-call-in-jsx.d.mts +19 -0
- package/dist/oxlint/no-function-call-in-jsx.mjs +74 -0
- package/dist/oxlint/no-function-call-in-jsx.mjs.map +1 -0
- package/dist/oxlint/no-inline-components.d.mts +11 -11
- package/dist/oxlint/no-switch-plugin.d.mts +3 -3
- package/dist/oxlint/no-top-level-let.d.mts +4 -4
- package/dist/oxlint/no-type-cast.d.mts +4 -4
- package/package.json +5 -1
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as oxlint21 from "oxlint";
|
|
2
2
|
|
|
3
3
|
//#region src/oxlint-plugins/jsx-component-pascal-case.d.ts
|
|
4
|
-
declare const jsxComponentPascalCaseRule:
|
|
4
|
+
declare const jsxComponentPascalCaseRule: oxlint21.Rule;
|
|
5
5
|
declare namespace _default {
|
|
6
6
|
namespace meta {
|
|
7
7
|
let name: string;
|
|
8
8
|
}
|
|
9
9
|
let rules: {
|
|
10
|
-
"jsx-component-pascal-case":
|
|
10
|
+
"jsx-component-pascal-case": oxlint21.Rule;
|
|
11
11
|
};
|
|
12
12
|
}
|
|
13
|
-
type RuleContext =
|
|
14
|
-
type ESTNode =
|
|
15
|
-
type ESTExpression =
|
|
16
|
-
type ReturnStatementNode =
|
|
17
|
-
type FunctionLikeNode =
|
|
13
|
+
type RuleContext = oxlint21.Context;
|
|
14
|
+
type ESTNode = oxlint21.ESTree.Node;
|
|
15
|
+
type ESTExpression = oxlint21.ESTree.Expression;
|
|
16
|
+
type ReturnStatementNode = oxlint21.ESTree.ReturnStatement;
|
|
17
|
+
type FunctionLikeNode = oxlint21.ESTree.Function | oxlint21.ESTree.ArrowFunctionExpression;
|
|
18
18
|
type FunctionContext = {
|
|
19
19
|
node: FunctionLikeNode;
|
|
20
20
|
name: string;
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as oxlint13 from "oxlint";
|
|
2
2
|
|
|
3
3
|
//#region src/oxlint-plugins/no-component-date-instantiation.d.ts
|
|
4
|
-
declare const noComponentDateInstantiationRule:
|
|
4
|
+
declare const noComponentDateInstantiationRule: oxlint13.Rule;
|
|
5
5
|
declare namespace _default {
|
|
6
6
|
namespace meta {
|
|
7
7
|
let name: string;
|
|
8
8
|
}
|
|
9
9
|
let rules: {
|
|
10
|
-
"no-component-date-instantiation":
|
|
10
|
+
"no-component-date-instantiation": oxlint13.Rule;
|
|
11
11
|
};
|
|
12
12
|
}
|
|
13
|
-
type RuleContext =
|
|
14
|
-
type ESTNode =
|
|
15
|
-
type NewExpressionNode =
|
|
16
|
-
type ReturnStatementNode =
|
|
17
|
-
type FunctionLikeNode =
|
|
13
|
+
type RuleContext = oxlint13.Context;
|
|
14
|
+
type ESTNode = oxlint13.ESTree.Node;
|
|
15
|
+
type NewExpressionNode = oxlint13.ESTree.NewExpression;
|
|
16
|
+
type ReturnStatementNode = oxlint13.ESTree.ReturnStatement;
|
|
17
|
+
type FunctionLikeNode = oxlint13.ESTree.Function | oxlint13.ESTree.ArrowFunctionExpression;
|
|
18
18
|
type FunctionContext = {
|
|
19
19
|
node: FunctionLikeNode;
|
|
20
20
|
parent: FunctionContext | null;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as oxlint0 from "oxlint";
|
|
2
2
|
|
|
3
3
|
//#region src/oxlint-plugins/no-emoji.d.ts
|
|
4
|
-
declare const noEmojiRule:
|
|
4
|
+
declare const noEmojiRule: oxlint0.Rule;
|
|
5
5
|
declare namespace _default {
|
|
6
6
|
namespace meta {
|
|
7
7
|
let name: string;
|
|
8
8
|
}
|
|
9
9
|
let rules: {
|
|
10
|
-
"no-emoji":
|
|
10
|
+
"no-emoji": oxlint0.Rule;
|
|
11
11
|
};
|
|
12
12
|
}
|
|
13
|
-
type ESTNode =
|
|
13
|
+
type ESTNode = oxlint0.ESTree.Node;
|
|
14
14
|
//#endregion
|
|
15
15
|
export { ESTNode, _default as default, noEmojiRule };
|
|
16
16
|
//# sourceMappingURL=no-emoji.d.mts.map
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as oxlint35 from "oxlint";
|
|
2
2
|
|
|
3
3
|
//#region src/oxlint-plugins/no-finally.d.ts
|
|
4
|
-
declare const noFinallyRule:
|
|
4
|
+
declare const noFinallyRule: oxlint35.Rule;
|
|
5
5
|
declare namespace _default {
|
|
6
6
|
namespace meta {
|
|
7
7
|
let name: string;
|
|
8
8
|
}
|
|
9
9
|
let rules: {
|
|
10
|
-
"no-finally":
|
|
10
|
+
"no-finally": oxlint35.Rule;
|
|
11
11
|
};
|
|
12
12
|
}
|
|
13
|
-
type ESTNode =
|
|
13
|
+
type ESTNode = oxlint35.ESTree.Node;
|
|
14
14
|
//#endregion
|
|
15
15
|
export { ESTNode, _default as default, noFinallyRule };
|
|
16
16
|
//# sourceMappingURL=no-finally.d.mts.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as oxlint2 from "oxlint";
|
|
2
|
+
|
|
3
|
+
//#region src/oxlint-plugins/no-function-call-in-jsx.d.ts
|
|
4
|
+
declare const noFunctionCallInJsxRule: oxlint2.Rule;
|
|
5
|
+
declare namespace _default {
|
|
6
|
+
namespace meta {
|
|
7
|
+
let name: string;
|
|
8
|
+
}
|
|
9
|
+
let rules: {
|
|
10
|
+
"no-function-call-in-jsx": oxlint2.Rule;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
type RuleContext = oxlint2.Context;
|
|
14
|
+
type ESTNode = oxlint2.ESTree.Node;
|
|
15
|
+
type JSXExpressionContainer = oxlint2.ESTree.JSXExpressionContainer;
|
|
16
|
+
type CallExpression = oxlint2.ESTree.CallExpression;
|
|
17
|
+
//#endregion
|
|
18
|
+
export { CallExpression, ESTNode, JSXExpressionContainer, RuleContext, _default as default, noFunctionCallInJsxRule };
|
|
19
|
+
//# sourceMappingURL=no-function-call-in-jsx.d.mts.map
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { defineRule } from "oxlint";
|
|
2
|
+
|
|
3
|
+
//#region src/oxlint-plugins/no-function-call-in-jsx.js
|
|
4
|
+
/**
|
|
5
|
+
* @typedef {import("oxlint").Context} RuleContext
|
|
6
|
+
* @typedef {import("oxlint").ESTree.Node} ESTNode
|
|
7
|
+
* @typedef {import("oxlint").ESTree.JSXExpressionContainer} JSXExpressionContainer
|
|
8
|
+
* @typedef {import("oxlint").ESTree.CallExpression} CallExpression
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* @param {unknown} node
|
|
12
|
+
* @returns {node is ESTNode & { type: string }}
|
|
13
|
+
*/
|
|
14
|
+
const isNode = (node) => Boolean(node && typeof node === "object" && "type" in node);
|
|
15
|
+
/**
|
|
16
|
+
* @param {ESTNode | null | undefined} node
|
|
17
|
+
* @returns {boolean}
|
|
18
|
+
*/
|
|
19
|
+
const isInJSXExpressionContainer = (node) => {
|
|
20
|
+
const findJSXContainer = (current) => {
|
|
21
|
+
if (!current) return false;
|
|
22
|
+
if (current.type === "JSXExpressionContainer") return true;
|
|
23
|
+
return findJSXContainer(isNode(current) ? current.parent ?? null : null);
|
|
24
|
+
};
|
|
25
|
+
return findJSXContainer(isNode(node) ? node.parent ?? null : null);
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* @param {CallExpression} node
|
|
29
|
+
* @returns {string}
|
|
30
|
+
*/
|
|
31
|
+
const getCalleeName = (node) => {
|
|
32
|
+
const callee = node.callee;
|
|
33
|
+
if (!callee) return "function";
|
|
34
|
+
if (callee.type === "Identifier") return callee.name;
|
|
35
|
+
if (callee.type === "MemberExpression") {
|
|
36
|
+
const property = callee.property;
|
|
37
|
+
if (property && property.type === "Identifier") return property.name;
|
|
38
|
+
}
|
|
39
|
+
return "function";
|
|
40
|
+
};
|
|
41
|
+
const rule = defineRule({
|
|
42
|
+
meta: {
|
|
43
|
+
type: "problem",
|
|
44
|
+
docs: {
|
|
45
|
+
description: "Disallow function calls within JSX expression containers",
|
|
46
|
+
recommended: false
|
|
47
|
+
},
|
|
48
|
+
schema: []
|
|
49
|
+
},
|
|
50
|
+
create(context) {
|
|
51
|
+
/**
|
|
52
|
+
* @param {CallExpression} node
|
|
53
|
+
*/
|
|
54
|
+
const handleCallExpression = (node) => {
|
|
55
|
+
if (node.type !== "CallExpression") return;
|
|
56
|
+
if (!isInJSXExpressionContainer(node)) return;
|
|
57
|
+
const calleeName = getCalleeName(node);
|
|
58
|
+
context.report({
|
|
59
|
+
node,
|
|
60
|
+
message: `Avoid calling '${calleeName}()' directly in JSX. Store the result in a variable or use a component instead.`
|
|
61
|
+
});
|
|
62
|
+
};
|
|
63
|
+
return { CallExpression: handleCallExpression };
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
const noFunctionCallInJsxRule = rule;
|
|
67
|
+
var no_function_call_in_jsx_default = {
|
|
68
|
+
meta: { name: "no-function-call-in-jsx" },
|
|
69
|
+
rules: { "no-function-call-in-jsx": rule }
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
//#endregion
|
|
73
|
+
export { no_function_call_in_jsx_default as default, noFunctionCallInJsxRule };
|
|
74
|
+
//# sourceMappingURL=no-function-call-in-jsx.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"no-function-call-in-jsx.mjs","names":[],"sources":["../../src/oxlint-plugins/no-function-call-in-jsx.js"],"sourcesContent":["import { defineRule } from \"oxlint\";\n\n/**\n * @typedef {import(\"oxlint\").Context} RuleContext\n * @typedef {import(\"oxlint\").ESTree.Node} ESTNode\n * @typedef {import(\"oxlint\").ESTree.JSXExpressionContainer} JSXExpressionContainer\n * @typedef {import(\"oxlint\").ESTree.CallExpression} CallExpression\n */\n\n/**\n * @param {unknown} node\n * @returns {node is ESTNode & { type: string }}\n */\nconst isNode = (node) => Boolean(node && typeof node === \"object\" && \"type\" in node);\n\n/**\n * @param {ESTNode | null | undefined} node\n * @returns {boolean}\n */\nconst isInJSXExpressionContainer = (node) => {\n const findJSXContainer = (current) => {\n if (!current) return false;\n if (current.type === \"JSXExpressionContainer\") {\n return true;\n }\n return findJSXContainer(isNode(current) ? current.parent ?? null : null);\n };\n return findJSXContainer(isNode(node) ? node.parent ?? null : null);\n};\n\n/**\n * @param {CallExpression} node\n * @returns {string}\n */\nconst getCalleeName = (node) => {\n const callee = node.callee;\n if (!callee) return \"function\";\n\n if (callee.type === \"Identifier\") {\n return callee.name;\n }\n\n if (callee.type === \"MemberExpression\") {\n const property = callee.property;\n if (property && property.type === \"Identifier\") {\n return property.name;\n }\n }\n\n return \"function\";\n};\n\nconst rule = defineRule({\n meta: {\n type: \"problem\",\n docs: {\n description: \"Disallow function calls within JSX expression containers\",\n recommended: false,\n },\n schema: [],\n },\n\n create(context) {\n /**\n * @param {CallExpression} node\n */\n const handleCallExpression = (node) => {\n if (node.type !== \"CallExpression\") return;\n\n if (!isInJSXExpressionContainer(node)) return;\n\n const calleeName = getCalleeName(node);\n\n context.report({\n node: node,\n message: `Avoid calling '${calleeName}()' directly in JSX. Store the result in a variable or use a component instead.`,\n });\n };\n\n return {\n CallExpression: handleCallExpression,\n };\n },\n});\n\nexport const noFunctionCallInJsxRule = rule;\n\nexport default {\n meta: { name: \"no-function-call-in-jsx\" },\n rules: { \"no-function-call-in-jsx\": rule },\n};\n"],"mappings":";;;;;;;;;;;;;AAaA,MAAM,UAAU,SAAS,QAAQ,QAAQ,OAAO,SAAS,YAAY,UAAU,KAAK;;;;;AAMpF,MAAM,8BAA8B,SAAS;CAC3C,MAAM,oBAAoB,YAAY;AACpC,MAAI,CAAC,QAAS,QAAO;AACrB,MAAI,QAAQ,SAAS,yBACnB,QAAO;AAET,SAAO,iBAAiB,OAAO,QAAQ,GAAG,QAAQ,UAAU,OAAO,KAAK;;AAE1E,QAAO,iBAAiB,OAAO,KAAK,GAAG,KAAK,UAAU,OAAO,KAAK;;;;;;AAOpE,MAAM,iBAAiB,SAAS;CAC9B,MAAM,SAAS,KAAK;AACpB,KAAI,CAAC,OAAQ,QAAO;AAEpB,KAAI,OAAO,SAAS,aAClB,QAAO,OAAO;AAGhB,KAAI,OAAO,SAAS,oBAAoB;EACtC,MAAM,WAAW,OAAO;AACxB,MAAI,YAAY,SAAS,SAAS,aAChC,QAAO,SAAS;;AAIpB,QAAO;;AAGT,MAAM,OAAO,WAAW;CACtB,MAAM;EACJ,MAAM;EACN,MAAM;GACJ,aAAa;GACb,aAAa;GACd;EACD,QAAQ,EAAE;EACX;CAED,OAAO,SAAS;;;;EAId,MAAM,wBAAwB,SAAS;AACrC,OAAI,KAAK,SAAS,iBAAkB;AAEpC,OAAI,CAAC,2BAA2B,KAAK,CAAE;GAEvC,MAAM,aAAa,cAAc,KAAK;AAEtC,WAAQ,OAAO;IACP;IACN,SAAS,kBAAkB,WAAW;IACvC,CAAC;;AAGJ,SAAO,EACL,gBAAgB,sBACjB;;CAEJ,CAAC;AAEF,MAAa,0BAA0B;AAEvC,sCAAe;CACb,MAAM,EAAE,MAAM,2BAA2B;CACzC,OAAO,EAAE,2BAA2B,MAAM;CAC3C"}
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as oxlint38 from "oxlint";
|
|
2
2
|
|
|
3
3
|
//#region src/oxlint-plugins/no-inline-components.d.ts
|
|
4
4
|
declare function isComponentName(name: unknown): name is string;
|
|
5
5
|
declare function isHookName(name: unknown): name is string;
|
|
6
6
|
declare function getEnclosingFunction(node: ESTNode | null | undefined): FunctionLikeNode | null;
|
|
7
7
|
declare function getFunctionName(node: FunctionLikeNode): string;
|
|
8
|
-
declare const noInlineComponentsRule:
|
|
8
|
+
declare const noInlineComponentsRule: oxlint38.Rule;
|
|
9
9
|
declare namespace _default {
|
|
10
10
|
namespace meta {
|
|
11
11
|
let name: string;
|
|
12
12
|
}
|
|
13
13
|
let rules: {
|
|
14
|
-
"no-inline-components":
|
|
14
|
+
"no-inline-components": oxlint38.Rule;
|
|
15
15
|
};
|
|
16
16
|
}
|
|
17
|
-
type RuleContext =
|
|
18
|
-
type ESTNode =
|
|
19
|
-
type ESTExpression =
|
|
20
|
-
type ESTPattern =
|
|
21
|
-
type ReturnStatementNode =
|
|
22
|
-
type VariableDeclaratorNode =
|
|
23
|
-
type AssignmentExpressionNode =
|
|
24
|
-
type FunctionLikeNode =
|
|
17
|
+
type RuleContext = oxlint38.Context;
|
|
18
|
+
type ESTNode = oxlint38.ESTree.Node;
|
|
19
|
+
type ESTExpression = oxlint38.ESTree.Expression;
|
|
20
|
+
type ESTPattern = oxlint38.ESTree.Pattern;
|
|
21
|
+
type ReturnStatementNode = oxlint38.ESTree.ReturnStatement;
|
|
22
|
+
type VariableDeclaratorNode = oxlint38.ESTree.VariableDeclarator;
|
|
23
|
+
type AssignmentExpressionNode = oxlint38.ESTree.AssignmentExpression;
|
|
24
|
+
type FunctionLikeNode = oxlint38.ESTree.Function | oxlint38.ESTree.ArrowFunctionExpression;
|
|
25
25
|
type RecordedAssignment = {
|
|
26
26
|
node: ESTExpression;
|
|
27
27
|
names: string[];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as oxlint11 from "oxlint";
|
|
2
2
|
|
|
3
3
|
//#region src/oxlint-plugins/no-switch-plugin.d.ts
|
|
4
4
|
declare namespace _default {
|
|
@@ -6,10 +6,10 @@ declare namespace _default {
|
|
|
6
6
|
let name: string;
|
|
7
7
|
}
|
|
8
8
|
let rules: {
|
|
9
|
-
"no-switch":
|
|
9
|
+
"no-switch": oxlint11.Rule;
|
|
10
10
|
};
|
|
11
11
|
}
|
|
12
|
-
type ESTNode =
|
|
12
|
+
type ESTNode = oxlint11.ESTree.Node;
|
|
13
13
|
//#endregion
|
|
14
14
|
export { ESTNode, _default as default };
|
|
15
15
|
//# sourceMappingURL=no-switch-plugin.d.mts.map
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as oxlint8 from "oxlint";
|
|
2
2
|
|
|
3
3
|
//#region src/oxlint-plugins/no-top-level-let.d.ts
|
|
4
|
-
declare const noTopLevelLetRule:
|
|
4
|
+
declare const noTopLevelLetRule: oxlint8.Rule;
|
|
5
5
|
declare namespace _default {
|
|
6
6
|
namespace meta {
|
|
7
7
|
let name: string;
|
|
8
8
|
}
|
|
9
9
|
let rules: {
|
|
10
|
-
"no-top-level-let":
|
|
10
|
+
"no-top-level-let": oxlint8.Rule;
|
|
11
11
|
};
|
|
12
12
|
}
|
|
13
|
-
type ESTNode =
|
|
13
|
+
type ESTNode = oxlint8.ESTree.Node;
|
|
14
14
|
//#endregion
|
|
15
15
|
export { ESTNode, _default as default, noTopLevelLetRule };
|
|
16
16
|
//# sourceMappingURL=no-top-level-let.d.mts.map
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as oxlint32 from "oxlint";
|
|
2
2
|
|
|
3
3
|
//#region src/oxlint-plugins/no-type-cast.d.ts
|
|
4
|
-
declare const noTypeCastRule:
|
|
4
|
+
declare const noTypeCastRule: oxlint32.Rule;
|
|
5
5
|
declare namespace _default {
|
|
6
6
|
namespace meta {
|
|
7
7
|
let name: string;
|
|
8
8
|
}
|
|
9
9
|
let rules: {
|
|
10
|
-
"no-type-cast":
|
|
10
|
+
"no-type-cast": oxlint32.Rule;
|
|
11
11
|
};
|
|
12
12
|
}
|
|
13
|
-
type ESTNode =
|
|
13
|
+
type ESTNode = oxlint32.ESTree.Node;
|
|
14
14
|
//#endregion
|
|
15
15
|
export { ESTNode, _default as default, noTypeCastRule };
|
|
16
16
|
//# sourceMappingURL=no-type-cast.d.mts.map
|
package/package.json
CHANGED
|
@@ -38,6 +38,10 @@
|
|
|
38
38
|
"types": "./dist/oxlint/no-finally.d.mts",
|
|
39
39
|
"default": "./dist/oxlint/no-finally.mjs"
|
|
40
40
|
},
|
|
41
|
+
"./oxlint/no-function-call-in-jsx": {
|
|
42
|
+
"types": "./dist/oxlint/no-function-call-in-jsx.d.mts",
|
|
43
|
+
"default": "./dist/oxlint/no-function-call-in-jsx.mjs"
|
|
44
|
+
},
|
|
41
45
|
"./oxlint/no-inline-components": {
|
|
42
46
|
"types": "./dist/oxlint/no-inline-components.d.mts",
|
|
43
47
|
"default": "./dist/oxlint/no-inline-components.mjs"
|
|
@@ -82,7 +86,7 @@
|
|
|
82
86
|
"typescript": "5.9.3",
|
|
83
87
|
"vitest": "4.0.15"
|
|
84
88
|
},
|
|
85
|
-
"version": "0.0.
|
|
89
|
+
"version": "0.0.53",
|
|
86
90
|
"scripts": {
|
|
87
91
|
"dev": "tsdown --watch",
|
|
88
92
|
"build": "tsc --noEmit && tsdown",
|