@blumintinc/eslint-plugin-blumint 1.3.2 β 1.4.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 +41 -40
- package/lib/index.js +31 -1
- package/lib/rules/enforce-firestore-doc-ref-generic.js +5 -0
- package/lib/rules/enforce-firestore-set-merge.js +12 -6
- package/lib/rules/enforce-verb-noun-naming.js +2 -0
- package/lib/rules/no-explicit-return-type.d.ts +2 -1
- package/lib/rules/no-explicit-return-type.js +25 -15
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -52,47 +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
|
-
π Requires type information.
|
|
59
|
-
|
|
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-callable-types](docs/rules/enforce-callable-types.md) | Enforce Params and Response type exports in callable functions
|
|
68
|
-
| [enforce-callback-memo](docs/rules/enforce-callback-memo.md) | Enforce useCallback or useMemo for inline functions in JSX props
|
|
69
|
-
| [enforce-dynamic-firebase-imports](docs/rules/enforce-dynamic-firebase-imports.md) | Enforce dynamic importing for modules within the firebaseCloud directory
|
|
70
|
-
| [enforce-firestore-doc-ref-generic](docs/rules/enforce-firestore-doc-ref-generic.md) | Enforce generic argument for Firestore DocumentReference
|
|
71
|
-
| [enforce-firestore-path-utils](docs/rules/enforce-firestore-path-utils.md) | Enforce usage of utility functions for Firestore paths
|
|
72
|
-
| [enforce-identifiable-firestore-type](docs/rules/enforce-identifiable-firestore-type.md) | Enforce that Firestore type definitions extend Identifiable and match their folder name
|
|
73
|
-
| [enforce-
|
|
74
|
-
| [
|
|
75
|
-
| [
|
|
76
|
-
| [
|
|
77
|
-
| [
|
|
78
|
-
| [
|
|
79
|
-
| [no-async-
|
|
80
|
-
| [no-
|
|
81
|
-
| [no-
|
|
82
|
-
| [no-
|
|
83
|
-
| [no-
|
|
84
|
-
| [no-
|
|
85
|
-
| [no-
|
|
86
|
-
| [no-
|
|
87
|
-
| [no-
|
|
88
|
-
| [no-
|
|
89
|
-
| [
|
|
90
|
-
| [prefer-
|
|
91
|
-
| [
|
|
92
|
-
| [require-
|
|
93
|
-
| [require-
|
|
94
|
-
| [require-
|
|
95
|
-
| [require-
|
|
96
|
-
| [
|
|
57
|
+
π Requires [type information](https://typescript-eslint.io/linting/typed-linting).
|
|
58
|
+
|
|
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 | β
| π§ | |
|
|
97
98
|
|
|
98
99
|
<!-- end auto-generated rules list -->
|
package/lib/index.js
CHANGED
|
@@ -40,10 +40,20 @@ const no_compositing_layer_props_1 = require("./rules/no-compositing-layer-props
|
|
|
40
40
|
const enforce_firestore_doc_ref_generic_1 = require("./rules/enforce-firestore-doc-ref-generic");
|
|
41
41
|
const semantic_function_prefixes_1 = require("./rules/semantic-function-prefixes");
|
|
42
42
|
const enforce_mock_firestore_1 = require("./rules/enforce-mock-firestore");
|
|
43
|
+
const prefer_settings_object_1 = require("./rules/prefer-settings-object");
|
|
44
|
+
const enforce_firestore_set_merge_1 = require("./rules/enforce-firestore-set-merge");
|
|
45
|
+
const enforce_verb_noun_naming_1 = require("./rules/enforce-verb-noun-naming");
|
|
46
|
+
const no_explicit_return_type_1 = require("./rules/no-explicit-return-type");
|
|
47
|
+
const use_custom_memo_1 = require("./rules/use-custom-memo");
|
|
48
|
+
const use_custom_link_1 = require("./rules/use-custom-link");
|
|
49
|
+
const enforce_serializable_params_1 = __importDefault(require("./rules/enforce-serializable-params"));
|
|
50
|
+
const enforce_realtimedb_path_utils_1 = require("./rules/enforce-realtimedb-path-utils");
|
|
51
|
+
const enforce_memoize_async_1 = require("./rules/enforce-memoize-async");
|
|
52
|
+
const enforce_exported_function_types_1 = require("./rules/enforce-exported-function-types");
|
|
43
53
|
module.exports = {
|
|
44
54
|
meta: {
|
|
45
55
|
name: '@blumintinc/eslint-plugin-blumint',
|
|
46
|
-
version: '1.
|
|
56
|
+
version: '1.4.0',
|
|
47
57
|
},
|
|
48
58
|
parseOptions: {
|
|
49
59
|
ecmaVersion: 2020,
|
|
@@ -89,6 +99,16 @@ module.exports = {
|
|
|
89
99
|
'@blumintinc/blumint/enforce-firestore-doc-ref-generic': 'error',
|
|
90
100
|
'@blumintinc/blumint/semantic-function-prefixes': 'error',
|
|
91
101
|
'@blumintinc/blumint/enforce-mock-firestore': 'error',
|
|
102
|
+
'@blumintinc/blumint/prefer-settings-object': 'error',
|
|
103
|
+
'@blumintinc/blumint/enforce-firestore-set-merge': 'error',
|
|
104
|
+
'@blumintinc/blumint/enforce-verb-noun-naming': 'error',
|
|
105
|
+
'@blumintinc/blumint/no-explicit-return-type': 'error',
|
|
106
|
+
'@blumintinc/blumint/use-custom-memo': 'error',
|
|
107
|
+
'@blumintinc/blumint/use-custom-link': 'error',
|
|
108
|
+
'@blumintinc/blumint/enforce-serializable-params': 'error',
|
|
109
|
+
'@blumintinc/blumint/enforce-realtimedb-path-utils': 'error',
|
|
110
|
+
'@blumintinc/blumint/enforce-memoize-async': 'error',
|
|
111
|
+
'@blumintinc/blumint/enforce-exported-function-types': 'error',
|
|
92
112
|
},
|
|
93
113
|
},
|
|
94
114
|
},
|
|
@@ -130,6 +150,16 @@ module.exports = {
|
|
|
130
150
|
'enforce-firestore-doc-ref-generic': enforce_firestore_doc_ref_generic_1.enforceFirestoreDocRefGeneric,
|
|
131
151
|
'semantic-function-prefixes': semantic_function_prefixes_1.semanticFunctionPrefixes,
|
|
132
152
|
'enforce-mock-firestore': enforce_mock_firestore_1.enforceFirestoreMock,
|
|
153
|
+
'prefer-settings-object': prefer_settings_object_1.preferSettingsObject,
|
|
154
|
+
'enforce-firestore-set-merge': enforce_firestore_set_merge_1.enforceFirestoreSetMerge,
|
|
155
|
+
'enforce-verb-noun-naming': enforce_verb_noun_naming_1.enforceVerbNounNaming,
|
|
156
|
+
'no-explicit-return-type': no_explicit_return_type_1.noExplicitReturnType,
|
|
157
|
+
'use-custom-memo': use_custom_memo_1.useCustomMemo,
|
|
158
|
+
'use-custom-link': use_custom_link_1.useCustomLink,
|
|
159
|
+
'enforce-serializable-params': enforce_serializable_params_1.default,
|
|
160
|
+
'enforce-realtimedb-path-utils': enforce_realtimedb_path_utils_1.enforceRealtimedbPathUtils,
|
|
161
|
+
'enforce-memoize-async': enforce_memoize_async_1.enforceMemoizeAsync,
|
|
162
|
+
'enforce-exported-function-types': enforce_exported_function_types_1.enforceExportedFunctionTypes,
|
|
133
163
|
},
|
|
134
164
|
};
|
|
135
165
|
//# sourceMappingURL=index.js.map
|
|
@@ -113,6 +113,11 @@ exports.enforceFirestoreDocRefGeneric = (0, createRule_1.createRule)({
|
|
|
113
113
|
}
|
|
114
114
|
let current = node;
|
|
115
115
|
while (current) {
|
|
116
|
+
// Type assertions using 'as' keyword
|
|
117
|
+
if (current.type === utils_1.AST_NODE_TYPES.TSAsExpression) {
|
|
118
|
+
nodeCache.set(node, true);
|
|
119
|
+
return true;
|
|
120
|
+
}
|
|
116
121
|
// Variable declarations with type annotations
|
|
117
122
|
if (current.type === utils_1.AST_NODE_TYPES.VariableDeclarator && current.id.typeAnnotation) {
|
|
118
123
|
nodeCache.set(node, true);
|
|
@@ -10,6 +10,8 @@ exports.enforceFirestoreSetMerge = (0, createRule_1.createRule)({
|
|
|
10
10
|
docs: {
|
|
11
11
|
description: 'Enforce using set() with { merge: true } instead of update() for Firestore operations',
|
|
12
12
|
recommended: 'error',
|
|
13
|
+
requiresTypeChecking: false,
|
|
14
|
+
extendsBaseRule: false,
|
|
13
15
|
},
|
|
14
16
|
fixable: 'code',
|
|
15
17
|
schema: [],
|
|
@@ -23,7 +25,8 @@ exports.enforceFirestoreSetMerge = (0, createRule_1.createRule)({
|
|
|
23
25
|
function isFirestoreUpdateCall(node) {
|
|
24
26
|
if (node.callee.type === utils_1.AST_NODE_TYPES.MemberExpression) {
|
|
25
27
|
const property = node.callee.property;
|
|
26
|
-
return property.type === utils_1.AST_NODE_TYPES.Identifier &&
|
|
28
|
+
return (property.type === utils_1.AST_NODE_TYPES.Identifier &&
|
|
29
|
+
property.name === 'update');
|
|
27
30
|
}
|
|
28
31
|
if (node.callee.type === utils_1.AST_NODE_TYPES.Identifier) {
|
|
29
32
|
return updateAliases.has(node.callee.name);
|
|
@@ -51,8 +54,9 @@ exports.enforceFirestoreSetMerge = (0, createRule_1.createRule)({
|
|
|
51
54
|
}
|
|
52
55
|
return {
|
|
53
56
|
ImportDeclaration(node) {
|
|
54
|
-
if (node.source.value === 'firebase/firestore' ||
|
|
55
|
-
node.
|
|
57
|
+
if (node.source.value === 'firebase/firestore' ||
|
|
58
|
+
node.source.value === 'firebase-admin') {
|
|
59
|
+
node.specifiers.forEach((specifier) => {
|
|
56
60
|
if (specifier.type === utils_1.AST_NODE_TYPES.ImportSpecifier) {
|
|
57
61
|
if (specifier.imported.name === 'updateDoc') {
|
|
58
62
|
updateAliases.add(specifier.local.name);
|
|
@@ -63,7 +67,8 @@ exports.enforceFirestoreSetMerge = (0, createRule_1.createRule)({
|
|
|
63
67
|
},
|
|
64
68
|
ImportExpression(node) {
|
|
65
69
|
if (node.source.type === utils_1.AST_NODE_TYPES.Literal &&
|
|
66
|
-
(node.source.value === 'firebase/firestore' ||
|
|
70
|
+
(node.source.value === 'firebase/firestore' ||
|
|
71
|
+
node.source.value === 'firebase-admin')) {
|
|
67
72
|
// Dynamic imports are handled in VariableDeclarator
|
|
68
73
|
}
|
|
69
74
|
},
|
|
@@ -72,10 +77,11 @@ exports.enforceFirestoreSetMerge = (0, createRule_1.createRule)({
|
|
|
72
77
|
node.init.argument.type === utils_1.AST_NODE_TYPES.ImportExpression) {
|
|
73
78
|
const importSource = node.init.argument.source;
|
|
74
79
|
if (importSource.type === utils_1.AST_NODE_TYPES.Literal &&
|
|
75
|
-
(importSource.value === 'firebase/firestore' ||
|
|
80
|
+
(importSource.value === 'firebase/firestore' ||
|
|
81
|
+
importSource.value === 'firebase-admin')) {
|
|
76
82
|
// Handle destructured imports
|
|
77
83
|
if (node.id.type === utils_1.AST_NODE_TYPES.ObjectPattern) {
|
|
78
|
-
node.id.properties.forEach(prop => {
|
|
84
|
+
node.id.properties.forEach((prop) => {
|
|
79
85
|
if (prop.type === utils_1.AST_NODE_TYPES.Property &&
|
|
80
86
|
prop.key.type === utils_1.AST_NODE_TYPES.Identifier &&
|
|
81
87
|
prop.key.name === 'updateDoc') {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { TSESLint } from '@typescript-eslint/utils';
|
|
1
2
|
type Options = [
|
|
2
3
|
{
|
|
3
4
|
allowRecursiveFunctions?: boolean;
|
|
@@ -7,5 +8,5 @@ type Options = [
|
|
|
7
8
|
allowDtsFiles?: boolean;
|
|
8
9
|
}
|
|
9
10
|
];
|
|
10
|
-
export declare const noExplicitReturnType:
|
|
11
|
+
export declare const noExplicitReturnType: TSESLint.RuleModule<'noExplicitReturnType', Options>;
|
|
11
12
|
export {};
|
|
@@ -11,9 +11,11 @@ const defaultOptions = {
|
|
|
11
11
|
allowDtsFiles: true,
|
|
12
12
|
};
|
|
13
13
|
function isRecursiveFunction(node) {
|
|
14
|
-
const functionName = node.type === utils_1.AST_NODE_TYPES.FunctionDeclaration
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
const functionName = node.type === utils_1.AST_NODE_TYPES.FunctionDeclaration
|
|
15
|
+
? node.id?.name
|
|
16
|
+
: node.type === utils_1.AST_NODE_TYPES.FunctionExpression && node.id
|
|
17
|
+
? node.id.name
|
|
18
|
+
: undefined;
|
|
17
19
|
if (!functionName || !node.body)
|
|
18
20
|
return false;
|
|
19
21
|
let hasRecursiveCall = false;
|
|
@@ -63,9 +65,9 @@ function isOverloadedFunction(node) {
|
|
|
63
65
|
const methodName = node.key.type === utils_1.AST_NODE_TYPES.Identifier ? node.key.name : undefined;
|
|
64
66
|
if (!methodName)
|
|
65
67
|
return false;
|
|
66
|
-
return interfaceBody.body.filter(member => member.type === utils_1.AST_NODE_TYPES.TSMethodSignature &&
|
|
68
|
+
return (interfaceBody.body.filter((member) => member.type === utils_1.AST_NODE_TYPES.TSMethodSignature &&
|
|
67
69
|
member.key.type === utils_1.AST_NODE_TYPES.Identifier &&
|
|
68
|
-
member.key.name === methodName).length > 1;
|
|
70
|
+
member.key.name === methodName).length > 1);
|
|
69
71
|
}
|
|
70
72
|
return false;
|
|
71
73
|
}
|
|
@@ -75,7 +77,8 @@ function isInterfaceOrAbstractMethodSignature(node) {
|
|
|
75
77
|
if (node.type === utils_1.AST_NODE_TYPES.MethodDefinition) {
|
|
76
78
|
let current = node;
|
|
77
79
|
while (current) {
|
|
78
|
-
if (current.type === utils_1.AST_NODE_TYPES.ClassDeclaration &&
|
|
80
|
+
if (current.type === utils_1.AST_NODE_TYPES.ClassDeclaration &&
|
|
81
|
+
current.abstract) {
|
|
79
82
|
return true;
|
|
80
83
|
}
|
|
81
84
|
current = current.parent;
|
|
@@ -90,6 +93,8 @@ exports.noExplicitReturnType = (0, createRule_1.createRule)({
|
|
|
90
93
|
docs: {
|
|
91
94
|
description: 'Disallow explicit return types on functions',
|
|
92
95
|
recommended: 'error',
|
|
96
|
+
requiresTypeChecking: false,
|
|
97
|
+
extendsBaseRule: false,
|
|
93
98
|
},
|
|
94
99
|
fixable: 'code',
|
|
95
100
|
schema: [
|
|
@@ -116,6 +121,7 @@ exports.noExplicitReturnType = (0, createRule_1.createRule)({
|
|
|
116
121
|
if (mergedOptions.allowDtsFiles && filename.endsWith('.d.ts')) {
|
|
117
122
|
return {};
|
|
118
123
|
}
|
|
124
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
119
125
|
function fixReturnType(fixer, node) {
|
|
120
126
|
const returnType = node.returnType || node.value?.returnType;
|
|
121
127
|
if (!returnType)
|
|
@@ -127,25 +133,27 @@ exports.noExplicitReturnType = (0, createRule_1.createRule)({
|
|
|
127
133
|
FunctionDeclaration(node) {
|
|
128
134
|
if (!node.returnType)
|
|
129
135
|
return;
|
|
130
|
-
if (mergedOptions.allowRecursiveFunctions &&
|
|
136
|
+
if (mergedOptions.allowRecursiveFunctions &&
|
|
137
|
+
isRecursiveFunction(node)) {
|
|
131
138
|
return;
|
|
132
139
|
}
|
|
133
140
|
context.report({
|
|
134
141
|
node: node.returnType,
|
|
135
142
|
messageId: 'noExplicitReturnType',
|
|
136
|
-
fix: fixer => fixReturnType(fixer, node),
|
|
143
|
+
fix: (fixer) => fixReturnType(fixer, node),
|
|
137
144
|
});
|
|
138
145
|
},
|
|
139
146
|
FunctionExpression(node) {
|
|
140
147
|
if (!node.returnType)
|
|
141
148
|
return;
|
|
142
|
-
if (mergedOptions.allowRecursiveFunctions &&
|
|
149
|
+
if (mergedOptions.allowRecursiveFunctions &&
|
|
150
|
+
isRecursiveFunction(node)) {
|
|
143
151
|
return;
|
|
144
152
|
}
|
|
145
153
|
context.report({
|
|
146
154
|
node: node.returnType,
|
|
147
155
|
messageId: 'noExplicitReturnType',
|
|
148
|
-
fix: fixer => fixReturnType(fixer, node),
|
|
156
|
+
fix: (fixer) => fixReturnType(fixer, node),
|
|
149
157
|
});
|
|
150
158
|
},
|
|
151
159
|
ArrowFunctionExpression(node) {
|
|
@@ -154,7 +162,7 @@ exports.noExplicitReturnType = (0, createRule_1.createRule)({
|
|
|
154
162
|
context.report({
|
|
155
163
|
node: node.returnType,
|
|
156
164
|
messageId: 'noExplicitReturnType',
|
|
157
|
-
fix: fixer => fixReturnType(fixer, node),
|
|
165
|
+
fix: (fixer) => fixReturnType(fixer, node),
|
|
158
166
|
});
|
|
159
167
|
},
|
|
160
168
|
TSMethodSignature(node) {
|
|
@@ -163,25 +171,27 @@ exports.noExplicitReturnType = (0, createRule_1.createRule)({
|
|
|
163
171
|
if (mergedOptions.allowInterfaceMethodSignatures) {
|
|
164
172
|
return;
|
|
165
173
|
}
|
|
166
|
-
if (mergedOptions.allowOverloadedFunctions &&
|
|
174
|
+
if (mergedOptions.allowOverloadedFunctions &&
|
|
175
|
+
isOverloadedFunction(node)) {
|
|
167
176
|
return;
|
|
168
177
|
}
|
|
169
178
|
context.report({
|
|
170
179
|
node: node.returnType,
|
|
171
180
|
messageId: 'noExplicitReturnType',
|
|
172
|
-
fix: fixer => fixReturnType(fixer, node),
|
|
181
|
+
fix: (fixer) => fixReturnType(fixer, node),
|
|
173
182
|
});
|
|
174
183
|
},
|
|
175
184
|
MethodDefinition(node) {
|
|
176
185
|
if (!node.value.returnType)
|
|
177
186
|
return;
|
|
178
|
-
if (mergedOptions.allowAbstractMethodSignatures &&
|
|
187
|
+
if (mergedOptions.allowAbstractMethodSignatures &&
|
|
188
|
+
isInterfaceOrAbstractMethodSignature(node)) {
|
|
179
189
|
return;
|
|
180
190
|
}
|
|
181
191
|
context.report({
|
|
182
192
|
node: node.value.returnType,
|
|
183
193
|
messageId: 'noExplicitReturnType',
|
|
184
|
-
fix: fixer => fixReturnType(fixer, node),
|
|
194
|
+
fix: (fixer) => fixReturnType(fixer, node),
|
|
185
195
|
});
|
|
186
196
|
},
|
|
187
197
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blumintinc/eslint-plugin-blumint",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"description": "Custom eslint rules for use within BluMint",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Brodie McGuire",
|
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
"dotenv-cli": "5.0.0",
|
|
72
72
|
"eslint": "8.57.0",
|
|
73
73
|
"eslint-config-prettier": "8.5.0",
|
|
74
|
-
"eslint-doc-generator": "1.
|
|
74
|
+
"eslint-doc-generator": "1.7.1",
|
|
75
75
|
"eslint-import-resolver-typescript": "3.5.5",
|
|
76
76
|
"eslint-plugin-eslint-plugin": "5.0.0",
|
|
77
77
|
"eslint-plugin-import": "2.26.0",
|