@pobammer-ts/eslint-cease-nonsense-rules 1.15.0 → 1.16.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/README.md +43 -0
- package/dist/build-metadata.json +3 -3
- package/dist/index.d.ts +2 -1
- package/dist/index.js +129 -21
- package/dist/rules/require-module-level-instantiation.d.ts +25 -0
- package/dist/utilities/configure-utilities.d.ts +7 -0
- package/package.json +12 -12
package/README.md
CHANGED
|
@@ -64,6 +64,7 @@ export default [
|
|
|
64
64
|
"cease-nonsense/prefer-singular-enums": "error",
|
|
65
65
|
"cease-nonsense/prefer-udim2-shorthand": "error",
|
|
66
66
|
"cease-nonsense/react-hooks-strict-return": "error",
|
|
67
|
+
"cease-nonsense/require-module-level-instantiation": "error",
|
|
67
68
|
"cease-nonsense/require-named-effect-functions": "error",
|
|
68
69
|
"cease-nonsense/require-paired-calls": "error",
|
|
69
70
|
"cease-nonsense/require-react-component-keys": "error",
|
|
@@ -1408,6 +1409,48 @@ class MyClass {
|
|
|
1408
1409
|
}
|
|
1409
1410
|
```
|
|
1410
1411
|
|
|
1412
|
+
#### `require-module-level-instantiation`
|
|
1413
|
+
|
|
1414
|
+
Require certain classes to be instantiated at module level rather than inside functions.
|
|
1415
|
+
|
|
1416
|
+
Classes like Log should be instantiated once at module scope, not recreated on every function call.
|
|
1417
|
+
|
|
1418
|
+
**Configuration**
|
|
1419
|
+
|
|
1420
|
+
```typescript
|
|
1421
|
+
{
|
|
1422
|
+
"cease-nonsense/require-module-level-instantiation": ["error", {
|
|
1423
|
+
"classes": {
|
|
1424
|
+
"Log": "@rbxts/rbxts-sleitnick-log",
|
|
1425
|
+
"Server": "@rbxts/net"
|
|
1426
|
+
}
|
|
1427
|
+
}]
|
|
1428
|
+
}
|
|
1429
|
+
```
|
|
1430
|
+
|
|
1431
|
+
**❌ Bad**
|
|
1432
|
+
|
|
1433
|
+
```typescript
|
|
1434
|
+
import Log from "@rbxts/rbxts-sleitnick-log";
|
|
1435
|
+
|
|
1436
|
+
function useStoryModesState() {
|
|
1437
|
+
const log = new Log(); // Recreated on every call!
|
|
1438
|
+
log.Info("Create Match clicked");
|
|
1439
|
+
}
|
|
1440
|
+
```
|
|
1441
|
+
|
|
1442
|
+
**✅ Good**
|
|
1443
|
+
|
|
1444
|
+
```typescript
|
|
1445
|
+
import Log from "@rbxts/rbxts-sleitnick-log";
|
|
1446
|
+
|
|
1447
|
+
const log = new Log(); // Module level - created once
|
|
1448
|
+
|
|
1449
|
+
function useStoryModesState() {
|
|
1450
|
+
log.Info("Create Match clicked");
|
|
1451
|
+
}
|
|
1452
|
+
```
|
|
1453
|
+
|
|
1411
1454
|
### Module Boundaries
|
|
1412
1455
|
|
|
1413
1456
|
#### `strict-component-boundaries`
|
package/dist/build-metadata.json
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -9,13 +9,14 @@ export type { NoMemoChildrenOptions } from "./rules/no-memo-children";
|
|
|
9
9
|
export type { NoShorthandOptions } from "./rules/no-shorthand-names";
|
|
10
10
|
export type { NoUselessUseSpringOptions } from "./rules/no-useless-use-spring";
|
|
11
11
|
export type { PreferEnumItemOptions } from "./rules/prefer-enum-item";
|
|
12
|
+
export type { RequireModuleLevelInstantiationOptions } from "./rules/require-module-level-instantiation";
|
|
12
13
|
export type { EffectFunctionOptions, HookConfiguration } from "./rules/require-named-effect-functions";
|
|
13
14
|
export type { PairConfiguration, RequirePairedCallsOptions } from "./rules/require-paired-calls";
|
|
14
15
|
export type { ReactKeysOptions } from "./rules/require-react-component-keys";
|
|
15
16
|
export type { RequireReactDisplayNamesOptions } from "./rules/require-react-display-names";
|
|
16
17
|
export type { HookEntry, UseExhaustiveDependenciesOptions } from "./rules/use-exhaustive-dependencies";
|
|
17
18
|
export type { EnvironmentMode } from "./types/environment-mode";
|
|
18
|
-
export { createBanInstancesOptions, createComplexityConfiguration, createEffectFunctionOptions, createHookConfiguration, createNoGodComponentsOptions, createNoInstanceMethodsOptions, createNoMemoChildrenOptions, createNoShorthandOptions, createNoUselessUseSpringOptions, createPairConfiguration, createPreferPatternReplacementsOptions, createReactKeysOptions, createRequirePairedCallsOptions, createRequireReactDisplayNamesOptions, createUseExhaustiveDependenciesOptions, createUseHookAtTopLevelOptions, defaultRobloxProfilePair, } from "./utilities/configure-utilities";
|
|
19
|
+
export { createBanInstancesOptions, createComplexityConfiguration, createEffectFunctionOptions, createHookConfiguration, createNoGodComponentsOptions, createNoInstanceMethodsOptions, createNoMemoChildrenOptions, createNoShorthandOptions, createNoUselessUseSpringOptions, createPairConfiguration, createPreferEnumItemOptions, createPreferPatternReplacementsOptions, createReactKeysOptions, createRequireModuleLevelInstantiationOptions, createRequirePairedCallsOptions, createRequireReactDisplayNamesOptions, createUseExhaustiveDependenciesOptions, createUseHookAtTopLevelOptions, defaultRobloxProfilePair, } from "./utilities/configure-utilities";
|
|
19
20
|
export type { Pattern, PreferPatternReplacementsOptions } from "./utilities/pattern-replacement";
|
|
20
21
|
export { pattern } from "./utilities/pattern-replacement";
|
|
21
22
|
/**
|
package/dist/index.js
CHANGED
|
@@ -22152,6 +22152,105 @@ var react_hooks_strict_return_default = createRule({
|
|
|
22152
22152
|
name: "react-hooks-strict-return"
|
|
22153
22153
|
});
|
|
22154
22154
|
|
|
22155
|
+
// src/rules/require-module-level-instantiation.ts
|
|
22156
|
+
var import_scope_manager4 = __toESM(require_dist2(), 1);
|
|
22157
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES14 } from "@typescript-eslint/utils";
|
|
22158
|
+
var isOptionsObject2 = Compile(build_default.Object({
|
|
22159
|
+
classes: build_default.Record(build_default.String(), build_default.String())
|
|
22160
|
+
}));
|
|
22161
|
+
function normalizeConfiguration(options3) {
|
|
22162
|
+
if (!isOptionsObject2.Check(options3))
|
|
22163
|
+
return { trackedImports: new Map };
|
|
22164
|
+
const { classes } = options3;
|
|
22165
|
+
const trackedImports = new Map;
|
|
22166
|
+
for (const [className, source] of Object.entries(classes))
|
|
22167
|
+
trackedImports.set(className, { className, source });
|
|
22168
|
+
return { trackedImports };
|
|
22169
|
+
}
|
|
22170
|
+
function isTopScope2({ type: type3 }) {
|
|
22171
|
+
return type3 === import_scope_manager4.ScopeType.module || type3 === import_scope_manager4.ScopeType.global;
|
|
22172
|
+
}
|
|
22173
|
+
var require_module_level_instantiation_default = createRule({
|
|
22174
|
+
create(context) {
|
|
22175
|
+
const { trackedImports } = normalizeConfiguration(context.options[0]);
|
|
22176
|
+
if (trackedImports.size === 0)
|
|
22177
|
+
return {};
|
|
22178
|
+
const localBindings = new Map;
|
|
22179
|
+
return {
|
|
22180
|
+
ImportDeclaration(node) {
|
|
22181
|
+
const source = node.source.value;
|
|
22182
|
+
for (const specifier of node.specifiers) {
|
|
22183
|
+
for (const [className, tracked] of trackedImports) {
|
|
22184
|
+
if (tracked.source !== source)
|
|
22185
|
+
continue;
|
|
22186
|
+
if (specifier.type === AST_NODE_TYPES14.ImportDefaultSpecifier && specifier.local.name === className) {
|
|
22187
|
+
localBindings.set(specifier.local.name, tracked);
|
|
22188
|
+
}
|
|
22189
|
+
if (specifier.type === AST_NODE_TYPES14.ImportSpecifier) {
|
|
22190
|
+
const importedName = specifier.imported.type === AST_NODE_TYPES14.Identifier ? specifier.imported.name : specifier.imported.value;
|
|
22191
|
+
if (importedName === className)
|
|
22192
|
+
localBindings.set(specifier.local.name, tracked);
|
|
22193
|
+
}
|
|
22194
|
+
}
|
|
22195
|
+
}
|
|
22196
|
+
},
|
|
22197
|
+
NewExpression(node) {
|
|
22198
|
+
let trackedInfo;
|
|
22199
|
+
let calleeName;
|
|
22200
|
+
if (node.callee.type === AST_NODE_TYPES14.Identifier) {
|
|
22201
|
+
calleeName = node.callee.name;
|
|
22202
|
+
trackedInfo = localBindings.get(calleeName);
|
|
22203
|
+
}
|
|
22204
|
+
if (node.callee.type === AST_NODE_TYPES14.MemberExpression) {
|
|
22205
|
+
const { property } = node.callee;
|
|
22206
|
+
if (property.type === AST_NODE_TYPES14.Identifier) {
|
|
22207
|
+
calleeName = property.name;
|
|
22208
|
+
trackedInfo = trackedImports.get(calleeName);
|
|
22209
|
+
}
|
|
22210
|
+
}
|
|
22211
|
+
if (!(trackedInfo && calleeName))
|
|
22212
|
+
return;
|
|
22213
|
+
const scope = context.sourceCode.getScope(node);
|
|
22214
|
+
if (isTopScope2(scope))
|
|
22215
|
+
return;
|
|
22216
|
+
context.report({
|
|
22217
|
+
data: {
|
|
22218
|
+
className: trackedInfo.className,
|
|
22219
|
+
source: trackedInfo.source
|
|
22220
|
+
},
|
|
22221
|
+
messageId: "mustBeModuleLevel",
|
|
22222
|
+
node
|
|
22223
|
+
});
|
|
22224
|
+
}
|
|
22225
|
+
};
|
|
22226
|
+
},
|
|
22227
|
+
defaultOptions: [{ classes: {} }],
|
|
22228
|
+
meta: {
|
|
22229
|
+
docs: {
|
|
22230
|
+
description: "Require certain classes to be instantiated at module level rather than inside functions. Classes like Log should be instantiated once at module scope, not recreated on every function call."
|
|
22231
|
+
},
|
|
22232
|
+
messages: {
|
|
22233
|
+
mustBeModuleLevel: "'{{className}}' from '{{source}}' must be instantiated at module level, not inside a function. Move `new {{className}}()` to the top of the file outside any function body. Instantiating inside functions recreates the object on every call, which wastes resources and may cause unexpected behavior."
|
|
22234
|
+
},
|
|
22235
|
+
schema: [
|
|
22236
|
+
{
|
|
22237
|
+
additionalProperties: false,
|
|
22238
|
+
properties: {
|
|
22239
|
+
classes: {
|
|
22240
|
+
additionalProperties: { type: "string" },
|
|
22241
|
+
description: "Map of class names to their import sources. Classes imported from these sources must be instantiated at module level.",
|
|
22242
|
+
type: "object"
|
|
22243
|
+
}
|
|
22244
|
+
},
|
|
22245
|
+
required: ["classes"],
|
|
22246
|
+
type: "object"
|
|
22247
|
+
}
|
|
22248
|
+
],
|
|
22249
|
+
type: "problem"
|
|
22250
|
+
},
|
|
22251
|
+
name: "require-module-level-instantiation"
|
|
22252
|
+
});
|
|
22253
|
+
|
|
22155
22254
|
// src/rules/require-named-effect-functions.ts
|
|
22156
22255
|
import { TSESTree as TSESTree9 } from "@typescript-eslint/types";
|
|
22157
22256
|
|
|
@@ -22511,7 +22610,7 @@ var requireNamedEffectFunctions = {
|
|
|
22511
22610
|
var require_named_effect_functions_default = requireNamedEffectFunctions;
|
|
22512
22611
|
|
|
22513
22612
|
// src/rules/require-paired-calls.ts
|
|
22514
|
-
import { AST_NODE_TYPES as
|
|
22613
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES15 } from "@typescript-eslint/types";
|
|
22515
22614
|
var isStringArray = Compile(build_default.Readonly(build_default.Array(build_default.String())));
|
|
22516
22615
|
var isPairConfiguration = Compile(build_default.Readonly(build_default.Object({
|
|
22517
22616
|
alternatives: build_default.Optional(isStringArray),
|
|
@@ -22529,20 +22628,20 @@ var isRuleOptions4 = Compile(build_default.Partial(build_default.Readonly(build_
|
|
|
22529
22628
|
pairs: build_default.Readonly(build_default.Array(isPairConfiguration))
|
|
22530
22629
|
}))));
|
|
22531
22630
|
var LOOP_NODE_TYPES = new Set([
|
|
22532
|
-
|
|
22533
|
-
|
|
22534
|
-
|
|
22535
|
-
|
|
22536
|
-
|
|
22631
|
+
AST_NODE_TYPES15.DoWhileStatement,
|
|
22632
|
+
AST_NODE_TYPES15.ForInStatement,
|
|
22633
|
+
AST_NODE_TYPES15.ForOfStatement,
|
|
22634
|
+
AST_NODE_TYPES15.ForStatement,
|
|
22635
|
+
AST_NODE_TYPES15.WhileStatement
|
|
22537
22636
|
]);
|
|
22538
22637
|
var DEFAULT_ROBLOX_YIELDING_FUNCTIONS = ["task.wait", "wait", "*.WaitForChild", "*.*Async"];
|
|
22539
22638
|
function getCallName(node) {
|
|
22540
22639
|
const { callee } = node;
|
|
22541
|
-
if (callee.type ===
|
|
22640
|
+
if (callee.type === AST_NODE_TYPES15.Identifier)
|
|
22542
22641
|
return callee.name;
|
|
22543
|
-
if (callee.type ===
|
|
22544
|
-
const object3 = callee.object.type ===
|
|
22545
|
-
const property = callee.property.type ===
|
|
22642
|
+
if (callee.type === AST_NODE_TYPES15.MemberExpression) {
|
|
22643
|
+
const object3 = callee.object.type === AST_NODE_TYPES15.Identifier ? callee.object.name : undefined;
|
|
22644
|
+
const property = callee.property.type === AST_NODE_TYPES15.Identifier ? callee.property.name : undefined;
|
|
22546
22645
|
if (object3 !== undefined && property !== undefined)
|
|
22547
22646
|
return `${object3}.${property}`;
|
|
22548
22647
|
}
|
|
@@ -22578,12 +22677,12 @@ function isLoopLikeStatement(node) {
|
|
|
22578
22677
|
return LOOP_NODE_TYPES.has(node.type);
|
|
22579
22678
|
}
|
|
22580
22679
|
function isSwitchStatement(node) {
|
|
22581
|
-
return node?.type ===
|
|
22680
|
+
return node?.type === AST_NODE_TYPES15.SwitchStatement;
|
|
22582
22681
|
}
|
|
22583
22682
|
function findLabeledStatementBody(label, startingNode) {
|
|
22584
22683
|
let current = startingNode;
|
|
22585
22684
|
while (current) {
|
|
22586
|
-
if (current.type ===
|
|
22685
|
+
if (current.type === AST_NODE_TYPES15.LabeledStatement && current.label.name === label.name)
|
|
22587
22686
|
return current.body;
|
|
22588
22687
|
current = current.parent ?? undefined;
|
|
22589
22688
|
}
|
|
@@ -22845,7 +22944,7 @@ var rule = {
|
|
|
22845
22944
|
function onIfConsequentExit(node) {
|
|
22846
22945
|
const consequentNode = node;
|
|
22847
22946
|
const { parent } = consequentNode;
|
|
22848
|
-
if (parent?.type ===
|
|
22947
|
+
if (parent?.type === AST_NODE_TYPES15.IfStatement) {
|
|
22849
22948
|
const branches = branchStacks.get(parent) ?? [];
|
|
22850
22949
|
branches.push(cloneStack());
|
|
22851
22950
|
branchStacks.set(parent, branches);
|
|
@@ -22860,7 +22959,7 @@ var rule = {
|
|
|
22860
22959
|
function onIfAlternateExit(node) {
|
|
22861
22960
|
const alternateNode = node;
|
|
22862
22961
|
const { parent } = alternateNode;
|
|
22863
|
-
if (parent?.type ===
|
|
22962
|
+
if (parent?.type === AST_NODE_TYPES15.IfStatement) {
|
|
22864
22963
|
const branches = branchStacks.get(parent) ?? [];
|
|
22865
22964
|
branches.push(cloneStack());
|
|
22866
22965
|
branchStacks.set(parent, branches);
|
|
@@ -22909,7 +23008,7 @@ var rule = {
|
|
|
22909
23008
|
function onTryBlockExit(node) {
|
|
22910
23009
|
const blockNode = node;
|
|
22911
23010
|
const { parent } = blockNode;
|
|
22912
|
-
if (parent?.type ===
|
|
23011
|
+
if (parent?.type === AST_NODE_TYPES15.TryStatement) {
|
|
22913
23012
|
const branches = branchStacks.get(parent) ?? [];
|
|
22914
23013
|
branches.push(cloneStack());
|
|
22915
23014
|
branchStacks.set(parent, branches);
|
|
@@ -22928,7 +23027,7 @@ var rule = {
|
|
|
22928
23027
|
function onCatchClauseExit(node) {
|
|
22929
23028
|
const catchNode = node;
|
|
22930
23029
|
const { parent } = catchNode;
|
|
22931
|
-
if (parent?.type ===
|
|
23030
|
+
if (parent?.type === AST_NODE_TYPES15.TryStatement) {
|
|
22932
23031
|
const branches = branchStacks.get(parent) ?? [];
|
|
22933
23032
|
branches.push(cloneStack());
|
|
22934
23033
|
branchStacks.set(parent, branches);
|
|
@@ -22991,7 +23090,7 @@ var rule = {
|
|
|
22991
23090
|
function onSwitchCaseExit(node) {
|
|
22992
23091
|
const caseNode = node;
|
|
22993
23092
|
const { parent } = caseNode;
|
|
22994
|
-
if (parent?.type ===
|
|
23093
|
+
if (parent?.type === AST_NODE_TYPES15.SwitchStatement) {
|
|
22995
23094
|
const branches = branchStacks.get(parent) ?? [];
|
|
22996
23095
|
branches.push(cloneStack());
|
|
22997
23096
|
branchStacks.set(parent, branches);
|
|
@@ -23022,7 +23121,7 @@ var rule = {
|
|
|
23022
23121
|
for (const { opener, config, node: node2 } of openerStack) {
|
|
23023
23122
|
const validClosers = getValidClosers(config);
|
|
23024
23123
|
const closer = validClosers.length === 1 ? validClosers[0] ?? "closer" : validClosers.join("' or '");
|
|
23025
|
-
const statementType = statementNode.type ===
|
|
23124
|
+
const statementType = statementNode.type === AST_NODE_TYPES15.ReturnStatement ? "return" : "throw";
|
|
23026
23125
|
const lineNumber = statementNode.loc?.start.line ?? 0;
|
|
23027
23126
|
context.report({
|
|
23028
23127
|
data: {
|
|
@@ -23039,7 +23138,7 @@ var rule = {
|
|
|
23039
23138
|
const statementNode = node;
|
|
23040
23139
|
if (openerStack.length === 0)
|
|
23041
23140
|
return;
|
|
23042
|
-
const targetLoop = statementNode.type ===
|
|
23141
|
+
const targetLoop = statementNode.type === AST_NODE_TYPES15.ContinueStatement ? resolveContinueTargetLoop(statementNode) : resolveBreakTargetLoop(statementNode);
|
|
23043
23142
|
if (!targetLoop)
|
|
23044
23143
|
return;
|
|
23045
23144
|
for (const { node: openerNode, config, opener, loopAncestors } of openerStack) {
|
|
@@ -23047,7 +23146,7 @@ var rule = {
|
|
|
23047
23146
|
continue;
|
|
23048
23147
|
const validClosers = getValidClosers(config);
|
|
23049
23148
|
const closer = validClosers.length === 1 ? validClosers[0] ?? "closer" : validClosers.join("' or '");
|
|
23050
|
-
const statementType = statementNode.type ===
|
|
23149
|
+
const statementType = statementNode.type === AST_NODE_TYPES15.BreakStatement ? "break" : "continue";
|
|
23051
23150
|
const lineNumber = statementNode.loc?.start.line ?? 0;
|
|
23052
23151
|
context.report({
|
|
23053
23152
|
data: {
|
|
@@ -23185,7 +23284,7 @@ var rule = {
|
|
|
23185
23284
|
continue;
|
|
23186
23285
|
const validClosers = getValidClosers(config);
|
|
23187
23286
|
const closer = validClosers.length === 1 ? validClosers[0] ?? "closer" : validClosers.join("' or '");
|
|
23188
|
-
const asyncType = asyncNode.type ===
|
|
23287
|
+
const asyncType = asyncNode.type === AST_NODE_TYPES15.AwaitExpression ? "await" : "yield";
|
|
23189
23288
|
context.report({
|
|
23190
23289
|
data: { asyncType, closer, opener },
|
|
23191
23290
|
messageId: "asyncViolation",
|
|
@@ -25186,9 +25285,15 @@ function createNoUselessUseSpringOptions(options3 = {}) {
|
|
|
25186
25285
|
function createPreferPatternReplacementsOptions(patterns2 = []) {
|
|
25187
25286
|
return { patterns: patterns2 };
|
|
25188
25287
|
}
|
|
25288
|
+
function createPreferEnumItemOptions(options3 = {}) {
|
|
25289
|
+
return { fixNumericToValue: false, performanceMode: false, ...options3 };
|
|
25290
|
+
}
|
|
25189
25291
|
function createRequireReactDisplayNamesOptions(options3 = {}) {
|
|
25190
25292
|
return { environment: "roblox-ts", ...options3 };
|
|
25191
25293
|
}
|
|
25294
|
+
function createRequireModuleLevelInstantiationOptions(options3 = {}) {
|
|
25295
|
+
return { classes: {}, ...options3 };
|
|
25296
|
+
}
|
|
25192
25297
|
|
|
25193
25298
|
// src/index.ts
|
|
25194
25299
|
var rules = {
|
|
@@ -25217,6 +25322,7 @@ var rules = {
|
|
|
25217
25322
|
"prefer-singular-enums": prefer_singular_enums_default,
|
|
25218
25323
|
"prefer-udim2-shorthand": prefer_udim2_shorthand_default,
|
|
25219
25324
|
"react-hooks-strict-return": react_hooks_strict_return_default,
|
|
25325
|
+
"require-module-level-instantiation": require_module_level_instantiation_default,
|
|
25220
25326
|
"require-named-effect-functions": require_named_effect_functions_default,
|
|
25221
25327
|
"require-paired-calls": require_paired_calls_default,
|
|
25222
25328
|
"require-react-component-keys": require_react_component_keys_default,
|
|
@@ -25264,8 +25370,10 @@ export {
|
|
|
25264
25370
|
createUseExhaustiveDependenciesOptions,
|
|
25265
25371
|
createRequireReactDisplayNamesOptions,
|
|
25266
25372
|
createRequirePairedCallsOptions,
|
|
25373
|
+
createRequireModuleLevelInstantiationOptions,
|
|
25267
25374
|
createReactKeysOptions,
|
|
25268
25375
|
createPreferPatternReplacementsOptions,
|
|
25376
|
+
createPreferEnumItemOptions,
|
|
25269
25377
|
createPairConfiguration,
|
|
25270
25378
|
createNoUselessUseSpringOptions,
|
|
25271
25379
|
createNoShorthandOptions,
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { TSESLint } from "@typescript-eslint/utils";
|
|
2
|
+
import type { ReadonlyRecord } from "../types/utility-types";
|
|
3
|
+
/**
|
|
4
|
+
* Configuration for classes that must be instantiated at module level.
|
|
5
|
+
*
|
|
6
|
+
* Maps class names to their expected import sources.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* {
|
|
11
|
+
* classes: {
|
|
12
|
+
* "Log": "@rbxts/rbxts-sleitnick-log",
|
|
13
|
+
* "Server": "@rbxts/net"
|
|
14
|
+
* }
|
|
15
|
+
* }
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export interface RequireModuleLevelInstantiationOptions {
|
|
19
|
+
readonly classes: ReadonlyRecord<string, string>;
|
|
20
|
+
}
|
|
21
|
+
type Options = [RequireModuleLevelInstantiationOptions?];
|
|
22
|
+
declare const _default: TSESLint.RuleModule<"mustBeModuleLevel", Options, unknown, TSESLint.RuleListener> & {
|
|
23
|
+
name: string;
|
|
24
|
+
};
|
|
25
|
+
export default _default;
|
|
@@ -6,6 +6,7 @@ import type { NoMemoChildrenOptions } from "../rules/no-memo-children";
|
|
|
6
6
|
import type { NoShorthandOptions } from "../rules/no-shorthand-names";
|
|
7
7
|
import type { NoUselessUseSpringOptions } from "../rules/no-useless-use-spring";
|
|
8
8
|
import type { PreferEnumItemOptions } from "../rules/prefer-enum-item";
|
|
9
|
+
import type { RequireModuleLevelInstantiationOptions } from "../rules/require-module-level-instantiation";
|
|
9
10
|
import type { EffectFunctionOptions, HookConfiguration } from "../rules/require-named-effect-functions";
|
|
10
11
|
import type { PairConfiguration, RequirePairedCallsOptions } from "../rules/require-paired-calls";
|
|
11
12
|
import type { ReactKeysOptions } from "../rules/require-react-component-keys";
|
|
@@ -122,3 +123,9 @@ export declare function createPreferEnumItemOptions(options?: Partial<PreferEnum
|
|
|
122
123
|
* @returns The full options
|
|
123
124
|
*/
|
|
124
125
|
export declare function createRequireReactDisplayNamesOptions(options?: Partial<RequireReactDisplayNamesOptions>): RequireReactDisplayNamesOptions;
|
|
126
|
+
/**
|
|
127
|
+
* Creates options for require-module-level-instantiation rule
|
|
128
|
+
* @param options - Partial configuration options
|
|
129
|
+
* @returns The full options
|
|
130
|
+
*/
|
|
131
|
+
export declare function createRequireModuleLevelInstantiationOptions(options?: Partial<RequireModuleLevelInstantiationOptions>): RequireModuleLevelInstantiationOptions;
|
package/package.json
CHANGED
|
@@ -85,24 +85,24 @@
|
|
|
85
85
|
"url": "git+https://github.com/howmanysmall/eslint-cease-nonsense-rules.git"
|
|
86
86
|
},
|
|
87
87
|
"scripts": {
|
|
88
|
-
"biome:ci": "
|
|
88
|
+
"biome:ci": "biome ci",
|
|
89
89
|
"build": "./scripts/build.ts",
|
|
90
|
-
"build:legacy": "
|
|
91
|
-
"dev": "
|
|
92
|
-
"format": "
|
|
93
|
-
"knip": "
|
|
94
|
-
"lint": "bun run oxc . && bun x --bun biome
|
|
95
|
-
"lint:fix": "bun run oxc . --fix && bun x --bun biome
|
|
96
|
-
"oxc": "
|
|
97
|
-
"prepare": "
|
|
90
|
+
"build:legacy": "tsgo -p tsconfig.json",
|
|
91
|
+
"dev": "tsgo -w",
|
|
92
|
+
"format": "oxfmt",
|
|
93
|
+
"knip": "knip-bun",
|
|
94
|
+
"lint": "bun run oxc . && bun x --bun biome check .",
|
|
95
|
+
"lint:fix": "bun run oxc . --fix && bun x --bun biome check . --fix",
|
|
96
|
+
"oxc": "oxlint --type-aware",
|
|
97
|
+
"prepare": "simple-git-hooks",
|
|
98
98
|
"prepublishOnly": "bun run build",
|
|
99
99
|
"release": "bumpp",
|
|
100
100
|
"test": "bun test",
|
|
101
|
-
"type-check": "
|
|
102
|
-
"type-check:safe": "
|
|
101
|
+
"type-check": "tsgo --noEmit",
|
|
102
|
+
"type-check:safe": "tsc --noEmit"
|
|
103
103
|
},
|
|
104
104
|
"sideEffects": false,
|
|
105
105
|
"type": "module",
|
|
106
106
|
"types": "./dist/index.d.ts",
|
|
107
|
-
"version": "1.
|
|
107
|
+
"version": "1.16.0"
|
|
108
108
|
}
|