@pobammer-ts/eslint-cease-nonsense-rules 1.14.0 → 1.15.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 +74 -1
- package/dist/build-metadata.json +3 -3
- package/dist/constants/react-sources.d.ts +4 -0
- package/dist/index.d.ts +5 -3
- package/dist/index.js +1430 -271
- 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 +1 -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-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 +7 -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 +6 -4
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -724
- 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",
|
|
@@ -147,7 +148,8 @@ Enforce using EnumItem values instead of string or number literals when the type
|
|
|
147
148
|
```typescript
|
|
148
149
|
{
|
|
149
150
|
"cease-nonsense/prefer-enum-item": ["error", {
|
|
150
|
-
"fixNumericToValue": false // When true, numbers fix to Enum.X.Y.Value
|
|
151
|
+
"fixNumericToValue": false, // When true, numbers fix to Enum.X.Y.Value
|
|
152
|
+
"performanceMode": false // When true, cache enum lookups
|
|
151
153
|
}]
|
|
152
154
|
}
|
|
153
155
|
```
|
|
@@ -214,6 +216,77 @@ function Input() {
|
|
|
214
216
|
}
|
|
215
217
|
```
|
|
216
218
|
|
|
219
|
+
#### `no-memo-children`
|
|
220
|
+
|
|
221
|
+
Disallow `React.memo` on components that accept a `children` prop, since children typically change on every render and defeat memoization.
|
|
222
|
+
|
|
223
|
+
**Why**
|
|
224
|
+
|
|
225
|
+
`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.
|
|
226
|
+
|
|
227
|
+
**Configuration**
|
|
228
|
+
|
|
229
|
+
```typescript
|
|
230
|
+
{
|
|
231
|
+
"cease-nonsense/no-memo-children": ["error", {
|
|
232
|
+
"allowedComponents": ["Modal", "Drawer"], // Allow specific components
|
|
233
|
+
"environment": "roblox-ts" // or "standard"
|
|
234
|
+
}]
|
|
235
|
+
}
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
**❌ Bad**
|
|
239
|
+
|
|
240
|
+
```typescript
|
|
241
|
+
import { memo, ReactNode } from "@rbxts/react";
|
|
242
|
+
|
|
243
|
+
interface CardProps {
|
|
244
|
+
readonly title: string;
|
|
245
|
+
readonly children?: ReactNode;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
// memo is useless - children change every render
|
|
249
|
+
const Card = memo<CardProps>(({ title, children }) => {
|
|
250
|
+
return (
|
|
251
|
+
<frame>
|
|
252
|
+
<textlabel Text={title} />
|
|
253
|
+
{children}
|
|
254
|
+
</frame>
|
|
255
|
+
);
|
|
256
|
+
});
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
**✅ Good**
|
|
260
|
+
|
|
261
|
+
```typescript
|
|
262
|
+
import { memo, ReactNode } from "@rbxts/react";
|
|
263
|
+
|
|
264
|
+
// Option 1: Remove memo if you need children
|
|
265
|
+
interface CardProps {
|
|
266
|
+
readonly title: string;
|
|
267
|
+
readonly children?: ReactNode;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
function Card({ title, children }: CardProps) {
|
|
271
|
+
return (
|
|
272
|
+
<frame>
|
|
273
|
+
<textlabel Text={title} />
|
|
274
|
+
{children}
|
|
275
|
+
</frame>
|
|
276
|
+
);
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
// Option 2: Use render prop instead of children
|
|
280
|
+
interface ListProps<T> {
|
|
281
|
+
readonly items: ReadonlyArray<T>;
|
|
282
|
+
readonly renderItem: (item: T) => ReactNode;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
const List = memo(<T,>({ items, renderItem }: ListProps<T>) => {
|
|
286
|
+
return <frame>{items.map(renderItem)}</frame>;
|
|
287
|
+
});
|
|
288
|
+
```
|
|
289
|
+
|
|
217
290
|
#### `no-god-components`
|
|
218
291
|
|
|
219
292
|
Flags React components that are too large or doing too much, encouraging better separation of concerns.
|
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,17 @@ 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 { EffectFunctionOptions,
|
|
12
|
+
export type { EffectFunctionOptions, HookConfiguration } from "./rules/require-named-effect-functions";
|
|
12
13
|
export type { PairConfiguration, RequirePairedCallsOptions } from "./rules/require-paired-calls";
|
|
13
14
|
export type { ReactKeysOptions } from "./rules/require-react-component-keys";
|
|
14
15
|
export type { RequireReactDisplayNamesOptions } from "./rules/require-react-display-names";
|
|
15
16
|
export type { HookEntry, UseExhaustiveDependenciesOptions } from "./rules/use-exhaustive-dependencies";
|
|
16
|
-
export {
|
|
17
|
+
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";
|
|
17
19
|
export type { Pattern, PreferPatternReplacementsOptions } from "./utilities/pattern-replacement";
|
|
18
20
|
export { pattern } from "./utilities/pattern-replacement";
|
|
19
21
|
/**
|
|
@@ -47,6 +49,7 @@ declare const recommended: {
|
|
|
47
49
|
readonly "cease-nonsense/no-god-components": "error";
|
|
48
50
|
readonly "cease-nonsense/no-identity-map": "error";
|
|
49
51
|
readonly "cease-nonsense/no-instance-methods-without-this": "error";
|
|
52
|
+
readonly "cease-nonsense/no-memo-children": "error";
|
|
50
53
|
readonly "cease-nonsense/no-print": "error";
|
|
51
54
|
readonly "cease-nonsense/no-shorthand-names": "error";
|
|
52
55
|
readonly "cease-nonsense/no-warn": "error";
|
|
@@ -68,4 +71,3 @@ interface Plugin {
|
|
|
68
71
|
}
|
|
69
72
|
declare const plugin: Plugin;
|
|
70
73
|
export default plugin;
|
|
71
|
-
//# sourceMappingURL=index.d.ts.map
|