@ref0/workspace 0.0.0-stage → 0.2.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/LICENSE +201 -0
- package/README.md +169 -2
- package/dist/bin.d.mts +1 -0
- package/dist/bin.mjs +113 -0
- package/dist/docs-budget.mjs +122 -0
- package/dist/lint/anti-slop/LICENSE +21 -0
- package/dist/lint/anti-slop/UPSTREAM.md +11 -0
- package/dist/lint/anti-slop/effect/plugin.d.mts +3 -0
- package/dist/lint/anti-slop/effect/plugin.mjs +19 -0
- package/dist/lint/anti-slop/effect/rules/no-manual-effect-error-tag.mjs +33 -0
- package/dist/lint/anti-slop/effect/rules/no-manual-tag-comparison.mjs +32 -0
- package/dist/lint/anti-slop/effect/rules/no-manual-tagged-construction.mjs +22 -0
- package/dist/lint/anti-slop/effect/rules/no-service-constructor-imports.mjs +36 -0
- package/dist/lint/anti-slop/effect/rules/prefer-effect-match.mjs +40 -0
- package/dist/lint/anti-slop/effect/shared/tagged-values.mjs +40 -0
- package/dist/lint/anti-slop/plugin.d.mts +3 -0
- package/dist/lint/anti-slop/plugin.mjs +45 -0
- package/dist/lint/anti-slop/rules/no-array-filter-map.mjs +31 -0
- package/dist/lint/anti-slop/rules/no-chained-type-assertions.mjs +56 -0
- package/dist/lint/anti-slop/rules/no-conditional-empty-object-spread.mjs +32 -0
- package/dist/lint/anti-slop/rules/no-known-value-widening.mjs +236 -0
- package/dist/lint/anti-slop/rules/no-module-mocking.mjs +48 -0
- package/dist/lint/anti-slop/rules/no-object-parameters.mjs +48 -0
- package/dist/lint/anti-slop/rules/no-reduce-accumulator-copy.mjs +85 -0
- package/dist/lint/anti-slop/rules/no-reflect-apply.mjs +21 -0
- package/dist/lint/anti-slop/rules/no-reflect-get.mjs +21 -0
- package/dist/lint/anti-slop/rules/no-runtime-typeof.mjs +52 -0
- package/dist/lint/anti-slop/rules/no-shape-in-symbol-names.mjs +36 -0
- package/dist/lint/anti-slop/rules/no-unknown-parameters.mjs +44 -0
- package/dist/lint/anti-slop/rules/no-unknown-returns.mjs +47 -0
- package/dist/lint/anti-slop/rules/no-unknown-type-aliases.mjs +33 -0
- package/dist/lint/anti-slop/rules/no-unsafe-dictionary-type.mjs +121 -0
- package/dist/lint/anti-slop/rules/no-widen-then-assert.mjs +191 -0
- package/dist/lint/anti-slop/rules/require-readable-spacing.mjs +86 -0
- package/dist/lint/anti-slop/rules/require-safety-comment-for-type-assertion.mjs +82 -0
- package/dist/lint/anti-slop/shared/array-method.mjs +70 -0
- package/dist/lint/anti-slop/shared/child-nodes.mjs +24 -0
- package/dist/lint/anti-slop/shared/dictionary-types.mjs +248 -0
- package/dist/lint/anti-slop/shared/function-parameters.mjs +25 -0
- package/dist/lint/anti-slop/shared/lexical-type-parameters.mjs +21 -0
- package/dist/lint/anti-slop/shared/reflect-method.mjs +16 -0
- package/dist/lint/anti-slop/shared/scope.mjs +12 -0
- package/dist/lint/anti-slop/shared/string-literal.mjs +6 -0
- package/dist/lint/anti-slop/shared/type-alias-resolution.mjs +134 -0
- package/dist/lint/anti-slop/vendor/eslint-stylistic/LICENSE +22 -0
- package/dist/lint/anti-slop/vendor/eslint-stylistic/UPSTREAM.md +29 -0
- package/dist/lint/anti-slop/vendor/eslint-stylistic/padding-line-ast.mjs +32 -0
- package/dist/lint/anti-slop/vendor/eslint-stylistic/padding-line-between-statements.mjs +608 -0
- package/dist/lint/config.d.mts +20 -0
- package/dist/lint/config.mjs +135 -0
- package/dist/lint/generic/effect-encoding.mjs +45 -0
- package/dist/lint/generic/entry-reexports.mjs +81 -0
- package/dist/lint/generic/env-at-entrypoints.mjs +65 -0
- package/dist/lint/generic/export-type-side-effects.mjs +22 -0
- package/dist/lint/generic/index-barrel.mjs +14 -0
- package/dist/lint/generic/log-messages.mjs +39 -0
- package/dist/lint/generic/plugin.d.mts +6 -0
- package/dist/lint/generic/plugin.mjs +26 -0
- package/dist/lint/generic/seeded-properties.mjs +78 -0
- package/dist/lint/plugins.d.mts +9 -0
- package/dist/lint/plugins.mjs +14 -0
- package/dist/lint/t3code/LICENSE +21 -0
- package/dist/lint/t3code/UPSTREAM.md +24 -0
- package/dist/lint/t3code/plugin.d.mts +2 -0
- package/dist/lint/t3code/plugin.mjs +20 -0
- package/dist/lint/t3code/rules/no-global-process-runtime.mjs +76 -0
- package/dist/lint/t3code/rules/no-inline-schema-compile.mjs +112 -0
- package/dist/lint/t3code/rules/no-manual-effect-runtime-in-tests.mjs +67 -0
- package/dist/lint/t3code/rules/no-native-title-tooltip.mjs +33 -0
- package/dist/lint/t3code/rules/no-test-in-loop.mjs +69 -0
- package/dist/lint/t3code/rules/no-unscoped-has.mjs +147 -0
- package/dist/lint/t3code/utils.mjs +21 -0
- package/dist/package-exports.mjs +157 -0
- package/dist/symbols/check.mjs +209 -0
- package/dist/symbols/find.mjs +63 -0
- package/dist/symbols/symbols.mjs +390 -0
- package/dist/type-coverage.mjs +68 -0
- package/dist/types/cache.mjs +157 -0
- package/dist/types/inputs.mjs +71 -0
- package/dist/types/projects.mjs +65 -0
- package/dist/types/types.mjs +175 -0
- package/package.json +68 -3
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
import { createTypeAliasEnvironment, hasVisibleTypeBinding, visibleTypeAlias } from "./type-alias-resolution.mjs";
|
|
2
|
+
// src/lint/anti-slop/shared/dictionary-types.ts
|
|
3
|
+
const BUILT_INS = /* @__PURE__ */ new Set([
|
|
4
|
+
"Record",
|
|
5
|
+
"Readonly",
|
|
6
|
+
"Partial",
|
|
7
|
+
"Required",
|
|
8
|
+
"Pick",
|
|
9
|
+
"Omit",
|
|
10
|
+
"PropertyKey",
|
|
11
|
+
"NonNullable"
|
|
12
|
+
]);
|
|
13
|
+
const TRANSPARENT_WRAPPERS = /* @__PURE__ */ new Set([
|
|
14
|
+
"Readonly",
|
|
15
|
+
"Partial",
|
|
16
|
+
"Required",
|
|
17
|
+
"NonNullable"
|
|
18
|
+
]);
|
|
19
|
+
function declaredStatement(statement) {
|
|
20
|
+
return statement.type === "ExportNamedDeclaration" || statement.type === "ExportDefaultDeclaration" ? statement.declaration ?? null : statement;
|
|
21
|
+
}
|
|
22
|
+
function createTypeEnvironment(program, visitorKeys) {
|
|
23
|
+
const interfaces = /* @__PURE__ */ new Map();
|
|
24
|
+
for (const statement of program.body) {
|
|
25
|
+
const declaration = declaredStatement(statement);
|
|
26
|
+
if (declaration?.type !== "TSInterfaceDeclaration") continue;
|
|
27
|
+
const declarations = interfaces.get(declaration.id.name) ?? [];
|
|
28
|
+
declarations.push(declaration);
|
|
29
|
+
interfaces.set(declaration.id.name, declarations);
|
|
30
|
+
}
|
|
31
|
+
return {
|
|
32
|
+
interfaces,
|
|
33
|
+
typeAliases: createTypeAliasEnvironment(program, visitorKeys)
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
function typeReferenceName(type) {
|
|
37
|
+
return type.typeName.type === "Identifier" ? type.typeName.name : null;
|
|
38
|
+
}
|
|
39
|
+
function isBuiltIn(name, use, environment) {
|
|
40
|
+
return BUILT_INS.has(name) && !hasVisibleTypeBinding(name, use, environment.typeAliases);
|
|
41
|
+
}
|
|
42
|
+
function isUnappliedReferenceTo(type, name) {
|
|
43
|
+
const unwrapped = unwrapTransparentType(type);
|
|
44
|
+
return unwrapped.type === "TSTypeReference" && typeReferenceName(unwrapped) === name && (unwrapped.typeArguments === null || unwrapped.typeArguments === void 0 || unwrapped.typeArguments.params.length === 0);
|
|
45
|
+
}
|
|
46
|
+
function unwrapTransparentType(type) {
|
|
47
|
+
let current = type;
|
|
48
|
+
while (current.type === "TSParenthesizedType" || current.type === "TSTypeOperator" && current.operator === "readonly") current = current.typeAnnotation;
|
|
49
|
+
return current;
|
|
50
|
+
}
|
|
51
|
+
function isNeverType(type) {
|
|
52
|
+
return unwrapTransparentType(type).type === "TSNeverKeyword";
|
|
53
|
+
}
|
|
54
|
+
function isEffectivelyEmptyMember(member) {
|
|
55
|
+
return member.type === "TSPropertySignature" && member.optional === true && member.typeAnnotation !== null && member.typeAnnotation !== void 0 && isNeverType(member.typeAnnotation.typeAnnotation);
|
|
56
|
+
}
|
|
57
|
+
function isEffectivelyEmptyTypeLiteral(type) {
|
|
58
|
+
return type.members.length === 0 || type.members.every(isEffectivelyEmptyMember);
|
|
59
|
+
}
|
|
60
|
+
function isEffectivelyEmptyInterface(declarations) {
|
|
61
|
+
if (declarations.length !== 1) return false;
|
|
62
|
+
const [type] = declarations;
|
|
63
|
+
return type !== void 0 && type.extends.length === 0 && (type.body.body.length === 0 || type.body.body.every(isEffectivelyEmptyMember));
|
|
64
|
+
}
|
|
65
|
+
function resolvedSubstitutionArgument(type, base, resolving = /* @__PURE__ */ new Set()) {
|
|
66
|
+
const unwrapped = unwrapTransparentType(type);
|
|
67
|
+
if (unwrapped.type !== "TSTypeReference") return type;
|
|
68
|
+
const name = typeReferenceName(unwrapped);
|
|
69
|
+
if (name === null || resolving.has(name)) return type;
|
|
70
|
+
const substitution = base.get(name);
|
|
71
|
+
if (substitution === void 0) return type;
|
|
72
|
+
const nextResolving = new Set(resolving);
|
|
73
|
+
nextResolving.add(name);
|
|
74
|
+
return resolvedSubstitutionArgument(substitution, base, nextResolving);
|
|
75
|
+
}
|
|
76
|
+
function aliasSubstitution(alias, type, base) {
|
|
77
|
+
const parameters = alias.typeParameters?.params ?? [];
|
|
78
|
+
const arguments_ = type.typeArguments?.params ?? [];
|
|
79
|
+
const next = new Map(base);
|
|
80
|
+
for (const [index, parameter] of parameters.entries()) {
|
|
81
|
+
const argument = arguments_[index] ?? parameter.default;
|
|
82
|
+
if (argument === null || argument === void 0) return null;
|
|
83
|
+
next.set(parameter.name.name, resolvedSubstitutionArgument(argument, next));
|
|
84
|
+
}
|
|
85
|
+
return next;
|
|
86
|
+
}
|
|
87
|
+
function unsafeDirectValue(type, environment, substitutions, resolvingAliases) {
|
|
88
|
+
const unwrapped = unwrapTransparentType(type);
|
|
89
|
+
if (unwrapped.type === "TSUnknownKeyword") return "unknown";
|
|
90
|
+
if (unwrapped.type === "TSAnyKeyword") return "any";
|
|
91
|
+
if (unwrapped.type === "TSObjectKeyword") return "object";
|
|
92
|
+
if (unwrapped.type === "TSTypeLiteral" && isEffectivelyEmptyTypeLiteral(unwrapped)) return "empty-object";
|
|
93
|
+
if (unwrapped.type === "TSUnionType") return unwrapped.types.some((member) => unsafeDirectValue(member, environment, substitutions, resolvingAliases) !== null) ? "union" : null;
|
|
94
|
+
if (unwrapped.type === "TSIntersectionType") {
|
|
95
|
+
const unsafeMembers = unwrapped.types.map((member) => unsafeDirectValue(member, environment, substitutions, resolvingAliases));
|
|
96
|
+
if (unsafeMembers.includes("any")) return "any";
|
|
97
|
+
const [first] = unsafeMembers;
|
|
98
|
+
return first !== void 0 && unsafeMembers.every((member) => member !== null) ? first : null;
|
|
99
|
+
}
|
|
100
|
+
if (unwrapped.type !== "TSTypeReference") return null;
|
|
101
|
+
const name = typeReferenceName(unwrapped);
|
|
102
|
+
if (name === null) return null;
|
|
103
|
+
if (TRANSPARENT_WRAPPERS.has(name) && isBuiltIn(name, unwrapped, environment)) {
|
|
104
|
+
const wrapped = unwrapped.typeArguments?.params[0];
|
|
105
|
+
return wrapped === void 0 ? null : unsafeDirectValue(wrapped, environment, substitutions, resolvingAliases);
|
|
106
|
+
}
|
|
107
|
+
const substitution = substitutions.get(name);
|
|
108
|
+
if (substitution !== void 0) return isUnappliedReferenceTo(substitution, name) ? null : unsafeDirectValue(substitution, environment, substitutions, resolvingAliases);
|
|
109
|
+
const interfaceDeclarations = environment.interfaces.get(name);
|
|
110
|
+
if (interfaceDeclarations !== void 0) return isEffectivelyEmptyInterface(interfaceDeclarations) ? "empty-object" : null;
|
|
111
|
+
const alias = visibleTypeAlias(name, unwrapped, environment.typeAliases);
|
|
112
|
+
if (alias === null || resolvingAliases.has(name)) return null;
|
|
113
|
+
const nextSubstitutions = aliasSubstitution(alias, unwrapped, substitutions);
|
|
114
|
+
if (nextSubstitutions === null) return null;
|
|
115
|
+
const nextResolving = new Set(resolvingAliases);
|
|
116
|
+
nextResolving.add(name);
|
|
117
|
+
return unsafeDirectValue(alias.typeAnnotation, environment, nextSubstitutions, nextResolving);
|
|
118
|
+
}
|
|
119
|
+
function dictionaryValueTypes(type, environment, substitutions, resolvingAliases) {
|
|
120
|
+
const unwrapped = unwrapTransparentType(type);
|
|
121
|
+
if (unwrapped.type === "TSTypeLiteral") return unwrapped.members.flatMap((member) => member.type === "TSIndexSignature" && member.typeAnnotation !== null ? [{
|
|
122
|
+
type: member.typeAnnotation.typeAnnotation,
|
|
123
|
+
substitutions
|
|
124
|
+
}] : []);
|
|
125
|
+
if (unwrapped.type === "TSMappedType") return unwrapped.typeAnnotation === null ? [] : [{
|
|
126
|
+
type: unwrapped.typeAnnotation,
|
|
127
|
+
substitutions
|
|
128
|
+
}];
|
|
129
|
+
if (unwrapped.type !== "TSTypeReference") return [];
|
|
130
|
+
const name = typeReferenceName(unwrapped);
|
|
131
|
+
if (name === null) return [];
|
|
132
|
+
const substitution = substitutions.get(name);
|
|
133
|
+
if (substitution !== void 0) return isUnappliedReferenceTo(substitution, name) ? [] : dictionaryValueTypes(substitution, environment, substitutions, resolvingAliases);
|
|
134
|
+
if (TRANSPARENT_WRAPPERS.has(name) && isBuiltIn(name, unwrapped, environment)) {
|
|
135
|
+
const wrapped = unwrapped.typeArguments?.params[0];
|
|
136
|
+
return wrapped === void 0 ? [] : dictionaryValueTypes(wrapped, environment, substitutions, resolvingAliases);
|
|
137
|
+
}
|
|
138
|
+
if (name === "Record" && isBuiltIn(name, unwrapped, environment)) {
|
|
139
|
+
const value = unwrapped.typeArguments?.params[1] ?? null;
|
|
140
|
+
return value === null ? [] : [{
|
|
141
|
+
type: value,
|
|
142
|
+
substitutions
|
|
143
|
+
}];
|
|
144
|
+
}
|
|
145
|
+
if ((name === "Pick" || name === "Omit") && isBuiltIn(name, unwrapped, environment)) {
|
|
146
|
+
const source = unwrapped.typeArguments?.params[0];
|
|
147
|
+
return source === void 0 ? [] : dictionaryValueTypes(source, environment, substitutions, resolvingAliases);
|
|
148
|
+
}
|
|
149
|
+
const alias = visibleTypeAlias(name, unwrapped, environment.typeAliases);
|
|
150
|
+
if (alias === null || resolvingAliases.has(name)) return [];
|
|
151
|
+
const nextSubstitutions = aliasSubstitution(alias, unwrapped, substitutions);
|
|
152
|
+
if (nextSubstitutions === null) return [];
|
|
153
|
+
const nextResolving = new Set(resolvingAliases);
|
|
154
|
+
nextResolving.add(name);
|
|
155
|
+
return dictionaryValueTypes(alias.typeAnnotation, environment, nextSubstitutions, nextResolving);
|
|
156
|
+
}
|
|
157
|
+
function classifyUnsafeDictionaryValue(valueType, environment) {
|
|
158
|
+
const unsafeValue = unsafeDirectValue(valueType, environment, /* @__PURE__ */ new Map(), /* @__PURE__ */ new Set());
|
|
159
|
+
return unsafeValue === null ? null : {
|
|
160
|
+
kind: "unsafe-dictionary",
|
|
161
|
+
unsafeValue
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
function classifyUnsafeDictionary(type, environment) {
|
|
165
|
+
for (const valueType of dictionaryValueTypes(type, environment, /* @__PURE__ */ new Map(), /* @__PURE__ */ new Set())) {
|
|
166
|
+
const unsafeValue = unsafeDirectValue(valueType.type, environment, valueType.substitutions, /* @__PURE__ */ new Set());
|
|
167
|
+
if (unsafeValue !== null) return {
|
|
168
|
+
kind: "unsafe-dictionary",
|
|
169
|
+
unsafeValue
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
return null;
|
|
173
|
+
}
|
|
174
|
+
function classifyWideningTarget(type, environment) {
|
|
175
|
+
const unwrapped = unwrapTransparentType(type);
|
|
176
|
+
if (unwrapped.type === "TSUnknownKeyword") return { kind: "unknown" };
|
|
177
|
+
if (unwrapped.type === "TSObjectKeyword") return { kind: "object" };
|
|
178
|
+
if (unwrapped.type === "TSTypeLiteral") return unwrapped.members.some((member) => member.type === "TSIndexSignature") ? { kind: "open dictionary" } : unwrapped.members.length > 0 ? { kind: "anonymous object" } : null;
|
|
179
|
+
if (unwrapped.type === "TSMappedType") return { kind: "open dictionary" };
|
|
180
|
+
if (unwrapped.type !== "TSTypeReference") return null;
|
|
181
|
+
const name = typeReferenceName(unwrapped);
|
|
182
|
+
if (name === null) return null;
|
|
183
|
+
if (TRANSPARENT_WRAPPERS.has(name) && isBuiltIn(name, unwrapped, environment)) {
|
|
184
|
+
const wrapped = unwrapped.typeArguments?.params[0];
|
|
185
|
+
return wrapped === void 0 ? null : classifyWideningTarget(wrapped, environment);
|
|
186
|
+
}
|
|
187
|
+
if (name === "Record" && isBuiltIn(name, unwrapped, environment)) return hasBroadRecordKey(unwrapped, environment, /* @__PURE__ */ new Map()) ? { kind: "open dictionary" } : null;
|
|
188
|
+
const alias = visibleTypeAlias(name, unwrapped, environment.typeAliases);
|
|
189
|
+
if (alias === null) return null;
|
|
190
|
+
if ((alias.typeParameters?.params.length ?? 0) > 0) {
|
|
191
|
+
const substitutions = aliasSubstitution(alias, unwrapped, /* @__PURE__ */ new Map());
|
|
192
|
+
return (substitutions === null ? null : classifyAliasBroadTarget(alias.typeAnnotation, environment, substitutions, /* @__PURE__ */ new Set([name])))?.kind === "open dictionary" ? { kind: "generic container" } : null;
|
|
193
|
+
}
|
|
194
|
+
const substitutions = aliasSubstitution(alias, unwrapped, /* @__PURE__ */ new Map());
|
|
195
|
+
if (substitutions === null) return null;
|
|
196
|
+
return classifyAliasBroadTarget(alias.typeAnnotation, environment, substitutions, /* @__PURE__ */ new Set([name]));
|
|
197
|
+
}
|
|
198
|
+
function hasBroadRecordKey(type, environment, substitutions) {
|
|
199
|
+
const key = type.typeArguments?.params[0];
|
|
200
|
+
return key === void 0 || isBroadMappedKey(key, environment, substitutions);
|
|
201
|
+
}
|
|
202
|
+
function isBroadMappedKey(type, environment, substitutions, visitedAliases = /* @__PURE__ */ new Set()) {
|
|
203
|
+
const unwrapped = unwrapTransparentType(type);
|
|
204
|
+
if (unwrapped.type === "TSStringKeyword" || unwrapped.type === "TSNumberKeyword" || unwrapped.type === "TSSymbolKeyword") return true;
|
|
205
|
+
if (unwrapped.type === "TSUnionType") return unwrapped.types.some((member) => isBroadMappedKey(member, environment, substitutions, visitedAliases));
|
|
206
|
+
if (unwrapped.type !== "TSTypeReference") return false;
|
|
207
|
+
const name = typeReferenceName(unwrapped);
|
|
208
|
+
if (name === null) return false;
|
|
209
|
+
const substitution = substitutions.get(name);
|
|
210
|
+
if (substitution !== void 0 && !isUnappliedReferenceTo(substitution, name)) return isBroadMappedKey(substitution, environment, substitutions, visitedAliases);
|
|
211
|
+
if (name === "PropertyKey" && isBuiltIn(name, unwrapped, environment)) return true;
|
|
212
|
+
const alias = visibleTypeAlias(name, unwrapped, environment.typeAliases);
|
|
213
|
+
if (alias === null || (alias.typeParameters?.params.length ?? 0) > 0 || visitedAliases.has(name)) return false;
|
|
214
|
+
const nextVisited = new Set(visitedAliases);
|
|
215
|
+
nextVisited.add(name);
|
|
216
|
+
return isBroadMappedKey(alias.typeAnnotation, environment, substitutions, nextVisited);
|
|
217
|
+
}
|
|
218
|
+
function classifyAliasBroadTarget(type, environment, substitutions, resolvingAliases) {
|
|
219
|
+
const unwrapped = unwrapTransparentType(type);
|
|
220
|
+
if (unwrapped.type === "TSUnknownKeyword") return { kind: "unknown" };
|
|
221
|
+
if (unwrapped.type === "TSObjectKeyword") return { kind: "object" };
|
|
222
|
+
if (unwrapped.type === "TSTypeLiteral") return unwrapped.members.some((member) => member.type === "TSIndexSignature") ? { kind: "open dictionary" } : null;
|
|
223
|
+
if (unwrapped.type === "TSMappedType") return isBroadMappedKey(unwrapped.constraint, environment, substitutions) ? { kind: "open dictionary" } : null;
|
|
224
|
+
if (unwrapped.type !== "TSTypeReference") return null;
|
|
225
|
+
const name = typeReferenceName(unwrapped);
|
|
226
|
+
if (name === null) return null;
|
|
227
|
+
const substitution = substitutions.get(name);
|
|
228
|
+
if (substitution !== void 0) return isUnappliedReferenceTo(substitution, name) ? null : classifyAliasBroadTarget(substitution, environment, substitutions, resolvingAliases);
|
|
229
|
+
if (TRANSPARENT_WRAPPERS.has(name) && isBuiltIn(name, unwrapped, environment)) {
|
|
230
|
+
const wrapped = unwrapped.typeArguments?.params[0];
|
|
231
|
+
return wrapped === void 0 ? null : classifyAliasBroadTarget(wrapped, environment, substitutions, resolvingAliases);
|
|
232
|
+
}
|
|
233
|
+
if (name === "Record" && isBuiltIn(name, unwrapped, environment)) return hasBroadRecordKey(unwrapped, environment, substitutions) ? { kind: "open dictionary" } : null;
|
|
234
|
+
const alias = visibleTypeAlias(name, unwrapped, environment.typeAliases);
|
|
235
|
+
if (alias === null || resolvingAliases.has(name)) return null;
|
|
236
|
+
const nextSubstitutions = aliasSubstitution(alias, unwrapped, substitutions);
|
|
237
|
+
if (nextSubstitutions === null) return null;
|
|
238
|
+
const nextResolving = new Set(resolvingAliases);
|
|
239
|
+
nextResolving.add(name);
|
|
240
|
+
return classifyAliasBroadTarget(alias.typeAnnotation, environment, nextSubstitutions, nextResolving);
|
|
241
|
+
}
|
|
242
|
+
function isKnownEvidenceExpression(expression) {
|
|
243
|
+
let current = expression;
|
|
244
|
+
while (current.type === "ParenthesizedExpression" || current.type === "TSAsExpression" || current.type === "TSTypeAssertion" || current.type === "TSNonNullExpression" || current.type === "TSSatisfiesExpression") current = current.expression;
|
|
245
|
+
if (current.type === "ObjectExpression") return true;
|
|
246
|
+
return current.type === "ArrayExpression" || current.type === "ArrowFunctionExpression" || current.type === "ClassExpression" || current.type === "FunctionExpression" || current.type === "NewExpression" || current.type === "Literal" || current.type === "TemplateLiteral" || current.type === "UnaryExpression";
|
|
247
|
+
}
|
|
248
|
+
export { classifyUnsafeDictionary, classifyUnsafeDictionaryValue, classifyWideningTarget, createTypeEnvironment, isKnownEvidenceExpression };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// src/lint/anti-slop/shared/function-parameters.ts
|
|
2
|
+
/** Return whether a type is or contains TypeScript's absorbing unknown top type. */
|
|
3
|
+
function containsUnknownType(type) {
|
|
4
|
+
if (type.type === "TSUnknownKeyword") return true;
|
|
5
|
+
if (type.type === "TSParenthesizedType") return containsUnknownType(type.typeAnnotation);
|
|
6
|
+
return type.type === "TSUnionType" && type.types.some(containsUnknownType);
|
|
7
|
+
}
|
|
8
|
+
/** Return the TypeScript annotation attached to a function parameter or its wrapped binding. */
|
|
9
|
+
function functionParameterTypeAnnotation(parameter) {
|
|
10
|
+
if (parameter.type === "TSParameterProperty") return functionParameterTypeAnnotation(parameter.parameter);
|
|
11
|
+
if (parameter.type === "RestElement") return parameter.typeAnnotation ?? functionParameterTypeAnnotation(parameter.argument);
|
|
12
|
+
if (parameter.type === "AssignmentPattern") return parameter.typeAnnotation ?? functionParameterTypeAnnotation(parameter.left);
|
|
13
|
+
return parameter.typeAnnotation;
|
|
14
|
+
}
|
|
15
|
+
/** Return only a function parameter's local binding, excluding its annotation and default value. */
|
|
16
|
+
function functionParameterBindingName(parameter, sourceCode) {
|
|
17
|
+
if (parameter.type === "TSParameterProperty") return functionParameterBindingName(parameter.parameter, sourceCode);
|
|
18
|
+
if (parameter.type === "AssignmentPattern") return functionParameterBindingName(parameter.left, sourceCode);
|
|
19
|
+
if (parameter.type === "RestElement") return functionParameterBindingName(parameter.argument, sourceCode);
|
|
20
|
+
if (parameter.type === "Identifier") return parameter.name;
|
|
21
|
+
const sourceText = sourceCode.getText(parameter);
|
|
22
|
+
const annotationStart = parameter.typeAnnotation?.start;
|
|
23
|
+
return annotationStart === void 0 ? sourceText : sourceText.slice(0, annotationStart - parameter.start).trimEnd();
|
|
24
|
+
}
|
|
25
|
+
export { containsUnknownType, functionParameterBindingName, functionParameterTypeAnnotation };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { childNodes } from "./child-nodes.mjs";
|
|
2
|
+
// src/lint/anti-slop/shared/lexical-type-parameters.ts
|
|
3
|
+
function collectInferTypeParameterNames(node, visitorKeys, names) {
|
|
4
|
+
if (node.type === "TSInferType") names.add(node.typeParameter.name.name);
|
|
5
|
+
for (const child of childNodes(node, visitorKeys)) collectInferTypeParameterNames(child, visitorKeys, names);
|
|
6
|
+
}
|
|
7
|
+
/** Collect type binders that are in scope at a node and can shadow module aliases. */
|
|
8
|
+
function lexicalTypeParameterNames(node, visitorKeys) {
|
|
9
|
+
const names = /* @__PURE__ */ new Set();
|
|
10
|
+
let descendant = node;
|
|
11
|
+
let current = node;
|
|
12
|
+
while (current !== null && current.type !== "Program") {
|
|
13
|
+
if ("typeParameters" in current) for (const parameter of current.typeParameters?.params ?? []) names.add(parameter.name.name);
|
|
14
|
+
if (current.type === "TSMappedType" && (descendant === current.nameType || descendant === current.typeAnnotation)) names.add(current.key.name);
|
|
15
|
+
if (current.type === "TSConditionalType" && descendant === current.trueType) collectInferTypeParameterNames(current.extendsType, visitorKeys, names);
|
|
16
|
+
descendant = current;
|
|
17
|
+
current = current.parent;
|
|
18
|
+
}
|
|
19
|
+
return names;
|
|
20
|
+
}
|
|
21
|
+
export { lexicalTypeParameterNames };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { resolveVariable } from "./scope.mjs";
|
|
2
|
+
// src/lint/anti-slop/shared/reflect-method.ts
|
|
3
|
+
function isGlobalReflect(sourceCode, expression) {
|
|
4
|
+
if (expression.type !== "Identifier" || expression.name !== "Reflect") return false;
|
|
5
|
+
if (sourceCode.isGlobalReference(expression)) return true;
|
|
6
|
+
const variable = resolveVariable(sourceCode, expression);
|
|
7
|
+
return variable === null || variable.defs.length === 0;
|
|
8
|
+
}
|
|
9
|
+
/** Reports whether a call target names one method on the global Reflect object. */
|
|
10
|
+
function isGlobalReflectMethodCall(sourceCode, callee, methodName) {
|
|
11
|
+
if (!("property" in callee) || !("object" in callee) || !("computed" in callee)) return false;
|
|
12
|
+
if (!isGlobalReflect(sourceCode, callee.object)) return false;
|
|
13
|
+
const property = callee.property;
|
|
14
|
+
return callee.computed ? property.type === "Literal" && property.value === methodName : property.type === "Identifier" && property.name === methodName;
|
|
15
|
+
}
|
|
16
|
+
export { isGlobalReflectMethodCall };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// src/lint/anti-slop/shared/scope.ts
|
|
2
|
+
/** Resolve an identifier to its binding by walking lexical scopes upward. */
|
|
3
|
+
function resolveVariable(sourceCode, identifier) {
|
|
4
|
+
let scope = sourceCode.getScope(identifier);
|
|
5
|
+
while (scope !== null) {
|
|
6
|
+
const variable = scope.set.get(identifier.name);
|
|
7
|
+
if (variable !== void 0) return variable;
|
|
8
|
+
scope = scope.upper;
|
|
9
|
+
}
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
export { resolveVariable };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import * as Schema from "effect/Schema";
|
|
2
|
+
// src/lint/anti-slop/shared/string-literal.ts
|
|
3
|
+
const isString = Schema.is(Schema.String);
|
|
4
|
+
/** Whether `node` is a `Literal` whose value is a string. */
|
|
5
|
+
const isStringLiteral = (node) => node?.type === "Literal" && isString(node.value);
|
|
6
|
+
export { isStringLiteral };
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { childNodes } from "./child-nodes.mjs";
|
|
2
|
+
import { lexicalTypeParameterNames } from "./lexical-type-parameters.mjs";
|
|
3
|
+
// src/lint/anti-slop/shared/type-alias-resolution.ts
|
|
4
|
+
const environmentsByProgram = /* @__PURE__ */ new WeakMap();
|
|
5
|
+
function enclosingTypeScope(node) {
|
|
6
|
+
let current = node.parent;
|
|
7
|
+
while (current !== null) {
|
|
8
|
+
if (current.type === "Program" || current.type === "BlockStatement" || current.type === "TSModuleBlock" || current.type === "StaticBlock" || current.type === "SwitchStatement") return current;
|
|
9
|
+
current = current.parent;
|
|
10
|
+
}
|
|
11
|
+
return node;
|
|
12
|
+
}
|
|
13
|
+
function declaredTypeBinding(node) {
|
|
14
|
+
if (node.type === "TSTypeAliasDeclaration") return {
|
|
15
|
+
alias: node,
|
|
16
|
+
name: node.id.name
|
|
17
|
+
};
|
|
18
|
+
if (node.type === "TSInterfaceDeclaration" || node.type === "TSEnumDeclaration" || node.type === "ClassDeclaration" || node.type === "ClassExpression") return node.id === null ? null : {
|
|
19
|
+
alias: null,
|
|
20
|
+
name: node.id.name
|
|
21
|
+
};
|
|
22
|
+
if (node.type === "ImportSpecifier" || node.type === "ImportDefaultSpecifier" || node.type === "ImportNamespaceSpecifier") return {
|
|
23
|
+
alias: null,
|
|
24
|
+
name: node.local.name
|
|
25
|
+
};
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
function collectTypeBindings(node, visitorKeys, bindingsByName, aliases) {
|
|
29
|
+
const declared = declaredTypeBinding(node);
|
|
30
|
+
if (declared !== null) {
|
|
31
|
+
const bindings = bindingsByName.get(declared.name) ?? [];
|
|
32
|
+
bindings.push({
|
|
33
|
+
...declared,
|
|
34
|
+
scope: enclosingTypeScope(node)
|
|
35
|
+
});
|
|
36
|
+
bindingsByName.set(declared.name, bindings);
|
|
37
|
+
if (declared.alias !== null) aliases.push(declared.alias);
|
|
38
|
+
}
|
|
39
|
+
for (const child of childNodes(node, visitorKeys)) collectTypeBindings(child, visitorKeys, bindingsByName, aliases);
|
|
40
|
+
}
|
|
41
|
+
/** Collect every lexical type alias and competing type binding in a program. */
|
|
42
|
+
function createTypeAliasEnvironment(program, visitorKeys) {
|
|
43
|
+
const cached = environmentsByProgram.get(program);
|
|
44
|
+
if (cached !== void 0) return cached;
|
|
45
|
+
const bindingsByName = /* @__PURE__ */ new Map();
|
|
46
|
+
const aliases = [];
|
|
47
|
+
collectTypeBindings(program, visitorKeys, bindingsByName, aliases);
|
|
48
|
+
const environment = {
|
|
49
|
+
aliases,
|
|
50
|
+
bindingsByName,
|
|
51
|
+
visitorKeys
|
|
52
|
+
};
|
|
53
|
+
environmentsByProgram.set(program, environment);
|
|
54
|
+
return environment;
|
|
55
|
+
}
|
|
56
|
+
function ancestorDistance(ancestor, node) {
|
|
57
|
+
let current = node;
|
|
58
|
+
let distance = 0;
|
|
59
|
+
while (current !== null) {
|
|
60
|
+
if (current === ancestor) return distance;
|
|
61
|
+
current = current.parent;
|
|
62
|
+
distance += 1;
|
|
63
|
+
}
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
function nearestTypeBindings(name, use, environment) {
|
|
67
|
+
const candidates = environment.bindingsByName.get(name) ?? [];
|
|
68
|
+
let nearestDistance = Number.POSITIVE_INFINITY;
|
|
69
|
+
let nearest = [];
|
|
70
|
+
for (const candidate of candidates) {
|
|
71
|
+
const distance = ancestorDistance(candidate.scope, use);
|
|
72
|
+
if (distance === null || distance > nearestDistance) continue;
|
|
73
|
+
if (distance === nearestDistance) {
|
|
74
|
+
nearest.push(candidate);
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
nearestDistance = distance;
|
|
78
|
+
nearest = [candidate];
|
|
79
|
+
}
|
|
80
|
+
return nearest;
|
|
81
|
+
}
|
|
82
|
+
/** Resolve the nearest visible alias with this name, respecting lexical shadowing. */
|
|
83
|
+
function visibleTypeAlias(name, use, environment) {
|
|
84
|
+
if (lexicalTypeParameterNames(use, environment.visitorKeys).has(name)) return null;
|
|
85
|
+
const bindings = nearestTypeBindings(name, use, environment);
|
|
86
|
+
return bindings.length === 1 ? bindings[0]?.alias ?? null : null;
|
|
87
|
+
}
|
|
88
|
+
/** Return whether a local declaration shadows a built-in type at this use. */
|
|
89
|
+
function hasVisibleTypeBinding(name, use, environment) {
|
|
90
|
+
return lexicalTypeParameterNames(use, environment.visitorKeys).has(name) || nearestTypeBindings(name, use, environment).length > 0;
|
|
91
|
+
}
|
|
92
|
+
function typeReferenceName(type) {
|
|
93
|
+
return type.typeName.type === "Identifier" ? type.typeName.name : null;
|
|
94
|
+
}
|
|
95
|
+
function aliasSubstitutions(alias, reference, base) {
|
|
96
|
+
const parameters = alias.typeParameters?.params ?? [];
|
|
97
|
+
const arguments_ = reference.typeArguments?.params ?? [];
|
|
98
|
+
const next = new Map(base);
|
|
99
|
+
for (const [index, parameter] of parameters.entries()) {
|
|
100
|
+
const explicitArgument = arguments_[index];
|
|
101
|
+
const argument = explicitArgument ?? parameter.default;
|
|
102
|
+
if (argument === null || argument === void 0) return null;
|
|
103
|
+
const argumentSubstitutions = explicitArgument === void 0 ? next : base;
|
|
104
|
+
next.set(parameter.name.name, {
|
|
105
|
+
type: argument,
|
|
106
|
+
substitutions: new Map(argumentSubstitutions)
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
return next;
|
|
110
|
+
}
|
|
111
|
+
/** Match a type after resolving visible aliases and substituting their type parameters. */
|
|
112
|
+
function resolvedTypeMatches(type, environment, matcher) {
|
|
113
|
+
const evaluate = (current, substitutions, resolvingAliases) => {
|
|
114
|
+
if (current.type === "TSTypeReference") {
|
|
115
|
+
const name = typeReferenceName(current);
|
|
116
|
+
if (name !== null) {
|
|
117
|
+
const substitution = substitutions.get(name);
|
|
118
|
+
if (substitution !== void 0 && !current.typeArguments?.params.length) return evaluate(substitution.type, substitution.substitutions, resolvingAliases);
|
|
119
|
+
const alias = visibleTypeAlias(name, current, environment);
|
|
120
|
+
if (alias !== null && !resolvingAliases.has(alias)) {
|
|
121
|
+
const nextSubstitutions = aliasSubstitutions(alias, current, substitutions);
|
|
122
|
+
if (nextSubstitutions !== null) {
|
|
123
|
+
const nextResolving = new Set(resolvingAliases);
|
|
124
|
+
nextResolving.add(alias);
|
|
125
|
+
return evaluate(alias.typeAnnotation, nextSubstitutions, nextResolving);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
return matcher(current, (child) => evaluate(child, substitutions, resolvingAliases));
|
|
131
|
+
};
|
|
132
|
+
return evaluate(type, /* @__PURE__ */ new Map(), /* @__PURE__ */ new Set());
|
|
133
|
+
}
|
|
134
|
+
export { createTypeAliasEnvironment, hasVisibleTypeBinding, resolvedTypeMatches, visibleTypeAlias };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright OpenJS Foundation and other contributors, <www.openjsf.org>
|
|
4
|
+
Copyright (c) 2023-PRESENT ESLint Stylistic contributors
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
in the Software without restriction, including without limitation the rights
|
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
furnished to do so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
SOFTWARE.
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Vendored padding-line-between-statements
|
|
2
|
+
|
|
3
|
+
Source: [ESLint Stylistic](https://github.com/eslint-stylistic/eslint-stylistic), commit `435c3ea0fd26a5fef9042c4b36b6e165fbbf8d08`.
|
|
4
|
+
|
|
5
|
+
Copied files:
|
|
6
|
+
|
|
7
|
+
- `packages/eslint-plugin/rules/padding-line-between-statements/padding-line-between-statements.ts`
|
|
8
|
+
- `packages/eslint-plugin/rules/padding-line-between-statements/types.d.ts` → `padding-line-options.d.ts`
|
|
9
|
+
- Root `LICENSE`, retained verbatim. Both OpenJS Foundation and ESLint Stylistic notices apply.
|
|
10
|
+
|
|
11
|
+
The rule is MIT-licensed. Keep `LICENSE` with every redistributed copy, including skill assets. No Stylistic, ESLint, TypeScript-ESLint, or additional parser runtime dependency is required.
|
|
12
|
+
|
|
13
|
+
## Local adaptations
|
|
14
|
+
|
|
15
|
+
- Replace upstream type aliases with Oxlint's ESTree, context, token/comment, and rule types. Upstream's token type includes comments; Oxlint exposes those separately.
|
|
16
|
+
- Replace `AST_NODE_TYPES` enum members with identical string literals.
|
|
17
|
+
- Guard indexed reads for consuming repositories with `noUncheckedIndexedAccess`. Impossible missing AST/configuration entries raise explicit invariant errors rather than introducing new non-null assertions.
|
|
18
|
+
- Replace the repository-specific `createRule` factory with `createPaddingLineRule(options)`. The anti-slop wrapper supplies typed options directly; it exposes no user configuration options.
|
|
19
|
+
- Implement the small required AST helper surface in `padding-line-ast.ts` using Oxlint's public source-code/token API. `isParenthesized` only needs the one-pair check used to exclude parenthesized directive strings, not the upstream general-purpose overloads.
|
|
20
|
+
- Keep each statement's answer for each statement type, in `match` over upstream's matcher, now `matchUncached`. Each statement is matched as the next of one pair and the previous of the next, at `Program:exit`, after every selector has matched, so the answers can't change. It reports the same, faster.
|
|
21
|
+
- Retain the upstream statement matchers, scope tracking, comment-aware insertion/removal, selector support, and diagnostic text. Upstream naming and non-null assumptions remain localized here to keep future diffs reviewable; the file is not a model for new application code.
|
|
22
|
+
|
|
23
|
+
The opinionated policy lives outside this directory in `../../rules/require-readable-spacing.ts`. It adds spacing without collapsing existing blank lines. Short local bindings, consecutive imports, and adjacent overload signatures/implementation remain grouped. Spacing is syntactic, not an inference of business-logic boundaries.
|
|
24
|
+
|
|
25
|
+
## Updating and verification
|
|
26
|
+
|
|
27
|
+
Fetch an explicit upstream revision, compare the original rule and types against this revision, and port relevant fixes while retaining the adapters above. Update this record and preserve the license. Run `pnpm run check`.
|
|
28
|
+
|
|
29
|
+
The anti-slop source's focused RuleTester and CLI tests for `require-readable-spacing` weren't copied into this repository, and neither were upstream's JS/TS suites. Check a change here by linting files that break each spacing rule, before and after it.
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// src/lint/anti-slop/vendor/eslint-stylistic/padding-line-ast.ts
|
|
2
|
+
/** Line terminators recognized by the upstream padding matcher. */
|
|
3
|
+
const LINEBREAKS = /* @__PURE__ */ new Set([
|
|
4
|
+
"\r\n",
|
|
5
|
+
"\r",
|
|
6
|
+
"\n",
|
|
7
|
+
"\u2028",
|
|
8
|
+
"\u2029"
|
|
9
|
+
]);
|
|
10
|
+
/** Test a closing brace without treating comment text as punctuation. */
|
|
11
|
+
const isClosingBraceToken = (token) => token.type === "Punctuator" && token.value === "}";
|
|
12
|
+
/** Test a semicolon without treating comment text as punctuation. */
|
|
13
|
+
const isSemicolonToken = (token) => token.type === "Punctuator" && token.value === ";";
|
|
14
|
+
/** Filter the optional final semicolon when identifying block-like statements. */
|
|
15
|
+
const isNotSemicolonToken = (token) => !isSemicolonToken(token);
|
|
16
|
+
/** Compare token/node boundaries, including attached comments. */
|
|
17
|
+
const isTokenOnSameLine = (left, right) => left.loc.end.line === right.loc.start.line;
|
|
18
|
+
/** Recognize declarations and expressions used by the upstream IIFE matcher. */
|
|
19
|
+
const isFunction = (node) => node.type === "FunctionDeclaration" || node.type === "FunctionExpression" || node.type === "ArrowFunctionExpression";
|
|
20
|
+
/** Preserve the upstream multiline statement heuristic. */
|
|
21
|
+
const isSingleLine = (node) => node.loc.start.line === node.loc.end.line;
|
|
22
|
+
/** Unwrap optional chaining before checking IIFE syntax. */
|
|
23
|
+
const skipChainExpression = (node) => node.type === "ChainExpression" ? node.expression : node;
|
|
24
|
+
/** Only a program or function-body expression can begin a directive prologue. */
|
|
25
|
+
const isTopLevelExpressionStatement = (node) => node.type === "ExpressionStatement" && (node.parent.type === "Program" || node.parent.type === "BlockStatement" && isFunction(node.parent.parent));
|
|
26
|
+
/** A single wrapping pair suffices to exclude a string from directive syntax. */
|
|
27
|
+
function isParenthesized(node, sourceCode) {
|
|
28
|
+
const before = sourceCode.getTokenBefore(node);
|
|
29
|
+
const after = sourceCode.getTokenAfter(node);
|
|
30
|
+
return before?.value === "(" && after?.value === ")";
|
|
31
|
+
}
|
|
32
|
+
export { LINEBREAKS, isClosingBraceToken, isFunction, isNotSemicolonToken, isParenthesized, isSemicolonToken, isSingleLine, isTokenOnSameLine, isTopLevelExpressionStatement, skipChainExpression };
|