@blumintinc/eslint-plugin-blumint 1.7.2 → 1.8.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 +39 -62
- package/lib/index.js +37 -1
- package/lib/rules/enforce-assert-throws.js +48 -3
- package/lib/rules/enforce-assertSafe-object-key.d.ts +2 -0
- package/lib/rules/enforce-assertSafe-object-key.js +284 -0
- package/lib/rules/enforce-centralized-mock-firestore.js +193 -15
- package/lib/rules/enforce-firestore-facade.js +8 -0
- package/lib/rules/enforce-microdiff.d.ts +3 -0
- package/lib/rules/enforce-microdiff.js +379 -0
- package/lib/rules/enforce-mock-firestore.js +2 -2
- package/lib/rules/enforce-object-literal-as-const.d.ts +4 -0
- package/lib/rules/enforce-object-literal-as-const.js +88 -0
- package/lib/rules/enforce-positive-naming.d.ts +1 -0
- package/lib/rules/enforce-positive-naming.js +363 -0
- package/lib/rules/enforce-props-argument-name.d.ts +8 -0
- package/lib/rules/enforce-props-argument-name.js +182 -0
- package/lib/rules/enforce-render-hits-memoization.js +166 -17
- package/lib/rules/enforce-timestamp-now.d.ts +1 -0
- package/lib/rules/enforce-timestamp-now.js +223 -0
- package/lib/rules/enforce-verb-noun-naming.js +1 -0
- package/lib/rules/extract-global-constants.d.ts +1 -1
- package/lib/rules/extract-global-constants.js +109 -1
- package/lib/rules/global-const-style.js +3 -2
- package/lib/rules/no-always-true-false-conditions.d.ts +3 -0
- package/lib/rules/no-always-true-false-conditions.js +1202 -0
- package/lib/rules/no-firestore-jest-mock.js +27 -4
- package/lib/rules/no-mock-firebase-admin.js +21 -8
- package/lib/rules/no-type-assertion-returns.d.ts +9 -0
- package/lib/rules/no-type-assertion-returns.js +289 -0
- package/lib/rules/no-unnecessary-verb-suffix.d.ts +1 -0
- package/lib/rules/no-unnecessary-verb-suffix.js +203 -0
- package/lib/rules/no-unused-props.js +47 -1
- package/lib/rules/prefer-clone-deep.js +294 -22
- package/lib/rules/prefer-fragment-component.js +265 -34
- package/lib/rules/prefer-global-router-state-key.d.ts +5 -0
- package/lib/rules/prefer-global-router-state-key.js +89 -0
- package/lib/rules/prefer-utility-function-over-private-static.d.ts +1 -0
- package/lib/rules/prefer-utility-function-over-private-static.js +77 -0
- package/lib/rules/react-usememo-should-be-component.d.ts +1 -0
- package/lib/rules/react-usememo-should-be-component.js +256 -0
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -52,71 +52,48 @@ Or use the recommended config:
|
|
|
52
52
|
<!-- begin auto-generated rules list -->
|
|
53
53
|
|
|
54
54
|
💼 Configurations enabled in.\
|
|
55
|
-
⚠️ Configurations set to warn in.\
|
|
56
55
|
✅ Set in the `recommended` configuration.\
|
|
57
56
|
🔧 Automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/user-guide/command-line-interface#--fix).\
|
|
58
57
|
💭 Requires [type information](https://typescript-eslint.io/linting/typed-linting).
|
|
59
58
|
|
|
60
|
-
| Name | Description
|
|
61
|
-
| :--------------------------------------------------------------------------------------- |
|
|
62
|
-
| [array-methods-this-context](docs/rules/array-methods-this-context.md) | Prevent misuse of Array methods in OOP
|
|
63
|
-
| [avoid-utils-directory](docs/rules/avoid-utils-directory.md) | Enforce using util/ instead of utils/ directory
|
|
64
|
-
| [class-methods-read-top-to-bottom](docs/rules/class-methods-read-top-to-bottom.md) | Ensures classes read linearly from top to bottom.
|
|
65
|
-
| [consistent-callback-naming](docs/rules/consistent-callback-naming.md) | Enforce consistent naming conventions for callback props and functions
|
|
66
|
-
| [dynamic-https-errors](docs/rules/dynamic-https-errors.md) | Dynamic error details should only be in the third argument of the HttpsError constructor. The second argument is hashed to produce a unique id.
|
|
67
|
-
| [enforce-
|
|
68
|
-
| [enforce-
|
|
69
|
-
| [enforce-
|
|
70
|
-
| [enforce-
|
|
71
|
-
| [enforce-
|
|
72
|
-
| [enforce-firestore-
|
|
73
|
-
| [enforce-firestore
|
|
74
|
-
| [enforce-
|
|
75
|
-
| [
|
|
76
|
-
| [
|
|
77
|
-
| [
|
|
78
|
-
| [
|
|
79
|
-
| [
|
|
80
|
-
| [
|
|
81
|
-
| [
|
|
82
|
-
| [
|
|
83
|
-
| [
|
|
84
|
-
| [
|
|
85
|
-
| [
|
|
86
|
-
| [
|
|
87
|
-
| [no-
|
|
88
|
-
| [no-
|
|
89
|
-
| [no-
|
|
90
|
-
| [
|
|
91
|
-
| [
|
|
92
|
-
| [
|
|
93
|
-
| [
|
|
94
|
-
| [
|
|
95
|
-
| [
|
|
96
|
-
| [
|
|
97
|
-
| [
|
|
98
|
-
| [
|
|
99
|
-
| [no-memoize-on-static](docs/rules/no-memoize-on-static.md) | Prevent using @Memoize() decorator on static methods | ✅ | | | |
|
|
100
|
-
| [no-misused-switch-case](docs/rules/no-misused-switch-case.md) | Prevent misuse of logical OR (\|\|) in switch case statements, which can lead to confusing and error-prone code. Instead of using OR operators in case expressions, use multiple case statements in sequence to handle multiple values. This improves code readability and follows the standard switch-case pattern. | ✅ | | | |
|
|
101
|
-
| [no-mixed-firestore-transactions](docs/rules/no-mixed-firestore-transactions.md) | Prevent mixing transactional and non-transactional Firestore operations within a transaction | ✅ | | | |
|
|
102
|
-
| [no-redundant-param-types](docs/rules/no-redundant-param-types.md) | Disallow redundant parameter type annotations | ✅ | | 🔧 | |
|
|
103
|
-
| [no-unpinned-dependencies](docs/rules/no-unpinned-dependencies.md) | Enforces pinned dependencies | ✅ | | 🔧 | |
|
|
104
|
-
| [no-unsafe-firestore-spread](docs/rules/no-unsafe-firestore-spread.md) | Prevent unsafe object/array spreads in Firestore updates | ✅ | | 🔧 | |
|
|
105
|
-
| [no-unused-props](docs/rules/no-unused-props.md) | Detect unused props in React component type definitions | ✅ | | 🔧 | |
|
|
106
|
-
| [no-useless-fragment](docs/rules/no-useless-fragment.md) | Prevent unnecessary use of React fragments | | | 🔧 | |
|
|
107
|
-
| [prefer-batch-operations](docs/rules/prefer-batch-operations.md) | Enforce using setAll() and overwriteAll() instead of multiple set() or overwrite() calls | ✅ | | 🔧 | |
|
|
108
|
-
| [prefer-fragment-shorthand](docs/rules/prefer-fragment-shorthand.md) | Prefer <> shorthand for <React.Fragment> | ✅ | | 🔧 | |
|
|
109
|
-
| [prefer-settings-object](docs/rules/prefer-settings-object.md) | Enforce using a settings object for functions with multiple parameters | ✅ | | 🔧 | |
|
|
110
|
-
| [prefer-type-over-interface](docs/rules/prefer-type-over-interface.md) | Prefer using type alias over interface | ✅ | | 🔧 | |
|
|
111
|
-
| [require-dynamic-firebase-imports](docs/rules/require-dynamic-firebase-imports.md) | Enforce dynamic imports for Firebase dependencies | ✅ | | 🔧 | |
|
|
112
|
-
| [require-https-error](docs/rules/require-https-error.md) | Enforce using proprietary HttpsError instead of throw new Error or firebase-admin HttpsError in functions/src | ✅ | | | |
|
|
113
|
-
| [require-image-optimized](docs/rules/require-image-optimized.md) | Enforce using ImageOptimized component instead of next/image or img tags | ✅ | | 🔧 | |
|
|
114
|
-
| [require-memo](docs/rules/require-memo.md) | React components must be memoized | ✅ | | 🔧 | |
|
|
115
|
-
| [require-usememo-object-literals](docs/rules/require-usememo-object-literals.md) | Enforce using useMemo for inline object/array literals passed as props to JSX components to prevent unnecessary re-renders. When object/array literals are defined inline in JSX, they create new references on every render, causing child components to re-render even if the values haven't changed. Wrap them in useMemo to maintain referential equality. | ✅ | | | |
|
|
116
|
-
| [semantic-function-prefixes](docs/rules/semantic-function-prefixes.md) | Enforce semantic function prefixes over generic ones like "get" and "update" | ✅ | | | |
|
|
117
|
-
| [sync-onwrite-name-func](docs/rules/sync-onwrite-name-func.md) | Ensure that the name field matches the func field in onWrite handlers | ✅ | | 🔧 | |
|
|
118
|
-
| [use-custom-link](docs/rules/use-custom-link.md) | Enforce using src/components/Link instead of next/link | ✅ | | 🔧 | |
|
|
119
|
-
| [use-custom-memo](docs/rules/use-custom-memo.md) | Enforce using src/util/memo instead of React memo | ✅ | | 🔧 | |
|
|
120
|
-
| [use-custom-router](docs/rules/use-custom-router.md) | Enforce using src/hooks/routing/useRouter instead of next/router | ✅ | | 🔧 | |
|
|
59
|
+
| Name | Description | 💼 | 🔧 | 💭 |
|
|
60
|
+
| :--------------------------------------------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------- | :- | :- | :- |
|
|
61
|
+
| [array-methods-this-context](docs/rules/array-methods-this-context.md) | Prevent misuse of Array methods in OOP | ✅ | | |
|
|
62
|
+
| [avoid-utils-directory](docs/rules/avoid-utils-directory.md) | Enforce using util/ instead of utils/ directory | ✅ | 🔧 | |
|
|
63
|
+
| [class-methods-read-top-to-bottom](docs/rules/class-methods-read-top-to-bottom.md) | Ensures classes read linearly from top to bottom. | ✅ | 🔧 | |
|
|
64
|
+
| [consistent-callback-naming](docs/rules/consistent-callback-naming.md) | Enforce consistent naming conventions for callback props and functions | ✅ | 🔧 | |
|
|
65
|
+
| [dynamic-https-errors](docs/rules/dynamic-https-errors.md) | Dynamic error details should only be in the third argument of the HttpsError constructor. The second argument is hashed to produce a unique id. | ✅ | | |
|
|
66
|
+
| [enforce-callable-types](docs/rules/enforce-callable-types.md) | Enforce Params and Response type exports in callable functions | ✅ | | |
|
|
67
|
+
| [enforce-callback-memo](docs/rules/enforce-callback-memo.md) | Enforce useCallback or useMemo for inline functions in JSX props | ✅ | | |
|
|
68
|
+
| [enforce-dynamic-firebase-imports](docs/rules/enforce-dynamic-firebase-imports.md) | Enforce dynamic importing for modules within the firebaseCloud directory | ✅ | | |
|
|
69
|
+
| [enforce-firestore-doc-ref-generic](docs/rules/enforce-firestore-doc-ref-generic.md) | Enforce generic argument for Firestore DocumentReference, CollectionReference and CollectionGroup | ✅ | | 💭 |
|
|
70
|
+
| [enforce-firestore-path-utils](docs/rules/enforce-firestore-path-utils.md) | Enforce usage of utility functions for Firestore paths | ✅ | | |
|
|
71
|
+
| [enforce-identifiable-firestore-type](docs/rules/enforce-identifiable-firestore-type.md) | Enforce that Firestore type definitions extend Identifiable and match their folder name | ✅ | | |
|
|
72
|
+
| [enforce-mock-firestore](docs/rules/enforce-mock-firestore.md) | Enforce using mockFirestore over manual Firestore mocking | ✅ | | |
|
|
73
|
+
| [enforce-safe-stringify](docs/rules/enforce-safe-stringify.md) | Enforce using safe-stable-stringify instead of JSON.stringify | ✅ | 🔧 | |
|
|
74
|
+
| [export-if-in-doubt](docs/rules/export-if-in-doubt.md) | All top-level const definitions, type definitions, and functions should be exported | | | |
|
|
75
|
+
| [extract-global-constants](docs/rules/extract-global-constants.md) | Extract static constants and functions to the global scope when possible | ✅ | | |
|
|
76
|
+
| [generic-starts-with-t](docs/rules/generic-starts-with-t.md) | Enforce TypeScript generic types to start with T | ✅ | | |
|
|
77
|
+
| [global-const-style](docs/rules/global-const-style.md) | Enforce UPPER_SNAKE_CASE and as const for global static constants | ✅ | 🔧 | |
|
|
78
|
+
| [no-async-array-filter](docs/rules/no-async-array-filter.md) | Disallow async callbacks for Array.filter | ✅ | | |
|
|
79
|
+
| [no-async-foreach](docs/rules/no-async-foreach.md) | Disallow Array.forEach with an async callback function | ✅ | | |
|
|
80
|
+
| [no-compositing-layer-props](docs/rules/no-compositing-layer-props.md) | Warn when using CSS properties that trigger compositing layers | ✅ | | |
|
|
81
|
+
| [no-conditional-literals-in-jsx](docs/rules/no-conditional-literals-in-jsx.md) | Disallow use of conditional literals in JSX code | ✅ | | |
|
|
82
|
+
| [no-entire-object-hook-deps](docs/rules/no-entire-object-hook-deps.md) | Avoid using entire objects in React hook dependency arrays when only specific fields are used. Requires TypeScript and `parserOptions.project` to be configured. | ✅ | 🔧 | 💭 |
|
|
83
|
+
| [no-filter-without-return](docs/rules/no-filter-without-return.md) | Disallow Array.filter callbacks without an explicit return (if part of a block statement) | ✅ | | |
|
|
84
|
+
| [no-jsx-whitespace-literal](docs/rules/no-jsx-whitespace-literal.md) | Disallow the use of {" "} elements in JSX code | ✅ | | |
|
|
85
|
+
| [no-misused-switch-case](docs/rules/no-misused-switch-case.md) | Prevent misuse of logical OR in switch case statements | ✅ | | |
|
|
86
|
+
| [no-unpinned-dependencies](docs/rules/no-unpinned-dependencies.md) | Enforces pinned dependencies | ✅ | 🔧 | |
|
|
87
|
+
| [no-unused-props](docs/rules/no-unused-props.md) | Detect unused props in React component type definitions | ✅ | 🔧 | |
|
|
88
|
+
| [no-useless-fragment](docs/rules/no-useless-fragment.md) | Prevent unnecessary use of React fragments | | 🔧 | |
|
|
89
|
+
| [prefer-fragment-shorthand](docs/rules/prefer-fragment-shorthand.md) | Prefer <> shorthand for <React.Fragment> | ✅ | 🔧 | |
|
|
90
|
+
| [prefer-type-over-interface](docs/rules/prefer-type-over-interface.md) | Prefer using type alias over interface | ✅ | 🔧 | |
|
|
91
|
+
| [require-dynamic-firebase-imports](docs/rules/require-dynamic-firebase-imports.md) | Enforce dynamic imports for Firebase dependencies | ✅ | 🔧 | |
|
|
92
|
+
| [require-https-error](docs/rules/require-https-error.md) | Enforce using proprietary HttpsError instead of throw new Error or firebase-admin HttpsError in functions/src | ✅ | | |
|
|
93
|
+
| [require-image-optimized](docs/rules/require-image-optimized.md) | Enforce using ImageOptimized component instead of next/image or img tags | ✅ | 🔧 | |
|
|
94
|
+
| [require-memo](docs/rules/require-memo.md) | React components must be memoized | ✅ | 🔧 | |
|
|
95
|
+
| [require-usememo-object-literals](docs/rules/require-usememo-object-literals.md) | Enforce using useMemo for inline object literals passed as props to JSX components | ✅ | | |
|
|
96
|
+
| [semantic-function-prefixes](docs/rules/semantic-function-prefixes.md) | Enforce semantic function prefixes over generic ones like "get" and "update" | ✅ | | |
|
|
97
|
+
| [use-custom-router](docs/rules/use-custom-router.md) | Enforce using src/hooks/routing/useRouter instead of next/router | ✅ | 🔧 | |
|
|
121
98
|
|
|
122
99
|
<!-- end auto-generated rules list -->
|
package/lib/index.js
CHANGED
|
@@ -70,10 +70,22 @@ const require_hooks_default_params_1 = require("./rules/require-hooks-default-pa
|
|
|
70
70
|
const prefer_destructuring_no_class_1 = require("./rules/prefer-destructuring-no-class");
|
|
71
71
|
const enforce_render_hits_memoization_1 = require("./rules/enforce-render-hits-memoization");
|
|
72
72
|
const prefer_fragment_component_1 = require("./rules/prefer-fragment-component");
|
|
73
|
+
const react_usememo_should_be_component_1 = require("./rules/react-usememo-should-be-component");
|
|
74
|
+
const no_unnecessary_verb_suffix_1 = require("./rules/no-unnecessary-verb-suffix");
|
|
75
|
+
const enforce_assertSafe_object_key_1 = require("./rules/enforce-assertSafe-object-key");
|
|
76
|
+
const enforce_object_literal_as_const_1 = require("./rules/enforce-object-literal-as-const");
|
|
77
|
+
const enforce_positive_naming_1 = require("./rules/enforce-positive-naming");
|
|
78
|
+
const no_type_assertion_returns_1 = require("./rules/no-type-assertion-returns");
|
|
79
|
+
const prefer_utility_function_over_private_static_1 = require("./rules/prefer-utility-function-over-private-static");
|
|
80
|
+
const enforce_microdiff_1 = require("./rules/enforce-microdiff");
|
|
81
|
+
const enforce_timestamp_now_1 = require("./rules/enforce-timestamp-now");
|
|
82
|
+
const no_always_true_false_conditions_1 = require("./rules/no-always-true-false-conditions");
|
|
83
|
+
const enforce_props_argument_name_1 = require("./rules/enforce-props-argument-name");
|
|
84
|
+
const prefer_global_router_state_key_1 = require("./rules/prefer-global-router-state-key");
|
|
73
85
|
module.exports = {
|
|
74
86
|
meta: {
|
|
75
87
|
name: '@blumintinc/eslint-plugin-blumint',
|
|
76
|
-
version: '1.
|
|
88
|
+
version: '1.8.0',
|
|
77
89
|
},
|
|
78
90
|
parseOptions: {
|
|
79
91
|
ecmaVersion: 2020,
|
|
@@ -149,6 +161,18 @@ module.exports = {
|
|
|
149
161
|
'@blumintinc/blumint/prefer-destructuring-no-class': 'error',
|
|
150
162
|
'@blumintinc/blumint/enforce-render-hits-memoization': 'error',
|
|
151
163
|
'@blumintinc/blumint/prefer-fragment-component': 'error',
|
|
164
|
+
'@blumintinc/blumint/react-usememo-should-be-component': 'error',
|
|
165
|
+
'@blumintinc/blumint/no-unnecessary-verb-suffix': 'error',
|
|
166
|
+
'@blumintinc/blumint/enforce-assertSafe-object-key': 'error',
|
|
167
|
+
'@blumintinc/blumint/enforce-object-literal-as-const': 'error',
|
|
168
|
+
'@blumintinc/blumint/enforce-positive-naming': 'error',
|
|
169
|
+
'@blumintinc/blumint/no-type-assertion-returns': 'error',
|
|
170
|
+
'@blumintinc/blumint/prefer-utility-function-over-private-static': 'error',
|
|
171
|
+
'@blumintinc/blumint/enforce-microdiff': 'error',
|
|
172
|
+
'@blumintinc/blumint/enforce-timestamp-now': 'error',
|
|
173
|
+
'@blumintinc/blumint/no-always-true-false-conditions': 'error',
|
|
174
|
+
'@blumintinc/blumint/enforce-props-argument-name': 'error',
|
|
175
|
+
'@blumintinc/blumint/prefer-global-router-state-key': 'warn',
|
|
152
176
|
},
|
|
153
177
|
},
|
|
154
178
|
},
|
|
@@ -220,6 +244,18 @@ module.exports = {
|
|
|
220
244
|
'prefer-destructuring-no-class': prefer_destructuring_no_class_1.preferDestructuringNoClass,
|
|
221
245
|
'enforce-render-hits-memoization': enforce_render_hits_memoization_1.enforceRenderHitsMemoization,
|
|
222
246
|
'prefer-fragment-component': prefer_fragment_component_1.preferFragmentComponent,
|
|
247
|
+
'react-usememo-should-be-component': react_usememo_should_be_component_1.reactUseMemoShouldBeComponent,
|
|
248
|
+
'no-unnecessary-verb-suffix': no_unnecessary_verb_suffix_1.noUnnecessaryVerbSuffix,
|
|
249
|
+
'enforce-assertSafe-object-key': enforce_assertSafe_object_key_1.enforceAssertSafeObjectKey,
|
|
250
|
+
'enforce-object-literal-as-const': enforce_object_literal_as_const_1.enforceObjectLiteralAsConst,
|
|
251
|
+
'enforce-positive-naming': enforce_positive_naming_1.enforcePositiveNaming,
|
|
252
|
+
'no-type-assertion-returns': no_type_assertion_returns_1.noTypeAssertionReturns,
|
|
253
|
+
'prefer-utility-function-over-private-static': prefer_utility_function_over_private_static_1.preferUtilityFunctionOverPrivateStatic,
|
|
254
|
+
'enforce-microdiff': enforce_microdiff_1.enforceMicrodiff,
|
|
255
|
+
'enforce-timestamp-now': enforce_timestamp_now_1.enforceTimestampNow,
|
|
256
|
+
'no-always-true-false-conditions': no_always_true_false_conditions_1.noAlwaysTrueFalseConditions,
|
|
257
|
+
'enforce-props-argument-name': enforce_props_argument_name_1.enforcePropsArgumentName,
|
|
258
|
+
'prefer-global-router-state-key': prefer_global_router_state_key_1.preferGlobalRouterStateKey,
|
|
223
259
|
},
|
|
224
260
|
};
|
|
225
261
|
//# sourceMappingURL=index.js.map
|
|
@@ -8,12 +8,12 @@ exports.enforceAssertThrows = (0, createRule_1.createRule)({
|
|
|
8
8
|
meta: {
|
|
9
9
|
type: 'problem',
|
|
10
10
|
docs: {
|
|
11
|
-
description: 'Enforce that functions with assert- prefix must throw an error',
|
|
11
|
+
description: 'Enforce that functions with assert- prefix must throw an error or call process.exit(1)',
|
|
12
12
|
recommended: 'error',
|
|
13
13
|
},
|
|
14
14
|
schema: [],
|
|
15
15
|
messages: {
|
|
16
|
-
assertShouldThrow: 'Functions with assert- prefix must throw an error. Either rename the function or add a throw statement.',
|
|
16
|
+
assertShouldThrow: 'Functions with assert- prefix must throw an error or call process.exit(1). Either rename the function or add a throw/exit statement.',
|
|
17
17
|
},
|
|
18
18
|
},
|
|
19
19
|
defaultOptions: [],
|
|
@@ -36,6 +36,32 @@ exports.enforceAssertThrows = (0, createRule_1.createRule)({
|
|
|
36
36
|
}
|
|
37
37
|
return false;
|
|
38
38
|
}
|
|
39
|
+
function isProcessExit1(node) {
|
|
40
|
+
if (node.type === utils_1.AST_NODE_TYPES.CallExpression) {
|
|
41
|
+
const callee = node.callee;
|
|
42
|
+
if (callee.type === utils_1.AST_NODE_TYPES.MemberExpression &&
|
|
43
|
+
callee.object.type === utils_1.AST_NODE_TYPES.Identifier &&
|
|
44
|
+
callee.object.name === 'process' &&
|
|
45
|
+
callee.property.type === utils_1.AST_NODE_TYPES.Identifier &&
|
|
46
|
+
callee.property.name === 'exit') {
|
|
47
|
+
const args = node.arguments;
|
|
48
|
+
if (args.length === 1) {
|
|
49
|
+
const arg = args[0];
|
|
50
|
+
if (arg.type === utils_1.AST_NODE_TYPES.Literal && arg.value === 1) {
|
|
51
|
+
return true;
|
|
52
|
+
}
|
|
53
|
+
// Handle numeric literal 1 in different forms
|
|
54
|
+
if (arg.type === utils_1.AST_NODE_TYPES.UnaryExpression &&
|
|
55
|
+
arg.operator === '+' &&
|
|
56
|
+
arg.argument.type === utils_1.AST_NODE_TYPES.Literal &&
|
|
57
|
+
arg.argument.value === 1) {
|
|
58
|
+
return true;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
39
65
|
function hasThrowStatement(node) {
|
|
40
66
|
let hasThrow = false;
|
|
41
67
|
function walk(node) {
|
|
@@ -43,6 +69,13 @@ exports.enforceAssertThrows = (0, createRule_1.createRule)({
|
|
|
43
69
|
hasThrow = true;
|
|
44
70
|
return;
|
|
45
71
|
}
|
|
72
|
+
// Check for process.exit(1)
|
|
73
|
+
if (node.type === utils_1.AST_NODE_TYPES.ExpressionStatement) {
|
|
74
|
+
if (isProcessExit1(node.expression)) {
|
|
75
|
+
hasThrow = true;
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
46
79
|
// Check for assertion function calls
|
|
47
80
|
if (isAssertionCall(node)) {
|
|
48
81
|
hasThrow = true;
|
|
@@ -56,8 +89,20 @@ exports.enforceAssertThrows = (0, createRule_1.createRule)({
|
|
|
56
89
|
return;
|
|
57
90
|
}
|
|
58
91
|
}
|
|
59
|
-
//
|
|
92
|
+
// Check catch blocks for process.exit(1)
|
|
60
93
|
if (node.type === utils_1.AST_NODE_TYPES.CatchClause) {
|
|
94
|
+
walk(node.body);
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
// Handle TryStatement specially
|
|
98
|
+
if (node.type === utils_1.AST_NODE_TYPES.TryStatement) {
|
|
99
|
+
walk(node.block);
|
|
100
|
+
if (node.handler) {
|
|
101
|
+
walk(node.handler);
|
|
102
|
+
}
|
|
103
|
+
if (node.finalizer) {
|
|
104
|
+
walk(node.finalizer);
|
|
105
|
+
}
|
|
61
106
|
return;
|
|
62
107
|
}
|
|
63
108
|
// Handle BlockStatement specially
|