@pobammer-ts/eslint-cease-nonsense-rules 1.16.0 → 1.17.1
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 +202 -1
- package/dist/build-metadata.json +3 -3
- package/dist/index.d.ts +7 -1
- package/dist/index.js +7280 -4122
- package/dist/rules/misleading-lua-tuple-checks.d.ts +6 -0
- package/dist/rules/naming-convention.d.ts +9 -0
- package/dist/rules/no-unused-imports.d.ts +9 -0
- package/dist/rules/prefer-read-only-props.d.ts +6 -0
- package/dist/rules/prevent-abbreviations.d.ts +21 -0
- package/dist/rules/use-exhaustive-dependencies.d.ts +6 -2
- package/dist/utilities/configure-utilities.d.ts +21 -0
- package/dist/utilities/naming-convention-utilities/enums.d.ts +86 -0
- package/dist/utilities/naming-convention-utilities/format.d.ts +1 -0
- package/dist/utilities/naming-convention-utilities/get-enum-names.d.ts +1 -0
- package/dist/utilities/naming-convention-utilities/index.d.ts +5 -0
- package/dist/utilities/naming-convention-utilities/parse-options.d.ts +2 -0
- package/dist/utilities/naming-convention-utilities/schema.d.ts +2 -0
- package/dist/utilities/naming-convention-utilities/shared.d.ts +4 -0
- package/dist/utilities/naming-convention-utilities/types.d.ts +40 -0
- package/dist/utilities/naming-convention-utilities/validator.d.ts +3 -0
- package/dist/utilities/pattern-replacement/pattern-types.d.ts +1 -3
- package/package.json +34 -19
package/README.md
CHANGED
|
@@ -53,6 +53,7 @@ export default [
|
|
|
53
53
|
"cease-nonsense/no-print": "error",
|
|
54
54
|
"cease-nonsense/prefer-enum-item": "error",
|
|
55
55
|
"cease-nonsense/no-shorthand-names": "error",
|
|
56
|
+
"cease-nonsense/no-unused-imports": "error",
|
|
56
57
|
"cease-nonsense/no-useless-use-spring": "error",
|
|
57
58
|
"cease-nonsense/no-warn": "error",
|
|
58
59
|
"cease-nonsense/prefer-class-properties": "error",
|
|
@@ -69,6 +70,7 @@ export default [
|
|
|
69
70
|
"cease-nonsense/require-paired-calls": "error",
|
|
70
71
|
"cease-nonsense/require-react-component-keys": "error",
|
|
71
72
|
"cease-nonsense/require-react-display-names": "error",
|
|
73
|
+
"cease-nonsense/prefer-read-only-props": "error",
|
|
72
74
|
"cease-nonsense/strict-component-boundaries": "error",
|
|
73
75
|
"cease-nonsense/use-exhaustive-dependencies": "error",
|
|
74
76
|
"cease-nonsense/use-hook-at-top-level": "error",
|
|
@@ -172,7 +174,50 @@ const props: ImageProps = { ScaleType: 1 };
|
|
|
172
174
|
<uiflexitem FlexMode={Enum.UIFlexMode.Fill} />
|
|
173
175
|
|
|
174
176
|
// Explicit enum in object
|
|
175
|
-
const props: ImageProps = { ScaleType: Enum.ScaleType.Slice };
|
|
177
|
+
const props: ImageProps = { ScaleType: Enum.ScaleType.Slice };
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
#### `no-unused-imports`
|
|
181
|
+
|
|
182
|
+
Disallow unused imports. Uses ESLint's scope analysis to detect unused imports and optionally checks JSDoc comments for references.
|
|
183
|
+
|
|
184
|
+
**Configuration**
|
|
185
|
+
|
|
186
|
+
```typescript
|
|
187
|
+
{
|
|
188
|
+
"cease-nonsense/no-unused-imports": ["error", {
|
|
189
|
+
"checkJSDoc": true // Check if imports are referenced in JSDoc comments
|
|
190
|
+
}]
|
|
191
|
+
}
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
**Features**
|
|
195
|
+
|
|
196
|
+
- ✨ Has auto-fix
|
|
197
|
+
- Cached JSDoc comment parsing per file
|
|
198
|
+
- Pre-compiled regex patterns
|
|
199
|
+
- Efficient scope analysis using ESLint's built-in mechanisms
|
|
200
|
+
|
|
201
|
+
**❌ Bad**
|
|
202
|
+
|
|
203
|
+
```typescript
|
|
204
|
+
import { unusedFunction } from "./utils";
|
|
205
|
+
import { AnotherUnused } from "./types";
|
|
206
|
+
|
|
207
|
+
// unusedFunction and AnotherUnused are never used
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
**✅ Good**
|
|
211
|
+
|
|
212
|
+
```typescript
|
|
213
|
+
import { usedFunction } from "./utils";
|
|
214
|
+
|
|
215
|
+
usedFunction();
|
|
216
|
+
|
|
217
|
+
// Or used in JSDoc
|
|
218
|
+
/**
|
|
219
|
+
* @see {usedFunction}
|
|
220
|
+
*/
|
|
176
221
|
```
|
|
177
222
|
|
|
178
223
|
### React
|
|
@@ -595,6 +640,43 @@ ErrorBoundaryContext.displayName = "ErrorBoundaryContext";
|
|
|
595
640
|
export default ErrorBoundaryContext;
|
|
596
641
|
```
|
|
597
642
|
|
|
643
|
+
#### `prefer-read-only-props`
|
|
644
|
+
|
|
645
|
+
Enforce that React component props are typed as `readonly` in TypeScript, preventing accidental mutation of props.
|
|
646
|
+
|
|
647
|
+
**Features**
|
|
648
|
+
|
|
649
|
+
- ✨ Has auto-fix
|
|
650
|
+
- Direct AST pattern matching (no global component analysis)
|
|
651
|
+
- Component detection caching
|
|
652
|
+
- Focused on common React component patterns
|
|
653
|
+
|
|
654
|
+
**❌ Bad**
|
|
655
|
+
|
|
656
|
+
```typescript
|
|
657
|
+
interface Props {
|
|
658
|
+
name: string;
|
|
659
|
+
age: number;
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
function Component({ name, age }: Props) {
|
|
663
|
+
// ...
|
|
664
|
+
}
|
|
665
|
+
```
|
|
666
|
+
|
|
667
|
+
**✅ Good**
|
|
668
|
+
|
|
669
|
+
```typescript
|
|
670
|
+
interface Props {
|
|
671
|
+
readonly name: string;
|
|
672
|
+
readonly age: number;
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
function Component({ name, age }: Props) {
|
|
676
|
+
// ...
|
|
677
|
+
}
|
|
678
|
+
```
|
|
679
|
+
|
|
598
680
|
#### `react-hooks-strict-return`
|
|
599
681
|
|
|
600
682
|
React hooks must return a tuple of ≤2 elements or a single object. Prevents unwieldy hook return types.
|
|
@@ -1002,6 +1084,48 @@ const doubled = items.map((x) => x * 2);
|
|
|
1002
1084
|
}
|
|
1003
1085
|
```
|
|
1004
1086
|
|
|
1087
|
+
#### `prevent-abbreviations`
|
|
1088
|
+
|
|
1089
|
+
Prevent abbreviations in variable and property names. Provides suggestions for replacements and can automatically fix single-replacement cases.
|
|
1090
|
+
|
|
1091
|
+
**Configuration**
|
|
1092
|
+
|
|
1093
|
+
```typescript
|
|
1094
|
+
{
|
|
1095
|
+
"cease-nonsense/prevent-abbreviations": ["error", {
|
|
1096
|
+
"checkFilenames": true,
|
|
1097
|
+
"checkProperties": false,
|
|
1098
|
+
"checkVariables": true,
|
|
1099
|
+
"replacements": {},
|
|
1100
|
+
"allowList": {},
|
|
1101
|
+
"ignore": []
|
|
1102
|
+
}]
|
|
1103
|
+
}
|
|
1104
|
+
```
|
|
1105
|
+
|
|
1106
|
+
**Features**
|
|
1107
|
+
|
|
1108
|
+
- ✨ Has auto-fix (for single replacements)
|
|
1109
|
+
- Aggressive caching of word and name replacements
|
|
1110
|
+
- Pre-compiled regex patterns
|
|
1111
|
+
- Early exits for constants and allow-listed names
|
|
1112
|
+
|
|
1113
|
+
**❌ Bad**
|
|
1114
|
+
|
|
1115
|
+
```typescript
|
|
1116
|
+
const err = new Error();
|
|
1117
|
+
const fn = () => {};
|
|
1118
|
+
const dist = calculateDistance();
|
|
1119
|
+
```
|
|
1120
|
+
|
|
1121
|
+
**✅ Good**
|
|
1122
|
+
|
|
1123
|
+
```typescript
|
|
1124
|
+
const error = new Error();
|
|
1125
|
+
const func = () => {};
|
|
1126
|
+
const distance = calculateDistance();
|
|
1127
|
+
```
|
|
1128
|
+
|
|
1005
1129
|
#### `no-shorthand-names`
|
|
1006
1130
|
|
|
1007
1131
|
Bans shorthand variable names in favor of descriptive full names.
|
|
@@ -1493,6 +1617,83 @@ import { Foo } from "./components/Foo";
|
|
|
1493
1617
|
|
|
1494
1618
|
### TypeScript
|
|
1495
1619
|
|
|
1620
|
+
#### `naming-convention`
|
|
1621
|
+
|
|
1622
|
+
Enforce naming conventions for TypeScript constructs. Optimized for common use cases like interface prefix checking without requiring type checking.
|
|
1623
|
+
|
|
1624
|
+
**Configuration**
|
|
1625
|
+
|
|
1626
|
+
```typescript
|
|
1627
|
+
{
|
|
1628
|
+
"cease-nonsense/naming-convention": ["error", {
|
|
1629
|
+
"custom": {
|
|
1630
|
+
"match": false,
|
|
1631
|
+
"regex": "^I[A-Z]"
|
|
1632
|
+
},
|
|
1633
|
+
"format": ["PascalCase"],
|
|
1634
|
+
"selector": "interface"
|
|
1635
|
+
}]
|
|
1636
|
+
}
|
|
1637
|
+
```
|
|
1638
|
+
|
|
1639
|
+
**Features**
|
|
1640
|
+
|
|
1641
|
+
- No type checking required (fast AST-only analysis)
|
|
1642
|
+
- Pre-compiled regex patterns
|
|
1643
|
+
- Focused on common use cases
|
|
1644
|
+
|
|
1645
|
+
**❌ Bad**
|
|
1646
|
+
|
|
1647
|
+
```typescript
|
|
1648
|
+
// With custom: { match: false, regex: "^I[A-Z]" }
|
|
1649
|
+
interface IUser {
|
|
1650
|
+
name: string;
|
|
1651
|
+
}
|
|
1652
|
+
```
|
|
1653
|
+
|
|
1654
|
+
**✅ Good**
|
|
1655
|
+
|
|
1656
|
+
```typescript
|
|
1657
|
+
interface User {
|
|
1658
|
+
name: string;
|
|
1659
|
+
}
|
|
1660
|
+
```
|
|
1661
|
+
|
|
1662
|
+
#### `misleading-lua-tuple-checks`
|
|
1663
|
+
|
|
1664
|
+
Disallow the use of `LuaTuple` types directly in conditional expressions, which can be misleading. Requires explicit indexing (`[0]`) or array destructuring.
|
|
1665
|
+
|
|
1666
|
+
**Features**
|
|
1667
|
+
|
|
1668
|
+
- ✨ Has auto-fix
|
|
1669
|
+
- Cached type queries per node
|
|
1670
|
+
- WeakMap-based caching for `isLuaTuple` checks
|
|
1671
|
+
- Cached constrained type lookups
|
|
1672
|
+
|
|
1673
|
+
**❌ Bad**
|
|
1674
|
+
|
|
1675
|
+
```typescript
|
|
1676
|
+
// Direct LuaTuple in conditional
|
|
1677
|
+
if (getLuaTuple()) {
|
|
1678
|
+
// ...
|
|
1679
|
+
}
|
|
1680
|
+
|
|
1681
|
+
// LuaTuple in variable declaration
|
|
1682
|
+
const result = getLuaTuple();
|
|
1683
|
+
```
|
|
1684
|
+
|
|
1685
|
+
**✅ Good**
|
|
1686
|
+
|
|
1687
|
+
```typescript
|
|
1688
|
+
// Explicit indexing
|
|
1689
|
+
if (getLuaTuple()[0]) {
|
|
1690
|
+
// ...
|
|
1691
|
+
}
|
|
1692
|
+
|
|
1693
|
+
// Array destructuring
|
|
1694
|
+
const [result] = getLuaTuple();
|
|
1695
|
+
```
|
|
1696
|
+
|
|
1496
1697
|
#### `prefer-pascal-case-enums`
|
|
1497
1698
|
|
|
1498
1699
|
Enum names and members must be PascalCase.
|
package/dist/build-metadata.json
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -2,13 +2,16 @@ import type { LooseRuleDefinition } from "@typescript-eslint/utils/ts-eslint";
|
|
|
2
2
|
import type { ReadonlyRecord } from "./types/utility-types.d";
|
|
3
3
|
export type { BanInstancesOptions } from "./rules/ban-instances";
|
|
4
4
|
export type { ComplexityConfiguration } from "./rules/enforce-ianitor-check-type";
|
|
5
|
+
export type { NamingConventionOptions } from "./rules/naming-convention";
|
|
5
6
|
export type { NoGodComponentsOptions } from "./rules/no-god-components";
|
|
6
7
|
export type { NoIdentityMapOptions } from "./rules/no-identity-map";
|
|
7
8
|
export type { NoInstanceMethodsOptions } from "./rules/no-instance-methods-without-this";
|
|
8
9
|
export type { NoMemoChildrenOptions } from "./rules/no-memo-children";
|
|
9
10
|
export type { NoShorthandOptions } from "./rules/no-shorthand-names";
|
|
11
|
+
export type { NoUnusedImportsOptions } from "./rules/no-unused-imports";
|
|
10
12
|
export type { NoUselessUseSpringOptions } from "./rules/no-useless-use-spring";
|
|
11
13
|
export type { PreferEnumItemOptions } from "./rules/prefer-enum-item";
|
|
14
|
+
export type { PreventAbbreviationsOptions } from "./rules/prevent-abbreviations";
|
|
12
15
|
export type { RequireModuleLevelInstantiationOptions } from "./rules/require-module-level-instantiation";
|
|
13
16
|
export type { EffectFunctionOptions, HookConfiguration } from "./rules/require-named-effect-functions";
|
|
14
17
|
export type { PairConfiguration, RequirePairedCallsOptions } from "./rules/require-paired-calls";
|
|
@@ -16,7 +19,7 @@ export type { ReactKeysOptions } from "./rules/require-react-component-keys";
|
|
|
16
19
|
export type { RequireReactDisplayNamesOptions } from "./rules/require-react-display-names";
|
|
17
20
|
export type { HookEntry, UseExhaustiveDependenciesOptions } from "./rules/use-exhaustive-dependencies";
|
|
18
21
|
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";
|
|
22
|
+
export { createBanInstancesOptions, createComplexityConfiguration, createEffectFunctionOptions, createHookConfiguration, createNamingConventionOptions, createNoGodComponentsOptions, createNoInstanceMethodsOptions, createNoMemoChildrenOptions, createNoShorthandOptions, createNoUnusedImportsOptions, createNoUselessUseSpringOptions, createPairConfiguration, createPreferEnumItemOptions, createPreferPatternReplacementsOptions, createPreventAbbreviationsOptions, createReactKeysOptions, createRequireModuleLevelInstantiationOptions, createRequirePairedCallsOptions, createRequireReactDisplayNamesOptions, createUseExhaustiveDependenciesOptions, createUseHookAtTopLevelOptions, defaultRobloxProfilePair, } from "./utilities/configure-utilities";
|
|
20
23
|
export type { Pattern, PreferPatternReplacementsOptions } from "./utilities/pattern-replacement";
|
|
21
24
|
export { pattern } from "./utilities/pattern-replacement";
|
|
22
25
|
/**
|
|
@@ -45,6 +48,7 @@ declare const recommended: {
|
|
|
45
48
|
readonly "cease-nonsense/ban-react-fc": "error";
|
|
46
49
|
readonly "cease-nonsense/enforce-ianitor-check-type": "error";
|
|
47
50
|
readonly "cease-nonsense/fast-format": "error";
|
|
51
|
+
readonly "cease-nonsense/misleading-lua-tuple-checks": "error";
|
|
48
52
|
readonly "cease-nonsense/no-async-constructor": "error";
|
|
49
53
|
readonly "cease-nonsense/no-color3-constructor": "error";
|
|
50
54
|
readonly "cease-nonsense/no-god-components": "error";
|
|
@@ -53,7 +57,9 @@ declare const recommended: {
|
|
|
53
57
|
readonly "cease-nonsense/no-memo-children": "error";
|
|
54
58
|
readonly "cease-nonsense/no-print": "error";
|
|
55
59
|
readonly "cease-nonsense/no-shorthand-names": "error";
|
|
60
|
+
readonly "cease-nonsense/no-unused-imports": "error";
|
|
56
61
|
readonly "cease-nonsense/no-warn": "error";
|
|
62
|
+
readonly "cease-nonsense/prefer-read-only-props": "error";
|
|
57
63
|
readonly "cease-nonsense/prefer-sequence-overloads": "error";
|
|
58
64
|
readonly "cease-nonsense/prefer-udim2-shorthand": "error";
|
|
59
65
|
readonly "cease-nonsense/require-named-effect-functions": "error";
|