@dereekb/firebase 14.0.1 → 14.2.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.
@@ -1,4 +1,3 @@
1
- import 'typescript';
2
1
  import { createRequire } from 'node:module';
3
2
  import { existsSync, readFileSync, globSync, readdirSync } from 'node:fs';
4
3
  import { join, dirname, isAbsolute, resolve, sep, basename } from 'node:path';
@@ -51,199 +50,6 @@ import { parse as parse$2 } from '@typescript-eslint/parser';
51
50
  return result;
52
51
  }
53
52
 
54
- /**
55
- * Default maximum positional parameters before the warn-level rule suggests a config object.
56
- * Triggers a warning when a function has more than 2 positional parameters (i.e. 3+ args).
57
- */ var DEFAULT_MAX_PARAMS_WARN = 2;
58
- /**
59
- * Default maximum positional parameters before the hard-error rule rejects the signature.
60
- * Triggers an error when a function has more than 4 positional parameters (i.e. 5+ args).
61
- */ var DEFAULT_MAX_PARAMS_HARD = 4;
62
- /**
63
- * Default JSDoc tag that opts a function out of this rule.
64
- */ var DEFAULT_ALLOW_JSDOC_TAG = '@dbxAllowMultiParams';
65
- /**
66
- * Returns a human-readable display name for the function-like node, or `<anonymous>`.
67
- *
68
- * @param node - The function-like AST node.
69
- * @returns The identifier string used in diagnostic messages.
70
- */ function getFunctionDisplayName(node) {
71
- var _node_id;
72
- var name = '<anonymous>';
73
- if (((_node_id = node.id) === null || _node_id === void 0 ? void 0 : _node_id.type) === 'Identifier') {
74
- name = node.id.name;
75
- } else if (node.parent) {
76
- var _parent_id, _parent_key, _parent_key1, _parent_left;
77
- var parent = node.parent;
78
- if (parent.type === 'VariableDeclarator' && ((_parent_id = parent.id) === null || _parent_id === void 0 ? void 0 : _parent_id.type) === 'Identifier') {
79
- name = parent.id.name;
80
- } else if (parent.type === 'Property' && ((_parent_key = parent.key) === null || _parent_key === void 0 ? void 0 : _parent_key.type) === 'Identifier') {
81
- name = parent.key.name;
82
- } else if (parent.type === 'MethodDefinition' && ((_parent_key1 = parent.key) === null || _parent_key1 === void 0 ? void 0 : _parent_key1.type) === 'Identifier') {
83
- name = parent.key.name;
84
- } else if (parent.type === 'AssignmentExpression' && ((_parent_left = parent.left) === null || _parent_left === void 0 ? void 0 : _parent_left.type) === 'Identifier') {
85
- name = parent.left.name;
86
- }
87
- }
88
- return name;
89
- }
90
- /**
91
- * Returns true if a parameter has any decorators (NestJS handler/Inject pattern).
92
- *
93
- * @param param - The parameter AST node.
94
- * @returns True when the parameter carries at least one decorator.
95
- */ function paramHasDecorator(param) {
96
- var _param_decorators;
97
- var decorators = (_param_decorators = param.decorators) !== null && _param_decorators !== void 0 ? _param_decorators : [];
98
- return Array.isArray(decorators) && decorators.length > 0;
99
- }
100
- /**
101
- * Returns true when the function is the constructor of a class.
102
- *
103
- * @param node - The function-like AST node.
104
- * @returns True if `node` is the `constructor` body of a class.
105
- */ function isConstructor(node) {
106
- var _node_parent;
107
- return ((_node_parent = node.parent) === null || _node_parent === void 0 ? void 0 : _node_parent.type) === 'MethodDefinition' && node.parent.kind === 'constructor';
108
- }
109
- /**
110
- * Returns true if any leading JSDoc block above `anchor` contains the allow tag.
111
- *
112
- * @param sourceCode - The ESLint `SourceCode` instance.
113
- * @param anchor - The AST node whose leading comments are scanned.
114
- * @param allowTag - The JSDoc tag string that opts the function out.
115
- * @returns True when a JSDoc with the allow tag is present.
116
- */ function hasAllowJsdoc(sourceCode, anchor, allowTag) {
117
- var comments = sourceCode.getCommentsBefore(anchor) || [];
118
- var allow = false;
119
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
120
- try {
121
- for(var _iterator = comments[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
122
- var comment = _step.value;
123
- if (comment.type === 'Block' && comment.value.startsWith('*') && comment.value.includes(allowTag)) {
124
- allow = true;
125
- }
126
- }
127
- } catch (err) {
128
- _didIteratorError = true;
129
- _iteratorError = err;
130
- } finally{
131
- try {
132
- if (!_iteratorNormalCompletion && _iterator.return != null) {
133
- _iterator.return();
134
- }
135
- } finally{
136
- if (_didIteratorError) {
137
- throw _iteratorError;
138
- }
139
- }
140
- }
141
- return allow;
142
- }
143
- /**
144
- * Builds a prefer-config-object-style rule with a configurable default `maxParams` threshold.
145
- * Class constructors and decorated parameters (e.g. NestJS `@Inject`) are exempted. Functions can
146
- * opt out via a leading JSDoc block carrying the configured allow tag (default `@dbxAllowMultiParams`).
147
- *
148
- * @param config - Default threshold and rule description.
149
- * @returns A complete ESLint rule definition that emits `tooManyParams` reports.
150
- */ function createPreferConfigObjectRule(config) {
151
- return {
152
- meta: {
153
- type: 'suggestion',
154
- docs: {
155
- description: config.description,
156
- recommended: true
157
- },
158
- messages: {
159
- tooManyParams: "Function '{{name}}' takes {{count}} positional parameters; use a single config object instead (see dbx__note__typescript-programming → Prefer Single Config Object)."
160
- },
161
- schema: [
162
- {
163
- type: 'object',
164
- properties: {
165
- maxParams: {
166
- type: 'number',
167
- minimum: 0,
168
- description: 'Maximum number of positional parameters before the rule fires.'
169
- },
170
- allowJsdocTag: {
171
- type: 'string',
172
- description: 'JSDoc tag that opts a function out of this rule.'
173
- }
174
- },
175
- additionalProperties: false
176
- }
177
- ]
178
- },
179
- create: function create(context) {
180
- var _context_options_, _options_maxParams, _options_allowJsdocTag;
181
- var options = (_context_options_ = context.options[0]) !== null && _context_options_ !== void 0 ? _context_options_ : {};
182
- var maxParams = (_options_maxParams = options.maxParams) !== null && _options_maxParams !== void 0 ? _options_maxParams : config.defaultMaxParams;
183
- var allowTag = (_options_allowJsdocTag = options.allowJsdocTag) !== null && _options_allowJsdocTag !== void 0 ? _options_allowJsdocTag : DEFAULT_ALLOW_JSDOC_TAG;
184
- var sourceCode = context.sourceCode;
185
- function checkFunction(node) {
186
- if (!isConstructor(node)) {
187
- var _node_params;
188
- var params = (_node_params = node.params) !== null && _node_params !== void 0 ? _node_params : [];
189
- // Decorated parameters indicate framework-driven signatures (NestJS handlers, Angular DI inside
190
- // constructors which we already skip — but standalone decorated functions exist too).
191
- if (!params.some(paramHasDecorator) && params.length > maxParams) {
192
- var _node_parent, _node_parent_parent;
193
- // Anchor for JSDoc lookup: prefer the enclosing export statement, then a VariableDeclaration
194
- // (for `const fn = () => ...`), otherwise the function node itself.
195
- var anchor = node;
196
- if (((_node_parent = node.parent) === null || _node_parent === void 0 ? void 0 : _node_parent.type) === 'VariableDeclarator' && ((_node_parent_parent = node.parent.parent) === null || _node_parent_parent === void 0 ? void 0 : _node_parent_parent.type) === 'VariableDeclaration') {
197
- anchor = node.parent.parent;
198
- }
199
- if (anchor.parent && (anchor.parent.type === 'ExportNamedDeclaration' || anchor.parent.type === 'ExportDefaultDeclaration')) {
200
- anchor = anchor.parent;
201
- }
202
- if (!hasAllowJsdoc(sourceCode, anchor, allowTag)) {
203
- var _node_id;
204
- var name = getFunctionDisplayName(node);
205
- context.report({
206
- node: (_node_id = node.id) !== null && _node_id !== void 0 ? _node_id : node,
207
- messageId: 'tooManyParams',
208
- data: {
209
- name: name,
210
- count: String(params.length)
211
- }
212
- });
213
- }
214
- }
215
- }
216
- }
217
- return {
218
- FunctionDeclaration: checkFunction,
219
- FunctionExpression: checkFunction,
220
- ArrowFunctionExpression: checkFunction
221
- };
222
- }
223
- };
224
- }
225
- /**
226
- * ESLint rule recommending a single config object when a function takes more than two positional
227
- * parameters (default `maxParams: 2`, i.e. fires at 3+ args). Intended to be configured at the
228
- * `warn` severity. Pair with `prefer-config-object-hard` for a stricter cap.
229
- *
230
- * @see `dbx__note__typescript-programming` → Prefer Single Config Object
231
- */ createPreferConfigObjectRule({
232
- defaultMaxParams: DEFAULT_MAX_PARAMS_WARN,
233
- description: 'Prefer a single config object when a function takes more than two positional parameters.'
234
- });
235
- /**
236
- * Hard-stop variant of `prefer-config-object`. Fires when a function takes more than four positional
237
- * parameters (default `maxParams: 4`, i.e. fires at 5+ args). Intended to be configured at the
238
- * `error` severity so genuinely unwieldy signatures break the build even when the softer warn-level
239
- * rule is disabled or downgraded.
240
- *
241
- * @see `dbx__note__typescript-programming` → Prefer Single Config Object
242
- */ createPreferConfigObjectRule({
243
- defaultMaxParams: DEFAULT_MAX_PARAMS_HARD,
244
- description: 'Reject function signatures with more than four positional parameters; require a single config object.'
245
- });
246
-
247
53
  function _array_like_to_array$h(arr, len) {
248
54
  if (len == null || len > arr.length) len = arr.length;
249
55
  for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
@@ -1,16 +1,17 @@
1
1
  {
2
2
  "name": "@dereekb/firebase/eslint",
3
- "version": "14.0.1",
3
+ "version": "14.2.0",
4
+ "sideEffects": false,
4
5
  "type": "module",
5
6
  "peerDependencies": {
6
- "@dereekb/util": "14.0.1",
7
+ "@dereekb/util": "14.2.0",
7
8
  "@marcbachmann/cel-js": "^8.0.0",
8
9
  "@typescript-eslint/parser": "8.69.0",
9
10
  "@typescript-eslint/utils": "8.69.0",
10
11
  "typescript": "6.0.3"
11
12
  },
12
13
  "devDependencies": {
13
- "@dereekb/firebase": "14.0.1",
14
+ "@dereekb/firebase": "14.2.0",
14
15
  "eslint": "10.9.1",
15
16
  "firebase": "^12.18.0"
16
17
  },