@pobammer-ts/eslint-cease-nonsense-rules 1.14.1 → 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 +115 -0
- package/dist/build-metadata.json +3 -3
- package/dist/constants/react-sources.d.ts +4 -0
- package/dist/index.d.ts +6 -3
- package/dist/index.js +529 -221
- package/dist/oxfmt-sync.d.ts +0 -1
- package/dist/oxfmt-worker.d.ts +0 -1
- package/dist/oxfmt-worker.js +0 -2
- package/dist/recognizers/camel-case-detector.d.ts +0 -1
- package/dist/recognizers/code-recognizer.d.ts +0 -1
- package/dist/recognizers/contains-detector.d.ts +0 -1
- package/dist/recognizers/detector.d.ts +0 -1
- package/dist/recognizers/end-with-detector.d.ts +0 -1
- package/dist/recognizers/javascript-footprint.d.ts +0 -1
- package/dist/recognizers/keywords-detector.d.ts +0 -1
- package/dist/rules/ban-instances.d.ts +0 -1
- package/dist/rules/ban-react-fc.d.ts +0 -1
- package/dist/rules/enforce-ianitor-check-type.d.ts +0 -1
- package/dist/rules/fast-format.d.ts +0 -1
- package/dist/rules/no-async-constructor.d.ts +0 -1
- package/dist/rules/no-color3-constructor.d.ts +0 -1
- package/dist/rules/no-commented-code.d.ts +0 -1
- package/dist/rules/no-god-components.d.ts +0 -1
- package/dist/rules/no-identity-map.d.ts +0 -1
- package/dist/rules/no-instance-methods-without-this.d.ts +0 -1
- package/dist/rules/no-memo-children.d.ts +19 -0
- package/dist/rules/no-print.d.ts +0 -1
- package/dist/rules/no-shorthand-names.d.ts +0 -1
- package/dist/rules/no-useless-use-spring.d.ts +0 -1
- package/dist/rules/no-warn.d.ts +0 -1
- package/dist/rules/prefer-class-properties.d.ts +0 -1
- package/dist/rules/prefer-early-return.d.ts +0 -1
- package/dist/rules/prefer-enum-item.d.ts +0 -1
- package/dist/rules/prefer-module-scope-constants.d.ts +0 -1
- package/dist/rules/prefer-pascal-case-enums.d.ts +0 -1
- package/dist/rules/prefer-pattern-replacements.d.ts +0 -1
- package/dist/rules/prefer-sequence-overloads.d.ts +0 -1
- package/dist/rules/prefer-singular-enums.d.ts +0 -1
- package/dist/rules/prefer-udim2-shorthand.d.ts +0 -1
- package/dist/rules/react-hooks-strict-return.d.ts +0 -1
- package/dist/rules/require-module-level-instantiation.d.ts +25 -0
- package/dist/rules/require-named-effect-functions.d.ts +1 -4
- package/dist/rules/require-paired-calls.d.ts +0 -1
- package/dist/rules/require-react-component-keys.d.ts +0 -1
- package/dist/rules/require-react-display-names.d.ts +1 -2
- package/dist/rules/strict-component-boundaries.d.ts +5 -2
- package/dist/rules/use-exhaustive-dependencies.d.ts +0 -1
- package/dist/rules/use-hook-at-top-level.d.ts +0 -1
- package/dist/types/environment-mode.d.ts +3 -0
- package/dist/utilities/casing-utilities.d.ts +0 -1
- package/dist/utilities/configure-utilities.d.ts +14 -1
- package/dist/utilities/create-rule.d.ts +0 -1
- package/dist/utilities/format-utilities.d.ts +0 -1
- package/dist/utilities/pattern-replacement/constant-folder.d.ts +0 -1
- package/dist/utilities/pattern-replacement/index.d.ts +0 -1
- package/dist/utilities/pattern-replacement/pattern-matcher.d.ts +0 -1
- package/dist/utilities/pattern-replacement/pattern-parser.d.ts +0 -1
- package/dist/utilities/pattern-replacement/pattern-types.d.ts +0 -1
- package/dist/utilities/pattern-replacement/replacement-generator.d.ts +0 -1
- package/dist/utilities/resolve-import.d.ts +0 -1
- package/package.json +14 -13
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -725
- package/dist/oxfmt-sync.d.ts.map +0 -1
- package/dist/oxfmt-worker.d.ts.map +0 -1
- package/dist/oxfmt-worker.js.map +0 -10
- package/dist/recognizers/camel-case-detector.d.ts.map +0 -1
- package/dist/recognizers/code-recognizer.d.ts.map +0 -1
- package/dist/recognizers/contains-detector.d.ts.map +0 -1
- package/dist/recognizers/detector.d.ts.map +0 -1
- package/dist/recognizers/end-with-detector.d.ts.map +0 -1
- package/dist/recognizers/javascript-footprint.d.ts.map +0 -1
- package/dist/recognizers/keywords-detector.d.ts.map +0 -1
- package/dist/rules/ban-instances.d.ts.map +0 -1
- package/dist/rules/ban-react-fc.d.ts.map +0 -1
- package/dist/rules/enforce-ianitor-check-type.d.ts.map +0 -1
- package/dist/rules/fast-format.d.ts.map +0 -1
- package/dist/rules/no-async-constructor.d.ts.map +0 -1
- package/dist/rules/no-color3-constructor.d.ts.map +0 -1
- package/dist/rules/no-commented-code.d.ts.map +0 -1
- package/dist/rules/no-god-components.d.ts.map +0 -1
- package/dist/rules/no-identity-map.d.ts.map +0 -1
- package/dist/rules/no-instance-methods-without-this.d.ts.map +0 -1
- package/dist/rules/no-print.d.ts.map +0 -1
- package/dist/rules/no-shorthand-names.d.ts.map +0 -1
- package/dist/rules/no-useless-use-spring.d.ts.map +0 -1
- package/dist/rules/no-warn.d.ts.map +0 -1
- package/dist/rules/prefer-class-properties.d.ts.map +0 -1
- package/dist/rules/prefer-early-return.d.ts.map +0 -1
- package/dist/rules/prefer-enum-item.d.ts.map +0 -1
- package/dist/rules/prefer-module-scope-constants.d.ts.map +0 -1
- package/dist/rules/prefer-pascal-case-enums.d.ts.map +0 -1
- package/dist/rules/prefer-pattern-replacements.d.ts.map +0 -1
- package/dist/rules/prefer-sequence-overloads.d.ts.map +0 -1
- package/dist/rules/prefer-singular-enums.d.ts.map +0 -1
- package/dist/rules/prefer-udim2-shorthand.d.ts.map +0 -1
- package/dist/rules/react-hooks-strict-return.d.ts.map +0 -1
- package/dist/rules/require-named-effect-functions.d.ts.map +0 -1
- package/dist/rules/require-paired-calls.d.ts.map +0 -1
- package/dist/rules/require-react-component-keys.d.ts.map +0 -1
- package/dist/rules/require-react-display-names.d.ts.map +0 -1
- package/dist/rules/strict-component-boundaries.d.ts.map +0 -1
- package/dist/rules/use-exhaustive-dependencies.d.ts.map +0 -1
- package/dist/rules/use-hook-at-top-level.d.ts.map +0 -1
- package/dist/utilities/casing-utilities.d.ts.map +0 -1
- package/dist/utilities/configure-utilities.d.ts.map +0 -1
- package/dist/utilities/create-rule.d.ts.map +0 -1
- package/dist/utilities/format-utilities.d.ts.map +0 -1
- package/dist/utilities/pattern-replacement/constant-folder.d.ts.map +0 -1
- package/dist/utilities/pattern-replacement/index.d.ts.map +0 -1
- package/dist/utilities/pattern-replacement/pattern-matcher.d.ts.map +0 -1
- package/dist/utilities/pattern-replacement/pattern-parser.d.ts.map +0 -1
- package/dist/utilities/pattern-replacement/pattern-types.d.ts.map +0 -1
- package/dist/utilities/pattern-replacement/replacement-generator.d.ts.map +0 -1
- package/dist/utilities/resolve-import.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -49,6 +49,7 @@ export default [
|
|
|
49
49
|
"cease-nonsense/no-god-components": "error",
|
|
50
50
|
"cease-nonsense/no-identity-map": "error",
|
|
51
51
|
"cease-nonsense/no-instance-methods-without-this": "error",
|
|
52
|
+
"cease-nonsense/no-memo-children": "error",
|
|
52
53
|
"cease-nonsense/no-print": "error",
|
|
53
54
|
"cease-nonsense/prefer-enum-item": "error",
|
|
54
55
|
"cease-nonsense/no-shorthand-names": "error",
|
|
@@ -63,6 +64,7 @@ export default [
|
|
|
63
64
|
"cease-nonsense/prefer-singular-enums": "error",
|
|
64
65
|
"cease-nonsense/prefer-udim2-shorthand": "error",
|
|
65
66
|
"cease-nonsense/react-hooks-strict-return": "error",
|
|
67
|
+
"cease-nonsense/require-module-level-instantiation": "error",
|
|
66
68
|
"cease-nonsense/require-named-effect-functions": "error",
|
|
67
69
|
"cease-nonsense/require-paired-calls": "error",
|
|
68
70
|
"cease-nonsense/require-react-component-keys": "error",
|
|
@@ -215,6 +217,77 @@ function Input() {
|
|
|
215
217
|
}
|
|
216
218
|
```
|
|
217
219
|
|
|
220
|
+
#### `no-memo-children`
|
|
221
|
+
|
|
222
|
+
Disallow `React.memo` on components that accept a `children` prop, since children typically change on every render and defeat memoization.
|
|
223
|
+
|
|
224
|
+
**Why**
|
|
225
|
+
|
|
226
|
+
`React.memo` performs a shallow comparison of props. When a component accepts `children`, the `children` prop is typically a new JSX element on every parent render. This causes the shallow comparison to fail every time, making `memo` useless while adding overhead.
|
|
227
|
+
|
|
228
|
+
**Configuration**
|
|
229
|
+
|
|
230
|
+
```typescript
|
|
231
|
+
{
|
|
232
|
+
"cease-nonsense/no-memo-children": ["error", {
|
|
233
|
+
"allowedComponents": ["Modal", "Drawer"], // Allow specific components
|
|
234
|
+
"environment": "roblox-ts" // or "standard"
|
|
235
|
+
}]
|
|
236
|
+
}
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
**❌ Bad**
|
|
240
|
+
|
|
241
|
+
```typescript
|
|
242
|
+
import { memo, ReactNode } from "@rbxts/react";
|
|
243
|
+
|
|
244
|
+
interface CardProps {
|
|
245
|
+
readonly title: string;
|
|
246
|
+
readonly children?: ReactNode;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
// memo is useless - children change every render
|
|
250
|
+
const Card = memo<CardProps>(({ title, children }) => {
|
|
251
|
+
return (
|
|
252
|
+
<frame>
|
|
253
|
+
<textlabel Text={title} />
|
|
254
|
+
{children}
|
|
255
|
+
</frame>
|
|
256
|
+
);
|
|
257
|
+
});
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
**✅ Good**
|
|
261
|
+
|
|
262
|
+
```typescript
|
|
263
|
+
import { memo, ReactNode } from "@rbxts/react";
|
|
264
|
+
|
|
265
|
+
// Option 1: Remove memo if you need children
|
|
266
|
+
interface CardProps {
|
|
267
|
+
readonly title: string;
|
|
268
|
+
readonly children?: ReactNode;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
function Card({ title, children }: CardProps) {
|
|
272
|
+
return (
|
|
273
|
+
<frame>
|
|
274
|
+
<textlabel Text={title} />
|
|
275
|
+
{children}
|
|
276
|
+
</frame>
|
|
277
|
+
);
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
// Option 2: Use render prop instead of children
|
|
281
|
+
interface ListProps<T> {
|
|
282
|
+
readonly items: ReadonlyArray<T>;
|
|
283
|
+
readonly renderItem: (item: T) => ReactNode;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
const List = memo(<T,>({ items, renderItem }: ListProps<T>) => {
|
|
287
|
+
return <frame>{items.map(renderItem)}</frame>;
|
|
288
|
+
});
|
|
289
|
+
```
|
|
290
|
+
|
|
218
291
|
#### `no-god-components`
|
|
219
292
|
|
|
220
293
|
Flags React components that are too large or doing too much, encouraging better separation of concerns.
|
|
@@ -1336,6 +1409,48 @@ class MyClass {
|
|
|
1336
1409
|
}
|
|
1337
1410
|
```
|
|
1338
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
|
+
|
|
1339
1454
|
### Module Boundaries
|
|
1340
1455
|
|
|
1341
1456
|
#### `strict-component-boundaries`
|
package/dist/build-metadata.json
CHANGED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { TSESTree } from "@typescript-eslint/types";
|
|
2
|
+
import type { EnvironmentMode } from "../types/environment-mode";
|
|
3
|
+
export declare function getReactSources(environment: EnvironmentMode): Set<string>;
|
|
4
|
+
export declare function isReactImport(node: TSESTree.ImportDeclaration, reactSources: Set<string>): boolean;
|
package/dist/index.d.ts
CHANGED
|
@@ -5,15 +5,18 @@ export type { ComplexityConfiguration } from "./rules/enforce-ianitor-check-type
|
|
|
5
5
|
export type { NoGodComponentsOptions } from "./rules/no-god-components";
|
|
6
6
|
export type { NoIdentityMapOptions } from "./rules/no-identity-map";
|
|
7
7
|
export type { NoInstanceMethodsOptions } from "./rules/no-instance-methods-without-this";
|
|
8
|
+
export type { NoMemoChildrenOptions } from "./rules/no-memo-children";
|
|
8
9
|
export type { NoShorthandOptions } from "./rules/no-shorthand-names";
|
|
9
10
|
export type { NoUselessUseSpringOptions } from "./rules/no-useless-use-spring";
|
|
10
11
|
export type { PreferEnumItemOptions } from "./rules/prefer-enum-item";
|
|
11
|
-
export type {
|
|
12
|
+
export type { RequireModuleLevelInstantiationOptions } from "./rules/require-module-level-instantiation";
|
|
13
|
+
export type { EffectFunctionOptions, HookConfiguration } from "./rules/require-named-effect-functions";
|
|
12
14
|
export type { PairConfiguration, RequirePairedCallsOptions } from "./rules/require-paired-calls";
|
|
13
15
|
export type { ReactKeysOptions } from "./rules/require-react-component-keys";
|
|
14
16
|
export type { RequireReactDisplayNamesOptions } from "./rules/require-react-display-names";
|
|
15
17
|
export type { HookEntry, UseExhaustiveDependenciesOptions } from "./rules/use-exhaustive-dependencies";
|
|
16
|
-
export {
|
|
18
|
+
export type { EnvironmentMode } from "./types/environment-mode";
|
|
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";
|
|
17
20
|
export type { Pattern, PreferPatternReplacementsOptions } from "./utilities/pattern-replacement";
|
|
18
21
|
export { pattern } from "./utilities/pattern-replacement";
|
|
19
22
|
/**
|
|
@@ -47,6 +50,7 @@ declare const recommended: {
|
|
|
47
50
|
readonly "cease-nonsense/no-god-components": "error";
|
|
48
51
|
readonly "cease-nonsense/no-identity-map": "error";
|
|
49
52
|
readonly "cease-nonsense/no-instance-methods-without-this": "error";
|
|
53
|
+
readonly "cease-nonsense/no-memo-children": "error";
|
|
50
54
|
readonly "cease-nonsense/no-print": "error";
|
|
51
55
|
readonly "cease-nonsense/no-shorthand-names": "error";
|
|
52
56
|
readonly "cease-nonsense/no-warn": "error";
|
|
@@ -68,4 +72,3 @@ interface Plugin {
|
|
|
68
72
|
}
|
|
69
73
|
declare const plugin: Plugin;
|
|
70
74
|
export default plugin;
|
|
71
|
-
//# sourceMappingURL=index.d.ts.map
|