@blumintinc/eslint-plugin-blumint 1.13.0 → 1.14.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 +170 -139
- package/lib/index.js +190 -1
- package/lib/rules/array-methods-this-context.js +1 -1
- package/lib/rules/class-methods-read-top-to-bottom.js +24 -5
- package/lib/rules/consistent-callback-naming.js +1 -1
- package/lib/rules/dynamic-https-errors.js +3 -4
- package/lib/rules/enforce-assert-safe-object-key.js +11 -11
- package/lib/rules/enforce-boolean-naming-prefixes.js +11 -23
- package/lib/rules/enforce-callback-memo.js +1 -1
- package/lib/rules/enforce-centralized-mock-firestore.js +1 -1
- package/lib/rules/enforce-console-error.js +35 -7
- package/lib/rules/enforce-dynamic-file-naming.d.ts +2 -0
- package/lib/rules/enforce-dynamic-file-naming.js +53 -28
- package/lib/rules/enforce-early-destructuring.d.ts +2 -0
- package/lib/rules/enforce-early-destructuring.js +980 -0
- package/lib/rules/enforce-empty-object-check.d.ts +11 -0
- package/lib/rules/enforce-empty-object-check.js +502 -0
- package/lib/rules/enforce-exported-function-types.js +1 -1
- package/lib/rules/enforce-fieldpath-syntax-in-docsetter.js +100 -50
- package/lib/rules/enforce-firestore-doc-ref-generic.js +15 -3
- package/lib/rules/enforce-firestore-facade.js +4 -2
- package/lib/rules/enforce-firestore-set-merge.js +3 -4
- package/lib/rules/enforce-global-constants.js +1 -1
- package/lib/rules/enforce-identifiable-firestore-type.js +108 -58
- package/lib/rules/enforce-memoize-async.js +2 -6
- package/lib/rules/enforce-memoize-getters.js +39 -15
- package/lib/rules/enforce-microdiff.js +1 -1
- package/lib/rules/enforce-object-literal-as-const.js +4 -4
- package/lib/rules/enforce-positive-naming.js +4 -0
- package/lib/rules/enforce-props-argument-name.js +2 -2
- package/lib/rules/enforce-safe-stringify.js +1 -1
- package/lib/rules/enforce-serializable-params.js +3 -3
- package/lib/rules/enforce-singular-type-names.js +1 -1
- package/lib/rules/enforce-stable-hash-spread-props.d.ts +13 -0
- package/lib/rules/enforce-stable-hash-spread-props.js +342 -0
- package/lib/rules/enforce-storage-context.d.ts +9 -0
- package/lib/rules/enforce-storage-context.js +646 -0
- package/lib/rules/enforce-timestamp-now.js +23 -7
- package/lib/rules/enforce-transform-memoization.d.ts +4 -0
- package/lib/rules/enforce-transform-memoization.js +416 -0
- package/lib/rules/enforce-typescript-markdown-code-blocks.js +7 -3
- package/lib/rules/enforce-unique-cursor-headers.d.ts +16 -0
- package/lib/rules/enforce-unique-cursor-headers.js +365 -0
- package/lib/rules/enforce-verb-noun-naming.js +5 -4
- package/lib/rules/ensure-pointer-events-none.js +28 -2
- package/lib/rules/export-if-in-doubt.js +27 -4
- package/lib/rules/extract-global-constants.js +40 -13
- package/lib/rules/fast-deep-equal-over-microdiff.js +29 -39
- package/lib/rules/firestore-transaction-reads-before-writes.js +50 -4
- package/lib/rules/flatten-push-calls.d.ts +2 -0
- package/lib/rules/flatten-push-calls.js +428 -0
- package/lib/rules/global-const-style.js +50 -19
- package/lib/rules/jsdoc-above-field.d.ts +11 -0
- package/lib/rules/jsdoc-above-field.js +208 -0
- package/lib/rules/key-only-outermost-element.js +21 -3
- package/lib/rules/logical-top-to-bottom-grouping.d.ts +5 -0
- package/lib/rules/logical-top-to-bottom-grouping.js +1258 -0
- package/lib/rules/memo-compare-deeply-complex-props.d.ts +3 -0
- package/lib/rules/memo-compare-deeply-complex-props.js +788 -0
- package/lib/rules/memo-nested-react-components.d.ts +8 -0
- package/lib/rules/memo-nested-react-components.js +410 -0
- package/lib/rules/no-always-true-false-conditions.d.ts +2 -1
- package/lib/rules/no-always-true-false-conditions.js +68 -8
- package/lib/rules/no-array-length-in-deps.js +9 -3
- package/lib/rules/no-async-foreach.js +210 -12
- package/lib/rules/no-circular-references.js +18 -17
- package/lib/rules/no-class-instance-destructuring.js +55 -12
- package/lib/rules/no-complex-cloud-params.js +7 -3
- package/lib/rules/no-compositing-layer-props.js +2 -2
- package/lib/rules/no-conditional-literals-in-jsx.js +37 -12
- package/lib/rules/no-console-error.d.ts +9 -0
- package/lib/rules/no-console-error.js +525 -0
- package/lib/rules/no-curly-brackets-around-commented-properties.d.ts +2 -0
- package/lib/rules/no-curly-brackets-around-commented-properties.js +258 -0
- package/lib/rules/no-empty-dependency-use-callbacks.d.ts +11 -0
- package/lib/rules/no-empty-dependency-use-callbacks.js +576 -0
- package/lib/rules/no-entire-object-hook-deps.js +4 -6
- package/lib/rules/no-excessive-parent-chain.js +1 -1
- package/lib/rules/no-explicit-return-type.d.ts +2 -1
- package/lib/rules/no-explicit-return-type.js +215 -26
- package/lib/rules/no-filter-without-return.js +5 -1
- package/lib/rules/no-firestore-jest-mock.d.ts +2 -1
- package/lib/rules/no-firestore-jest-mock.js +126 -8
- package/lib/rules/no-firestore-object-arrays.js +67 -12
- package/lib/rules/no-handler-suffix.d.ts +12 -0
- package/lib/rules/no-handler-suffix.js +305 -0
- package/lib/rules/no-hungarian.js +1 -1
- package/lib/rules/no-inline-component-prop.d.ts +10 -0
- package/lib/rules/no-inline-component-prop.js +456 -0
- package/lib/rules/no-jsx-in-hooks.js +6 -1
- package/lib/rules/no-jsx-whitespace-literal.js +8 -2
- package/lib/rules/no-margin-properties.js +6 -6
- package/lib/rules/no-memoize-on-static.js +9 -1
- package/lib/rules/no-misleading-boolean-prefixes.js +7 -3
- package/lib/rules/no-misused-switch-case.js +22 -1
- package/lib/rules/no-mixed-firestore-transactions.d.ts +3 -1
- package/lib/rules/no-mixed-firestore-transactions.js +296 -34
- package/lib/rules/no-mock-firebase-admin.js +5 -2
- package/lib/rules/no-object-values-on-strings.js +10 -2
- package/lib/rules/no-overridable-method-calls-in-constructor.js +29 -17
- package/lib/rules/no-passthrough-getters.js +38 -2
- package/lib/rules/no-redundant-annotation-assertion.d.ts +2 -0
- package/lib/rules/no-redundant-annotation-assertion.js +402 -0
- package/lib/rules/no-redundant-param-types.js +16 -6
- package/lib/rules/no-redundant-this-params.d.ts +3 -0
- package/lib/rules/no-redundant-this-params.js +459 -0
- package/lib/rules/no-redundant-usecallback-wrapper.js +16 -3
- package/lib/rules/no-res-error-status-in-onrequest.d.ts +4 -0
- package/lib/rules/no-res-error-status-in-onrequest.js +521 -0
- package/lib/rules/no-restricted-properties-fix.js +11 -10
- package/lib/rules/no-separate-loading-state.js +7 -16
- package/lib/rules/no-stale-state-across-await.js +1 -1
- package/lib/rules/no-type-assertion-returns.js +43 -49
- package/lib/rules/no-undefined-null-passthrough.js +61 -31
- package/lib/rules/no-unmemoized-memo-without-props.d.ts +8 -0
- package/lib/rules/no-unmemoized-memo-without-props.js +426 -0
- package/lib/rules/no-unnecessary-destructuring-rename.d.ts +2 -0
- package/lib/rules/no-unnecessary-destructuring-rename.js +347 -0
- package/lib/rules/no-unnecessary-destructuring.js +14 -4
- package/lib/rules/no-unnecessary-verb-suffix.js +2 -1
- package/lib/rules/no-unpinned-dependencies.js +36 -5
- package/lib/rules/no-unused-props.d.ts +2 -2
- package/lib/rules/no-unused-props.js +295 -91
- package/lib/rules/no-unused-usestate.js +6 -2
- package/lib/rules/no-useless-fragment.js +28 -2
- package/lib/rules/no-useless-usememo-primitives.d.ts +9 -0
- package/lib/rules/no-useless-usememo-primitives.js +393 -0
- package/lib/rules/no-usememo-for-pass-by-value.d.ts +13 -0
- package/lib/rules/no-usememo-for-pass-by-value.js +757 -0
- package/lib/rules/no-uuidv4-base62-as-key.js +18 -13
- package/lib/rules/omit-index-html.d.ts +2 -1
- package/lib/rules/omit-index-html.js +62 -7
- package/lib/rules/optimize-object-boolean-conditions.js +6 -4
- package/lib/rules/parallelize-async-operations.js +24 -5
- package/lib/rules/prefer-batch-operations.d.ts +1 -3
- package/lib/rules/prefer-batch-operations.js +32 -5
- package/lib/rules/prefer-block-comments-for-declarations.js +9 -4
- package/lib/rules/prefer-clone-deep.js +3 -3
- package/lib/rules/prefer-destructuring-no-class.d.ts +2 -1
- package/lib/rules/prefer-destructuring-no-class.js +244 -59
- package/lib/rules/prefer-docsetter-setall.d.ts +2 -0
- package/lib/rules/prefer-docsetter-setall.js +243 -0
- package/lib/rules/prefer-field-paths-in-transforms.js +4 -3
- package/lib/rules/prefer-fragment-component.js +1 -1
- package/lib/rules/prefer-fragment-shorthand.js +2 -1
- package/lib/rules/prefer-getter-over-parameterless-method.d.ts +13 -0
- package/lib/rules/prefer-getter-over-parameterless-method.js +648 -0
- package/lib/rules/prefer-global-router-state-key.js +88 -13
- package/lib/rules/prefer-memoized-props.d.ts +3 -0
- package/lib/rules/prefer-memoized-props.js +445 -0
- package/lib/rules/prefer-next-dynamic.js +60 -69
- package/lib/rules/prefer-nullish-coalescing-boolean-props.js +9 -4
- package/lib/rules/prefer-nullish-coalescing-override.d.ts +2 -1
- package/lib/rules/prefer-nullish-coalescing-override.js +11 -5
- package/lib/rules/prefer-params-over-parent-id.js +220 -171
- package/lib/rules/prefer-settings-object.js +2 -2
- package/lib/rules/prefer-type-over-interface.js +7 -2
- package/lib/rules/prefer-url-tostring-over-tojson.js +6 -3
- package/lib/rules/prefer-use-deep-compare-memo.js +8 -5
- package/lib/rules/prefer-usecallback-over-usememo-for-functions.js +1 -1
- package/lib/rules/prefer-utility-function-over-private-static.js +34 -2
- package/lib/rules/prevent-children-clobber.d.ts +2 -0
- package/lib/rules/prevent-children-clobber.js +536 -0
- package/lib/rules/react-memoize-literals.d.ts +4 -0
- package/lib/rules/react-memoize-literals.js +495 -0
- package/lib/rules/react-usememo-should-be-component.js +2 -2
- package/lib/rules/require-hooks-default-params.js +17 -16
- package/lib/rules/require-https-error-cause.d.ts +4 -0
- package/lib/rules/require-https-error-cause.js +136 -0
- package/lib/rules/require-https-error.js +43 -21
- package/lib/rules/require-image-optimized.js +1 -1
- package/lib/rules/require-memo.js +1 -1
- package/lib/rules/require-memoize-jsx-returners.d.ts +3 -0
- package/lib/rules/require-memoize-jsx-returners.js +485 -0
- package/lib/rules/require-usememo-object-literals.js +2 -3
- package/lib/rules/test-file-location-enforcement.js +1 -1
- package/lib/rules/use-latest-callback.js +6 -5
- package/lib/rules/vertically-group-related-functions.d.ts +16 -0
- package/lib/rules/vertically-group-related-functions.js +480 -0
- package/lib/utils/ASTHelpers.d.ts +13 -1
- package/lib/utils/ASTHelpers.js +24 -0
- package/lib/utils/getMethodName.d.ts +27 -0
- package/lib/utils/getMethodName.js +35 -0
- package/lib/utils/tsTypeClassifier.d.ts +30 -0
- package/lib/utils/tsTypeClassifier.js +149 -0
- package/package.json +3 -1
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.requireHttpsErrorCause = void 0;
|
|
4
|
+
const utils_1 = require("@typescript-eslint/utils");
|
|
5
|
+
const createRule_1 = require("../utils/createRule");
|
|
6
|
+
const isHttpsErrorCallee = (callee) => {
|
|
7
|
+
if (callee.type === utils_1.AST_NODE_TYPES.Identifier) {
|
|
8
|
+
return callee.name === 'HttpsError';
|
|
9
|
+
}
|
|
10
|
+
if (callee.type === utils_1.AST_NODE_TYPES.MemberExpression) {
|
|
11
|
+
return (callee.object.type === utils_1.AST_NODE_TYPES.Identifier &&
|
|
12
|
+
callee.property.type === utils_1.AST_NODE_TYPES.Identifier &&
|
|
13
|
+
callee.property.name === 'HttpsError');
|
|
14
|
+
}
|
|
15
|
+
return false;
|
|
16
|
+
};
|
|
17
|
+
const findVariableInScopeChain = (scope, name) => {
|
|
18
|
+
let currentScope = scope;
|
|
19
|
+
while (currentScope) {
|
|
20
|
+
const variable = currentScope.variables.find((item) => item.name === name);
|
|
21
|
+
if (variable) {
|
|
22
|
+
return variable;
|
|
23
|
+
}
|
|
24
|
+
currentScope = currentScope.upper;
|
|
25
|
+
}
|
|
26
|
+
return null;
|
|
27
|
+
};
|
|
28
|
+
exports.requireHttpsErrorCause = (0, createRule_1.createRule)({
|
|
29
|
+
name: 'require-https-error-cause',
|
|
30
|
+
meta: {
|
|
31
|
+
type: 'problem',
|
|
32
|
+
docs: {
|
|
33
|
+
description: 'Ensure HttpsError calls inside catch blocks pass the caught error as the fourth "cause" argument to preserve stack traces for monitoring.',
|
|
34
|
+
recommended: 'error',
|
|
35
|
+
},
|
|
36
|
+
schema: [],
|
|
37
|
+
messages: {
|
|
38
|
+
missingCause: 'HttpsError inside a catch block must pass the caught error as the fourth "cause" argument. Without the original error, the stack is lost and monitoring fingerprints degrade. Add {{catchName}} as the cause argument after the optional details parameter.',
|
|
39
|
+
causeNotCatchBinding: 'The fourth HttpsError argument should be the catch binding {{catchName}} so the original error stack is preserved for monitoring. Pass the catch variable instead of {{actual}}.',
|
|
40
|
+
missingCatchBinding: 'HttpsError inside a catch block needs a named catch binding so the original error can be forwarded as the fourth "cause" argument. Bind the error value (e.g., `catch (error)`) and pass that variable as the cause to keep the upstream stack trace.',
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
defaultOptions: [],
|
|
44
|
+
create(context) {
|
|
45
|
+
const sourceCode = context.getSourceCode();
|
|
46
|
+
const catchStack = [];
|
|
47
|
+
// ESLint 9 moves getScope onto sourceCode; ESLint 8 exposes context.getScope().
|
|
48
|
+
// This shim keeps the rule compatible until the codebase drops ESLint 8 support.
|
|
49
|
+
const getScopeForNode = (node) => {
|
|
50
|
+
const sourceCodeWithScope = sourceCode;
|
|
51
|
+
if (typeof sourceCodeWithScope.getScope === 'function') {
|
|
52
|
+
return sourceCodeWithScope.getScope(node);
|
|
53
|
+
}
|
|
54
|
+
return context.getScope();
|
|
55
|
+
};
|
|
56
|
+
const reportMissingCause = (node, catchName) => {
|
|
57
|
+
context.report({
|
|
58
|
+
node,
|
|
59
|
+
messageId: 'missingCause',
|
|
60
|
+
data: {
|
|
61
|
+
catchName,
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
};
|
|
65
|
+
const reportWrongCause = (node, catchName, actual) => {
|
|
66
|
+
context.report({
|
|
67
|
+
node,
|
|
68
|
+
messageId: 'causeNotCatchBinding',
|
|
69
|
+
data: {
|
|
70
|
+
catchName,
|
|
71
|
+
actual,
|
|
72
|
+
},
|
|
73
|
+
});
|
|
74
|
+
};
|
|
75
|
+
const isCatchBindingReference = (identifier, frame) => {
|
|
76
|
+
if (!frame.paramName || identifier.name !== frame.paramName) {
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
const variable = findVariableInScopeChain(getScopeForNode(identifier), identifier.name);
|
|
80
|
+
return (variable?.defs.some((definition) => definition.type === 'CatchClause' && definition.node === frame.node) ?? false);
|
|
81
|
+
};
|
|
82
|
+
const validateHttpsError = (node) => {
|
|
83
|
+
if (!catchStack.length) {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
if (!isHttpsErrorCallee(node.callee)) {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
const activeCatch = catchStack[catchStack.length - 1];
|
|
90
|
+
if (!activeCatch.paramName) {
|
|
91
|
+
context.report({
|
|
92
|
+
node,
|
|
93
|
+
messageId: 'missingCatchBinding',
|
|
94
|
+
});
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
const catchName = activeCatch.paramName;
|
|
98
|
+
if (node.arguments.length < 4) {
|
|
99
|
+
reportMissingCause(node, catchName);
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
const causeArg = node.arguments[3];
|
|
103
|
+
if (!causeArg || causeArg.type !== utils_1.AST_NODE_TYPES.Identifier) {
|
|
104
|
+
reportWrongCause(causeArg ?? node, catchName, causeArg
|
|
105
|
+
? sourceCode.getText(causeArg)
|
|
106
|
+
: 'the missing cause argument');
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
if (!isCatchBindingReference(causeArg, activeCatch)) {
|
|
110
|
+
reportWrongCause(causeArg, catchName, sourceCode.getText(causeArg));
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
return {
|
|
114
|
+
CatchClause(node) {
|
|
115
|
+
if (node.param?.type === utils_1.AST_NODE_TYPES.Identifier) {
|
|
116
|
+
catchStack.push({ paramName: node.param.name, node });
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
// Destructured catch params (e.g., `catch ({ message })`) do not bind the
|
|
120
|
+
// full error object, so they cannot be forwarded as the HttpsError cause.
|
|
121
|
+
// Users should bind the error value (e.g., `catch (error)`) before rethrowing.
|
|
122
|
+
catchStack.push({ paramName: null, node });
|
|
123
|
+
},
|
|
124
|
+
'CatchClause:exit'() {
|
|
125
|
+
catchStack.pop();
|
|
126
|
+
},
|
|
127
|
+
NewExpression(node) {
|
|
128
|
+
validateHttpsError(node);
|
|
129
|
+
},
|
|
130
|
+
CallExpression(node) {
|
|
131
|
+
validateHttpsError(node);
|
|
132
|
+
},
|
|
133
|
+
};
|
|
134
|
+
},
|
|
135
|
+
});
|
|
136
|
+
//# sourceMappingURL=require-https-error-cause.js.map
|
|
@@ -11,8 +11,8 @@ module.exports = (0, createRule_1.createRule)({
|
|
|
11
11
|
},
|
|
12
12
|
schema: [],
|
|
13
13
|
messages: {
|
|
14
|
-
useHttpsError: '
|
|
15
|
-
useProprietaryHttpsError: '
|
|
14
|
+
useHttpsError: 'Throwing "{{constructorName}}" in Cloud Functions returns a generic 500 and drops the structured status code clients rely on. Throw the proprietary HttpsError instead so responses include the correct status, sanitized message, and logging context.',
|
|
15
|
+
useProprietaryHttpsError: '{{reference}} comes from {{source}} and bypasses our proprietary HttpsError wrapper, so responses skip standardized status codes, logging, and client-safe payloads. Import and throw HttpsError from @our-company/errors to keep errors consistent.',
|
|
16
16
|
},
|
|
17
17
|
},
|
|
18
18
|
defaultOptions: [],
|
|
@@ -22,12 +22,20 @@ module.exports = (0, createRule_1.createRule)({
|
|
|
22
22
|
if (!filename.includes('functions/src')) {
|
|
23
23
|
return {};
|
|
24
24
|
}
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
const httpsIdentifiers = new Map();
|
|
26
|
+
const httpsErrorIdentifiers = new Map();
|
|
27
|
+
const reportProprietary = (node, data) => context.report({
|
|
28
|
+
node,
|
|
29
|
+
messageId: 'useProprietaryHttpsError',
|
|
30
|
+
data,
|
|
31
|
+
});
|
|
27
32
|
return {
|
|
28
33
|
ImportDeclaration(node) {
|
|
29
34
|
if (node.source.value === 'firebase-admin' ||
|
|
30
35
|
node.source.value === 'firebase-admin/lib/https-error') {
|
|
36
|
+
const sourceModule = String(node.source.value);
|
|
37
|
+
// Report imports immediately so the forbidden dependency is blocked even
|
|
38
|
+
// when unused; throw sites below also report to cover runtime usage.
|
|
31
39
|
// Check for direct HttpsError import
|
|
32
40
|
const httpsErrorSpecifier = node.specifiers.find((spec) => spec.type === utils_1.AST_NODE_TYPES.ImportSpecifier &&
|
|
33
41
|
spec.imported.name === 'HttpsError');
|
|
@@ -35,17 +43,19 @@ module.exports = (0, createRule_1.createRule)({
|
|
|
35
43
|
const httpsSpecifier = node.specifiers.find((spec) => spec.type === utils_1.AST_NODE_TYPES.ImportSpecifier &&
|
|
36
44
|
spec.imported.name === 'https');
|
|
37
45
|
if (httpsErrorSpecifier && 'local' in httpsErrorSpecifier) {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
46
|
+
const localName = httpsErrorSpecifier.local.name;
|
|
47
|
+
httpsErrorIdentifiers.set(localName, sourceModule);
|
|
48
|
+
reportProprietary(node, {
|
|
49
|
+
reference: localName,
|
|
50
|
+
source: sourceModule,
|
|
42
51
|
});
|
|
43
52
|
}
|
|
44
53
|
if (httpsSpecifier && 'local' in httpsSpecifier) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
54
|
+
const localName = httpsSpecifier.local.name;
|
|
55
|
+
httpsIdentifiers.set(localName, sourceModule);
|
|
56
|
+
reportProprietary(node, {
|
|
57
|
+
reference: `${localName}.HttpsError`,
|
|
58
|
+
source: sourceModule,
|
|
49
59
|
});
|
|
50
60
|
}
|
|
51
61
|
}
|
|
@@ -65,22 +75,34 @@ module.exports = (0, createRule_1.createRule)({
|
|
|
65
75
|
context.report({
|
|
66
76
|
node,
|
|
67
77
|
messageId: 'useHttpsError',
|
|
78
|
+
data: {
|
|
79
|
+
constructorName: callee.name,
|
|
80
|
+
},
|
|
68
81
|
});
|
|
69
82
|
return;
|
|
70
83
|
}
|
|
71
84
|
// Check for firebase-admin HttpsError usage
|
|
72
|
-
|
|
85
|
+
if (callee.type === utils_1.AST_NODE_TYPES.MemberExpression &&
|
|
73
86
|
callee.object.type === utils_1.AST_NODE_TYPES.Identifier &&
|
|
74
|
-
callee.object.name === httpsIdentifier &&
|
|
75
87
|
callee.property.type === utils_1.AST_NODE_TYPES.Identifier &&
|
|
76
|
-
callee.property.name === 'HttpsError'
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
88
|
+
callee.property.name === 'HttpsError') {
|
|
89
|
+
const objectName = callee.object.name;
|
|
90
|
+
const source = httpsIdentifiers.get(objectName);
|
|
91
|
+
if (!source) {
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
reportProprietary(node, {
|
|
95
|
+
reference: `${objectName}.HttpsError`,
|
|
96
|
+
source,
|
|
83
97
|
});
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
if (callee.type === utils_1.AST_NODE_TYPES.Identifier) {
|
|
101
|
+
const source = httpsErrorIdentifiers.get(callee.name);
|
|
102
|
+
if (!source) {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
reportProprietary(node, { reference: callee.name, source });
|
|
84
106
|
}
|
|
85
107
|
},
|
|
86
108
|
};
|
|
@@ -32,7 +32,7 @@ module.exports = (0, createRule_1.createRule)({
|
|
|
32
32
|
const options = context.options[0] || {
|
|
33
33
|
componentPath: 'src/components/image/ImageOptimized',
|
|
34
34
|
};
|
|
35
|
-
const sourceCode = context.
|
|
35
|
+
const sourceCode = context.sourceCode;
|
|
36
36
|
return {
|
|
37
37
|
// Handle JSX img elements
|
|
38
38
|
JSXElement(node) {
|
|
@@ -79,7 +79,7 @@ function checkFunction(context, node) {
|
|
|
79
79
|
},
|
|
80
80
|
fix: results[2] || results[1]
|
|
81
81
|
? function fix(fixer) {
|
|
82
|
-
const sourceCode = context.
|
|
82
|
+
const sourceCode = context.sourceCode;
|
|
83
83
|
let importFix = null;
|
|
84
84
|
// Search for memo import statement
|
|
85
85
|
const importDeclarations = sourceCode.ast.body.filter((node) => node.type === 'ImportDeclaration');
|