@pobammer-ts/eslint-cease-nonsense-rules 1.7.0 → 1.9.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.
Files changed (53) hide show
  1. package/README.md +227 -0
  2. package/dist/build-metadata.json +3 -3
  3. package/dist/index.d.ts.map +1 -1
  4. package/dist/index.js +3197 -505
  5. package/dist/index.js.map +31 -17
  6. package/dist/oxfmt-sync.d.ts +2 -1
  7. package/dist/oxfmt-sync.d.ts.map +1 -1
  8. package/dist/oxfmt-worker.d.ts +1 -0
  9. package/dist/oxfmt-worker.d.ts.map +1 -1
  10. package/dist/oxfmt-worker.js +17 -172730
  11. package/dist/oxfmt-worker.js.map +4 -21
  12. package/dist/recognizers/code-recognizer.d.ts +0 -18
  13. package/dist/recognizers/code-recognizer.d.ts.map +1 -1
  14. package/dist/resolver.linux-x64-gnu-hcjn12y1.node +0 -0
  15. package/dist/resolver.linux-x64-musl-gnkc267h.node +0 -0
  16. package/dist/rules/ban-instances.d.ts.map +1 -1
  17. package/dist/rules/ban-react-fc.d.ts.map +1 -1
  18. package/dist/rules/enforce-ianitor-check-type.d.ts.map +1 -1
  19. package/dist/rules/no-god-components.d.ts.map +1 -1
  20. package/dist/rules/no-identity-map.d.ts.map +1 -1
  21. package/dist/rules/prefer-class-properties.d.ts +6 -0
  22. package/dist/rules/prefer-class-properties.d.ts.map +1 -0
  23. package/dist/rules/prefer-early-return.d.ts +8 -0
  24. package/dist/rules/prefer-early-return.d.ts.map +1 -0
  25. package/dist/rules/prefer-module-scope-constants.d.ts +5 -0
  26. package/dist/rules/prefer-module-scope-constants.d.ts.map +1 -0
  27. package/dist/rules/prefer-pascal-case-enums.d.ts +5 -0
  28. package/dist/rules/prefer-pascal-case-enums.d.ts.map +1 -0
  29. package/dist/rules/prefer-singular-enums.d.ts +5 -0
  30. package/dist/rules/prefer-singular-enums.d.ts.map +1 -0
  31. package/dist/rules/prefer-udim2-shorthand.d.ts.map +1 -1
  32. package/dist/rules/react-hooks-strict-return.d.ts +5 -0
  33. package/dist/rules/react-hooks-strict-return.d.ts.map +1 -0
  34. package/dist/rules/require-paired-calls.d.ts +0 -1
  35. package/dist/rules/require-paired-calls.d.ts.map +1 -1
  36. package/dist/rules/strict-component-boundaries.d.ts +9 -0
  37. package/dist/rules/strict-component-boundaries.d.ts.map +1 -0
  38. package/dist/rules/use-exhaustive-dependencies.d.ts +1 -42
  39. package/dist/rules/use-exhaustive-dependencies.d.ts.map +1 -1
  40. package/dist/rules/use-hook-at-top-level.d.ts.map +1 -1
  41. package/dist/utilities/casing-utilities.d.ts +2 -0
  42. package/dist/utilities/casing-utilities.d.ts.map +1 -0
  43. package/dist/utilities/format-utilities.d.ts +2 -3
  44. package/dist/utilities/format-utilities.d.ts.map +1 -1
  45. package/dist/utilities/resolve-import.d.ts +16 -0
  46. package/dist/utilities/resolve-import.d.ts.map +1 -0
  47. package/package.json +15 -2
  48. package/dist/types/oxfmt.d.ts +0 -88
  49. package/dist/types/oxfmt.d.ts.map +0 -1
  50. package/dist/utilities/error-utilities.d.ts +0 -25
  51. package/dist/utilities/error-utilities.d.ts.map +0 -1
  52. package/dist/utilities/typebox-utilities.d.ts +0 -4
  53. package/dist/utilities/typebox-utilities.d.ts.map +0 -1
