@r_masseater/oxlint-typed-rules 0.0.1 → 0.0.3
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.mts +23 -5
- package/dist/index.mjs +1 -1
- package/dist/tanstack-start.d.mts +2 -6
- package/dist/tanstack-start.mjs +91 -22
- package/dist/tanstack-start.mjs.map +1 -1
- package/dist/typed-rule-ClHYwCu8.mjs +151 -0
- package/dist/typed-rule-ClHYwCu8.mjs.map +1 -0
- package/package.json +16 -4
- package/dist/typed-rule-Cp7XL2SV.mjs +0 -155
- package/dist/typed-rule-Cp7XL2SV.mjs.map +0 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,24 @@
|
|
|
1
|
-
import { Record } from "effect";
|
|
2
|
-
import
|
|
1
|
+
import { Option, Record } from "effect";
|
|
2
|
+
import { Node, SourceFile } from "typescript-7/ast";
|
|
3
|
+
import { Symbol, SymbolFlags } from "typescript-7/sync";
|
|
3
4
|
import { Context, CreateRule, Location, Range, RuleMeta, Visitor } from "vite-plus/lint/plugins";
|
|
5
|
+
interface CompatSymbol {
|
|
6
|
+
readonly native: Symbol;
|
|
7
|
+
readonly flags: SymbolFlags;
|
|
8
|
+
readonly name: string;
|
|
9
|
+
readonly getName: () => string;
|
|
10
|
+
readonly getFlags: () => SymbolFlags;
|
|
11
|
+
readonly getDeclarations: () => readonly Node[];
|
|
12
|
+
}
|
|
13
|
+
interface CompatChecker {
|
|
14
|
+
readonly getSymbolAtLocation: (node: Node) => CompatSymbol | undefined;
|
|
15
|
+
readonly getAliasedSymbol: (symbol: CompatSymbol) => CompatSymbol;
|
|
16
|
+
}
|
|
17
|
+
interface CompatProgram {
|
|
18
|
+
readonly getSourceFile: (fileName: string) => SourceFile | undefined;
|
|
19
|
+
readonly getSourceFiles: () => readonly SourceFile[];
|
|
20
|
+
readonly getTypeChecker: () => CompatChecker;
|
|
21
|
+
}
|
|
4
22
|
interface RangedNode {
|
|
5
23
|
readonly range: Readonly<Range>;
|
|
6
24
|
}
|
|
@@ -10,12 +28,12 @@ interface MappedNode {
|
|
|
10
28
|
readonly loc: Location;
|
|
11
29
|
}
|
|
12
30
|
interface ParserServices {
|
|
13
|
-
readonly program:
|
|
31
|
+
readonly program: CompatProgram;
|
|
14
32
|
readonly esTreeNodeToTSNodeMap: {
|
|
15
|
-
readonly get: (node: RangedNode) =>
|
|
33
|
+
readonly get: (node: RangedNode) => Node;
|
|
16
34
|
};
|
|
17
35
|
readonly tsNodeToESTreeNodeMap: {
|
|
18
|
-
readonly get: (node:
|
|
36
|
+
readonly get: (node: Node) => MappedNode | undefined;
|
|
19
37
|
};
|
|
20
38
|
}
|
|
21
39
|
interface TypedContext {
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as typedRules, n as withTypeInformation } from "./typed-rule-
|
|
1
|
+
export { t as typedRules, n as withTypeInformation } from "./typed-rule-ClHYwCu8.mjs";
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
readonly name: "tanstack-start";
|
|
4
|
-
};
|
|
5
|
-
readonly rules: import("effect/Record").ReadonlyRecord<string, import("vite-plus/lint/plugins").CreateRule>;
|
|
6
|
-
};
|
|
1
|
+
import { Plugin } from "vite-plus/lint/plugins";
|
|
2
|
+
declare const plugin: Plugin;
|
|
7
3
|
export { plugin as default };
|
|
8
4
|
//# sourceMappingURL=tanstack-start.d.mts.map
|
package/dist/tanstack-start.mjs
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import { t as typedRules } from "./typed-rule-
|
|
2
|
-
import
|
|
1
|
+
import { t as typedRules } from "./typed-rule-ClHYwCu8.mjs";
|
|
2
|
+
import { Array as Array$1, Function, Option, Predicate } from "effect";
|
|
3
|
+
import { SyntaxKind, SyntaxKind as SyntaxKind$1 } from "typescript-7/ast";
|
|
4
|
+
import { SymbolFlags as SymbolFlags$1 } from "typescript-7/sync";
|
|
5
|
+
import { isArrayBindingPattern, isArrowFunction, isBindingElement, isCallExpression, isClassDeclaration, isClassExpression, isExpressionStatement, isFunctionDeclaration, isFunctionExpression, isIdentifier, isImportClause, isImportSpecifier, isInterfaceDeclaration, isJsxAttribute, isJsxExpression, isJsxOpeningElement, isJsxSelfClosingElement, isMethodDeclaration, isObjectBindingPattern, isObjectLiteralExpression, isParameterDeclaration as isParameter, isParenthesizedExpression, isPropertyAccessExpression, isPropertyAssignment, isPropertyDeclaration, isStringLiteral, isTypeAliasDeclaration, isTypeParameterDeclaration, isTypeQueryNode, isTypeReferenceNode, isVariableDeclaration, isVariableStatement } from "typescript-7/ast/is";
|
|
3
6
|
import path from "node:path";
|
|
4
7
|
// \0rolldown/runtime.js
|
|
5
8
|
var __create = Object.create;
|
|
@@ -9,6 +12,15 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
|
9
12
|
var __getProtoOf = Object.getPrototypeOf;
|
|
10
13
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
11
14
|
var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod, mod.exports), cb = null), mod.exports);
|
|
15
|
+
var __exportAll = (all, no_symbols) => {
|
|
16
|
+
let target = {};
|
|
17
|
+
for (var name in all) __defProp(target, name, {
|
|
18
|
+
get: all[name],
|
|
19
|
+
enumerable: true
|
|
20
|
+
});
|
|
21
|
+
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
22
|
+
return target;
|
|
23
|
+
};
|
|
12
24
|
var __copyProps = (to, from, except, desc) => {
|
|
13
25
|
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
14
26
|
key = keys[i];
|
|
@@ -25,6 +37,63 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
25
37
|
}) : target, mod));
|
|
26
38
|
// ../../node_modules/.pnpm/@tanstack+eslint-plugin-start@0.1.0_patch_hash=364cc40b73326fe59c5d685ac247690de2302e3e_1ecd472b6714c9eeb7d387901cbbf798/node_modules/@tanstack/eslint-plugin-start/dist/esm/utils/get-docs-url.js
|
|
27
39
|
var getDocsUrl = (ruleName) => `https://tanstack.com/start/latest/docs/eslint/${ruleName}`;
|
|
40
|
+
// src/ts-compat.ts
|
|
41
|
+
var ts_compat_exports = /* @__PURE__ */ __exportAll({
|
|
42
|
+
SymbolFlags: () => SymbolFlags$1,
|
|
43
|
+
SyntaxKind: () => SyntaxKind$1,
|
|
44
|
+
forEachChild: () => forEachChild,
|
|
45
|
+
isArrayBindingPattern: () => isArrayBindingPattern,
|
|
46
|
+
isArrowFunction: () => isArrowFunction,
|
|
47
|
+
isBindingElement: () => isBindingElement,
|
|
48
|
+
isCallExpression: () => isCallExpression,
|
|
49
|
+
isClassDeclaration: () => isClassDeclaration,
|
|
50
|
+
isClassExpression: () => isClassExpression,
|
|
51
|
+
isExpressionStatement: () => isExpressionStatement,
|
|
52
|
+
isFunctionDeclaration: () => isFunctionDeclaration,
|
|
53
|
+
isFunctionExpression: () => isFunctionExpression,
|
|
54
|
+
isFunctionLike: () => isFunctionLike,
|
|
55
|
+
isIdentifier: () => isIdentifier,
|
|
56
|
+
isImportClause: () => isImportClause,
|
|
57
|
+
isImportSpecifier: () => isImportSpecifier,
|
|
58
|
+
isInterfaceDeclaration: () => isInterfaceDeclaration,
|
|
59
|
+
isJsxAttribute: () => isJsxAttribute,
|
|
60
|
+
isJsxExpression: () => isJsxExpression,
|
|
61
|
+
isJsxOpeningElement: () => isJsxOpeningElement,
|
|
62
|
+
isJsxSelfClosingElement: () => isJsxSelfClosingElement,
|
|
63
|
+
isMethodDeclaration: () => isMethodDeclaration,
|
|
64
|
+
isObjectBindingPattern: () => isObjectBindingPattern,
|
|
65
|
+
isObjectLiteralExpression: () => isObjectLiteralExpression,
|
|
66
|
+
isParameter: () => isParameter,
|
|
67
|
+
isParenthesizedExpression: () => isParenthesizedExpression,
|
|
68
|
+
isPropertyAccessExpression: () => isPropertyAccessExpression,
|
|
69
|
+
isPropertyAssignment: () => isPropertyAssignment,
|
|
70
|
+
isPropertyDeclaration: () => isPropertyDeclaration,
|
|
71
|
+
isStringLiteral: () => isStringLiteral,
|
|
72
|
+
isTypeAliasDeclaration: () => isTypeAliasDeclaration,
|
|
73
|
+
isTypeParameterDeclaration: () => isTypeParameterDeclaration,
|
|
74
|
+
isTypeQueryNode: () => isTypeQueryNode,
|
|
75
|
+
isTypeReferenceNode: () => isTypeReferenceNode,
|
|
76
|
+
isVariableDeclaration: () => isVariableDeclaration,
|
|
77
|
+
isVariableStatement: () => isVariableStatement
|
|
78
|
+
});
|
|
79
|
+
const FUNCTION_LIKE_KINDS = /* @__PURE__ */ new Set([
|
|
80
|
+
SyntaxKind.FunctionDeclaration,
|
|
81
|
+
SyntaxKind.MethodDeclaration,
|
|
82
|
+
SyntaxKind.Constructor,
|
|
83
|
+
SyntaxKind.GetAccessor,
|
|
84
|
+
SyntaxKind.SetAccessor,
|
|
85
|
+
SyntaxKind.FunctionExpression,
|
|
86
|
+
SyntaxKind.ArrowFunction,
|
|
87
|
+
SyntaxKind.MethodSignature,
|
|
88
|
+
SyntaxKind.CallSignature,
|
|
89
|
+
SyntaxKind.JSDocSignature,
|
|
90
|
+
SyntaxKind.ConstructSignature,
|
|
91
|
+
SyntaxKind.IndexSignature,
|
|
92
|
+
SyntaxKind.FunctionType,
|
|
93
|
+
SyntaxKind.ConstructorType
|
|
94
|
+
]);
|
|
95
|
+
const isFunctionLike = (node) => Option.fromNullishOr(node).pipe(Option.exists(({ kind }) => FUNCTION_LIKE_KINDS.has(kind)));
|
|
96
|
+
const forEachChild = Function.dual((args) => Array$1.head(Array$1.fromIterable(args)).pipe(Option.exists(Predicate.not(Predicate.isFunction))), (node, visit) => node.forEachChild(visit));
|
|
28
97
|
// ../../node_modules/.pnpm/@tanstack+eslint-plugin-start@0.1.0_patch_hash=364cc40b73326fe59c5d685ac247690de2302e3e_1ecd472b6714c9eeb7d387901cbbf798/node_modules/@tanstack/eslint-plugin-start/dist/esm/shared/use-client-resolver.js
|
|
29
98
|
/**
|
|
30
99
|
* Creates a resolver that checks for 'use client' directive in source files
|
|
@@ -35,7 +104,7 @@ function createUseClientResolver(program) {
|
|
|
35
104
|
if (!sourceFile) return false;
|
|
36
105
|
const firstStmt = sourceFile.statements[0];
|
|
37
106
|
if (!firstStmt) return false;
|
|
38
|
-
if (
|
|
107
|
+
if (isExpressionStatement(firstStmt) && isStringLiteral(firstStmt.expression)) return firstStmt.expression.text === "use client";
|
|
39
108
|
return false;
|
|
40
109
|
}
|
|
41
110
|
return { hasUseClientDirective };
|
|
@@ -4032,11 +4101,11 @@ var rule$1 = import_eslint_utils.RuleCreator(getDocsUrl)({
|
|
|
4032
4101
|
const checker = program.getTypeChecker();
|
|
4033
4102
|
const allowedHooks = /* @__PURE__ */ new Set([...DEFAULT_ALLOWED_HOOKS, ...options.allowedServerHooks]);
|
|
4034
4103
|
const useClientResolver = createUseClientResolver(program);
|
|
4035
|
-
const violationDetector = createViolationDetector(
|
|
4104
|
+
const violationDetector = createViolationDetector(ts_compat_exports, {
|
|
4036
4105
|
allowedHooks,
|
|
4037
4106
|
checker
|
|
4038
4107
|
});
|
|
4039
|
-
const transitiveAnalyzer = createTransitiveAnalyzer(
|
|
4108
|
+
const transitiveAnalyzer = createTransitiveAnalyzer(ts_compat_exports, program, checker, useClientResolver, violationDetector);
|
|
4040
4109
|
return { CallExpression(node) {
|
|
4041
4110
|
const sourceFile = services.esTreeNodeToTSNodeMap.get(node).getSourceFile();
|
|
4042
4111
|
if (useClientResolver.hasUseClientDirective(sourceFile.fileName)) return;
|
|
@@ -4046,8 +4115,8 @@ var rule$1 = import_eslint_utils.RuleCreator(getDocsUrl)({
|
|
|
4046
4115
|
const callback = node.arguments[0];
|
|
4047
4116
|
if (!callback) return;
|
|
4048
4117
|
const tsNode = services.esTreeNodeToTSNodeMap.get(callback);
|
|
4049
|
-
if (
|
|
4050
|
-
else if (
|
|
4118
|
+
if (isFunctionLike(tsNode)) analyzeServerComponentCallback(tsNode, node, rootKind);
|
|
4119
|
+
else if (isIdentifier(tsNode)) analyzeDirectComponentReference(tsNode, node, rootKind);
|
|
4051
4120
|
return;
|
|
4052
4121
|
}
|
|
4053
4122
|
const element = node.arguments[0];
|
|
@@ -4085,7 +4154,7 @@ var rule$1 = import_eslint_utils.RuleCreator(getDocsUrl)({
|
|
|
4085
4154
|
for (const ref of componentRefs) {
|
|
4086
4155
|
const symbol = checker.getSymbolAtLocation(ref);
|
|
4087
4156
|
if (!symbol) continue;
|
|
4088
|
-
const resolvedSymbol =
|
|
4157
|
+
const resolvedSymbol = SymbolFlags$1.Alias & symbol.flags ? checker.getAliasedSymbol(symbol) : symbol;
|
|
4089
4158
|
const result = transitiveAnalyzer.analyzeEntrySymbol(resolvedSymbol);
|
|
4090
4159
|
if (result.isClientBoundary) continue;
|
|
4091
4160
|
for (const violation of result.violations) {
|
|
@@ -4124,7 +4193,7 @@ var rule$1 = import_eslint_utils.RuleCreator(getDocsUrl)({
|
|
|
4124
4193
|
const symbol = checker.getSymbolAtLocation(ref);
|
|
4125
4194
|
if (!symbol) continue;
|
|
4126
4195
|
if (symbol.getDeclarations()?.some((d) => isWithinParameters(d, callback))) continue;
|
|
4127
|
-
const resolvedSymbol =
|
|
4196
|
+
const resolvedSymbol = SymbolFlags$1.Alias & symbol.flags ? checker.getAliasedSymbol(symbol) : symbol;
|
|
4128
4197
|
const result = transitiveAnalyzer.analyzeEntrySymbol(resolvedSymbol);
|
|
4129
4198
|
if (result.isClientBoundary) continue;
|
|
4130
4199
|
for (const violation of result.violations) {
|
|
@@ -4142,7 +4211,7 @@ var rule$1 = import_eslint_utils.RuleCreator(getDocsUrl)({
|
|
|
4142
4211
|
function analyzeDirectComponentReference(ref, eslintNode, rootKind = "createCompositeComponent") {
|
|
4143
4212
|
const symbol = checker.getSymbolAtLocation(ref);
|
|
4144
4213
|
if (!symbol) return;
|
|
4145
|
-
const resolvedSymbol =
|
|
4214
|
+
const resolvedSymbol = SymbolFlags$1.Alias & symbol.flags ? checker.getAliasedSymbol(symbol) : symbol;
|
|
4146
4215
|
const result = transitiveAnalyzer.analyzeEntrySymbol(resolvedSymbol);
|
|
4147
4216
|
if (result.isClientBoundary) return;
|
|
4148
4217
|
const reportedViolations = /* @__PURE__ */ new Set();
|
|
@@ -4159,10 +4228,10 @@ var rule$1 = import_eslint_utils.RuleCreator(getDocsUrl)({
|
|
|
4159
4228
|
*/
|
|
4160
4229
|
function collectParameterBindings(bindingName, names) {
|
|
4161
4230
|
function collectFromBinding(node) {
|
|
4162
|
-
if (
|
|
4163
|
-
else if (
|
|
4164
|
-
else if (
|
|
4165
|
-
for (const element of node.elements) if (
|
|
4231
|
+
if (isIdentifier(node)) names.add(node.text);
|
|
4232
|
+
else if (isObjectBindingPattern(node)) for (const element of node.elements) collectFromBinding(element.name);
|
|
4233
|
+
else if (isArrayBindingPattern(node)) {
|
|
4234
|
+
for (const element of node.elements) if (isBindingElement(element)) collectFromBinding(element.name);
|
|
4166
4235
|
}
|
|
4167
4236
|
}
|
|
4168
4237
|
collectFromBinding(bindingName);
|
|
@@ -4173,9 +4242,9 @@ var rule$1 = import_eslint_utils.RuleCreator(getDocsUrl)({
|
|
|
4173
4242
|
function isWithinParameters(decl, callback) {
|
|
4174
4243
|
let current = decl;
|
|
4175
4244
|
while (current) {
|
|
4176
|
-
if (
|
|
4245
|
+
if (isParameter(current)) {
|
|
4177
4246
|
const paramParent = current.parent;
|
|
4178
|
-
if (
|
|
4247
|
+
if (isFunctionLike(paramParent) && paramParent === callback) return true;
|
|
4179
4248
|
}
|
|
4180
4249
|
current = current.parent;
|
|
4181
4250
|
}
|
|
@@ -4184,15 +4253,15 @@ var rule$1 = import_eslint_utils.RuleCreator(getDocsUrl)({
|
|
|
4184
4253
|
function findComponentReferences(node) {
|
|
4185
4254
|
const refs = [];
|
|
4186
4255
|
function visit(n) {
|
|
4187
|
-
if (
|
|
4256
|
+
if (isJsxOpeningElement(n) || isJsxSelfClosingElement(n)) {
|
|
4188
4257
|
const tagName = n.tagName;
|
|
4189
|
-
if (
|
|
4258
|
+
if (isIdentifier(tagName) && /^[A-Z]/.test(tagName.text)) refs.push(tagName);
|
|
4190
4259
|
}
|
|
4191
|
-
if (
|
|
4260
|
+
if (isCallExpression(n)) {
|
|
4192
4261
|
const callee = n.expression;
|
|
4193
|
-
if (
|
|
4262
|
+
if (isIdentifier(callee) && /^[A-Z]/.test(callee.text)) refs.push(callee);
|
|
4194
4263
|
}
|
|
4195
|
-
|
|
4264
|
+
forEachChild(n, visit);
|
|
4196
4265
|
}
|
|
4197
4266
|
visit(node);
|
|
4198
4267
|
return refs;
|
|
@@ -4660,7 +4729,7 @@ var rule = import_eslint_utils.RuleCreator(getDocsUrl)({
|
|
|
4660
4729
|
let cached = perProgramCache.get(program);
|
|
4661
4730
|
if (!cached) {
|
|
4662
4731
|
cached = {
|
|
4663
|
-
builder: createRenderGraphBuilder(
|
|
4732
|
+
builder: createRenderGraphBuilder(ts_compat_exports, program, checker),
|
|
4664
4733
|
graphBuilt: false
|
|
4665
4734
|
};
|
|
4666
4735
|
perProgramCache.set(program, cached);
|