package/README.md CHANGED
@@ -13,6 +13,8 @@ An ESLint plugin that catches common mistakes before they reach production. This
13
13
  - [Resource Management](#resource-management)
14
14
  - [Code Quality](#code-quality)
15
15
  - [Performance](#performance)
16
+ - [Module Boundaries](#module-boundaries)
17
+ - [TypeScript](#typescript)
16
18
  - [License](#license)
17
19
 
18
20
  ## Installation
@@ -51,11 +53,18 @@ export default [
51
53
  "cease-nonsense/no-shorthand-names": "error",
52
54
  "cease-nonsense/no-useless-use-spring": "error",
53
55
  "cease-nonsense/no-warn": "error",
56
+ "cease-nonsense/prefer-class-properties": "error",
57
+ "cease-nonsense/prefer-early-return": "error",
58
+ "cease-nonsense/prefer-module-scope-constants": "error",
59
+ "cease-nonsense/prefer-pascal-case-enums": "error",
54
60
  "cease-nonsense/prefer-sequence-overloads": "error",
61
+ "cease-nonsense/prefer-singular-enums": "error",
55
62
  "cease-nonsense/prefer-udim2-shorthand": "error",
63
+ "cease-nonsense/react-hooks-strict-return": "error",
56
64
  "cease-nonsense/require-named-effect-functions": "error",
57
65
  "cease-nonsense/require-paired-calls": "error",
58
66
  "cease-nonsense/require-react-component-keys": "error",
67
+ "cease-nonsense/strict-component-boundaries": "error",
59
68
  "cease-nonsense/use-exhaustive-dependencies": "error",
60
69
  "cease-nonsense/use-hook-at-top-level": "error",
61
70
  },
@@ -418,6 +427,35 @@ function UserProfile({ userId }) {
418
427
  }
419
428
  ```
420
429
 
430
+ #### `react-hooks-strict-return`
431
+
432
+ React hooks must return a tuple of ≤2 elements or a single object. Prevents unwieldy hook return types.
433
+
434
+ **❌ Bad**
435
+
436
+ ```typescript
437
+ function useMyHook() {
438
+ return [a, b, c]; // 3+ elements
439
+ }
440
+
441
+ function useData() {
442
+ const items = [1, 2, 3];
443
+ return items; // Variable reference to 3+ element array
444
+ }
445
+ ```
446
+
447
+ **✅ Good**
448
+
449
+ ```typescript
450
+ function useMyHook() {
451
+ return [state, setState]; // 2 elements max
452
+ }
453
+
454
+ function useData() {
455
+ return { a, b, c }; // Objects are fine regardless of size
456
+ }
457
+ ```
458
+
421
459
  ### Logging
422
460
 
423
461
  #### `no-print`
@@ -843,6 +881,85 @@ const deltaTime = 0.016;
843
881
  const model = entity.char; // Property access is allowed
844
882
  ```
845
883
 
884
+ #### `prefer-class-properties`
885
+
886
+ Prefer class properties over assignment of literals in constructors.
887
+
888
+ **Options:** `['always' | 'never']` (default: `'always'`)
889
+
890
+ **❌ Bad**
891
+
892
+ ```typescript
893
+ class Foo {
894
+ constructor() {
895
+ this.bar = "literal"; // Assignment in constructor
896
+ this.obj = { key: "value" };
897
+ }
898
+ }
899
+ ```
900
+
901
+ **✅ Good**
902
+
903
+ ```typescript
904
+ class Foo {
905
+ bar = "literal"; // Class property
906
+ obj = { key: "value" };
907
+ }
908
+ ```
909
+
910
+ #### `prefer-early-return`
911
+
912
+ Prefer early returns over full-body conditional wrapping in function declarations.
913
+
914
+ **Options:** `{ maximumStatements: number }` (default: `1`)
915
+
916
+ **❌ Bad**
917
+
918
+ ```typescript
919
+ function foo() {
920
+ if (condition) {
921
+ doA();
922
+ doB();
923
+ doC();
924
+ }
925
+ }
926
+ ```
927
+
928
+ **✅ Good**
929
+
930
+ ```typescript
931
+ function foo() {
932
+ if (!condition) return;
933
+ doA();
934
+ doB();
935
+ doC();
936
+ }
937
+ ```
938
+
939
+ #### `prefer-module-scope-constants`
940
+
941
+ SCREAMING_SNAKE_CASE variables must be `const` at module scope.
942
+
943
+ **❌ Bad**
944
+
945
+ ```typescript
946
+ let FOO = 1; // Not const
947
+ function bar() {
948
+ const BAZ = 2; // Not module scope
949
+ }
950
+ ```
951
+
952
+ **✅ Good**
953
+
954
+ ```typescript
955
+ const FOO = 1; // Const at module scope
956
+
957
+ // Destructuring patterns are allowed anywhere
958
+ function bar() {
959
+ const { FOO } = config;
960
+ }
961
+ ```
962
+
846
963
  ### Performance
847
964
 
848
965
  #### `no-color3-constructor`
@@ -992,6 +1109,116 @@ class MyClass {
992
1109
  }
993
1110
  ```
994
1111
 
1112
+ ### Module Boundaries
1113
+
1114
+ #### `strict-component-boundaries`
1115
+
1116
+ Prevent reaching into sibling component folders for nested modules.
1117
+
1118
+ **Options:** `{ allow: string[], maxDepth: number }` (default: `maxDepth: 1`)
1119
+
1120
+ **❌ Bad**
1121
+
1122
+ ```typescript
1123
+ // Reaching into another component's internals
1124
+ import { helper } from "../OtherComponent/utils/helper";
1125
+ import { thing } from "./components/Foo/internal";
1126
+ ```
1127
+
1128
+ **✅ Good**
1129
+
1130
+ ```typescript
1131
+ // Import from shared location
1132
+ import { helper } from "../../shared/helper";
1133
+
1134
+ // Index import from component
1135
+ import { OtherComponent } from "../OtherComponent";
1136
+
1137
+ // Direct component import (within maxDepth)
1138
+ import { Foo } from "./components/Foo";
1139
+ ```
1140
+
1141
+ **Configuration**
1142
+
1143
+ ```typescript
1144
+ {
1145
+ "cease-nonsense/strict-component-boundaries": ["error", {
1146
+ "allow": ["components/\\w+$"], // Regex patterns to allow
1147
+ "maxDepth": 2 // Maximum import depth
1148
+ }]
1149
+ }
1150
+ ```
1151
+
1152
+ ### TypeScript
1153
+
1154
+ #### `prefer-pascal-case-enums`
1155
+
1156
+ Enum names and members must be PascalCase.
1157
+
1158
+ **❌ Bad**
1159
+
1160
+ ```typescript
1161
+ enum my_enum {
1162
+ foo_bar,
1163
+ }
1164
+ enum MyEnum {
1165
+ FOO_BAR,
1166
+ }
1167
+ enum COLORS {
1168
+ red,
1169
+ }
1170
+ ```
1171
+
1172
+ **✅ Good**
1173
+
1174
+ ```typescript
1175
+ enum MyEnum {
1176
+ FooBar,
1177
+ }
1178
+ enum Color {
1179
+ Red,
1180
+ Blue,
1181
+ }
1182
+ ```
1183
+
1184
+ #### `prefer-singular-enums`
1185
+
1186
+ Enum names should be singular, not plural.
1187
+
1188
+ **❌ Bad**
1189
+
1190
+ ```typescript
1191
+ enum Colors {
1192
+ Red,
1193
+ Blue,
1194
+ }
1195
+ enum Commands {
1196
+ Up,
1197
+ Down,
1198
+ }
1199
+ enum Feet {
1200
+ Left,
1201
+ Right,
1202
+ } // Irregular plural
1203
+ ```
1204
+
1205
+ **✅ Good**
1206
+
1207
+ ```typescript
1208
+ enum Color {
1209
+ Red,
1210
+ Blue,
1211
+ }
1212
+ enum Command {
1213
+ Up,
1214
+ Down,
1215
+ }
1216
+ enum Foot {
1217
+ Left,
1218
+ Right,
1219
+ }
1220
+ ```
1221
+
995
1222
  ## License
996
1223
 
997
1224
  MIT License - feel free to use this code however you want.
@@ -1,5 +1,5 @@
1
1
  {
2
- "commit": "5190fe3e4c6dd0f00dca6ffc3ab597f548ed996b",
3
- "time": "2025-12-20T05:50:30.010Z",
4
- "version": "1.7.0"
2
+ "commit": "6f9e13801a44ec08f3620295fee898d814956ca1",
3
+ "time": "2025-12-21T10:12:09.203Z",
4
+ "version": "1.9.0"
5
5
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAuBnC,KAAK,aAAa,GAAG,IAAI,CAAC,UAAU,GAAG,QAAQ,CAAC,yBAAyB,CAAC;AAE1E,YAAY,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AACjE,YAAY,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AAClF,YAAY,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AACxE,YAAY,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AACpE,YAAY,EAAE,wBAAwB,EAAE,MAAM,0CAA0C,CAAC;AACzF,YAAY,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AACrE,YAAY,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAC;AAC/E,YAAY,EAAE,qBAAqB,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,wCAAwC,CAAC;AACxH,YAAY,EAAE,iBAAiB,EAAE,yBAAyB,EAAE,MAAM,8BAA8B,CAAC;AACjG,YAAY,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AAC7E,YAAY,EAAE,SAAS,EAAE,gCAAgC,EAAE,MAAM,qCAAqC,CAAC;AACvG,OAAO,EACN,yBAAyB,EACzB,6BAA6B,EAC7B,2BAA2B,EAC3B,uBAAuB,EACvB,4BAA4B,EAC5B,8BAA8B,EAC9B,wBAAwB,EACxB,+BAA+B,EAC/B,uBAAuB,EACvB,sBAAsB,EACtB,+BAA+B,EAC/B,sCAAsC,EACtC,8BAA8B,EAC9B,wBAAwB,GACxB,MAAM,iCAAiC,CAAC;AA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