@blumintinc/eslint-plugin-blumint 1.12.5 → 1.13.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.
Files changed (142) hide show
  1. package/README.md +140 -99
  2. package/lib/index.js +111 -20
  3. package/lib/rules/array-methods-this-context.js +20 -2
  4. package/lib/rules/avoid-utils-directory.js +11 -2
  5. package/lib/rules/dynamic-https-errors.d.ts +3 -1
  6. package/lib/rules/dynamic-https-errors.js +48 -10
  7. package/lib/rules/enforce-assert-safe-object-key.d.ts +8 -0
  8. package/lib/rules/{enforce-assertSafe-object-key.js → enforce-assert-safe-object-key.js} +51 -95
  9. package/lib/rules/enforce-assert-throws.d.ts +3 -1
  10. package/lib/rules/enforce-assert-throws.js +493 -51
  11. package/lib/rules/enforce-boolean-naming-prefixes.d.ts +3 -1
  12. package/lib/rules/enforce-boolean-naming-prefixes.js +832 -39
  13. package/lib/rules/enforce-callable-types.js +4 -4
  14. package/lib/rules/enforce-callback-memo.js +143 -18
  15. package/lib/rules/enforce-centralized-mock-firestore.js +4 -1
  16. package/lib/rules/enforce-console-error.d.ts +3 -0
  17. package/lib/rules/enforce-console-error.js +250 -0
  18. package/lib/rules/enforce-css-media-queries.js +24 -46
  19. package/lib/rules/enforce-dynamic-firebase-imports.js +100 -19
  20. package/lib/rules/enforce-dynamic-imports.js +1 -1
  21. package/lib/rules/enforce-exported-function-types.js +3 -3
  22. package/lib/rules/enforce-fieldpath-syntax-in-docsetter.d.ts +2 -0
  23. package/lib/rules/enforce-fieldpath-syntax-in-docsetter.js +212 -0
  24. package/lib/rules/enforce-firestore-doc-ref-generic.js +335 -0
  25. package/lib/rules/enforce-firestore-facade.js +347 -157
  26. package/lib/rules/enforce-firestore-rules-get-access.d.ts +3 -0
  27. package/lib/rules/enforce-firestore-rules-get-access.js +109 -0
  28. package/lib/rules/enforce-global-constants.d.ts +4 -1
  29. package/lib/rules/enforce-global-constants.js +240 -12
  30. package/lib/rules/enforce-memoize-async.d.ts +2 -1
  31. package/lib/rules/enforce-memoize-async.js +96 -27
  32. package/lib/rules/enforce-memoize-getters.d.ts +3 -0
  33. package/lib/rules/enforce-memoize-getters.js +123 -0
  34. package/lib/rules/enforce-microdiff.js +2 -1
  35. package/lib/rules/enforce-positive-naming.js +5 -7
  36. package/lib/rules/enforce-props-argument-name.d.ts +2 -7
  37. package/lib/rules/enforce-props-argument-name.js +165 -151
  38. package/lib/rules/enforce-props-naming-consistency.d.ts +2 -0
  39. package/lib/rules/enforce-props-naming-consistency.js +145 -0
  40. package/lib/rules/enforce-querykey-ts.d.ts +9 -0
  41. package/lib/rules/enforce-querykey-ts.js +274 -0
  42. package/lib/rules/enforce-singular-type-names.js +9 -5
  43. package/lib/rules/enforce-typescript-markdown-code-blocks.d.ts +1 -0
  44. package/lib/rules/enforce-typescript-markdown-code-blocks.js +96 -0
  45. package/lib/rules/enforce-verb-noun-naming.js +85 -10
  46. package/lib/rules/extract-global-constants.js +57 -45
  47. package/lib/rules/fast-deep-equal-over-microdiff.d.ts +2 -1
  48. package/lib/rules/fast-deep-equal-over-microdiff.js +356 -78
  49. package/lib/rules/firestore-transaction-reads-before-writes.d.ts +1 -0
  50. package/lib/rules/firestore-transaction-reads-before-writes.js +231 -0
  51. package/lib/rules/generic-starts-with-t.js +8 -2
  52. package/lib/rules/memoize-root-level-hocs.d.ts +7 -0
  53. package/lib/rules/memoize-root-level-hocs.js +242 -0
  54. package/lib/rules/no-array-length-in-deps.d.ts +12 -0
  55. package/lib/rules/no-array-length-in-deps.js +308 -0
  56. package/lib/rules/no-async-array-filter.js +5 -2
  57. package/lib/rules/no-complex-cloud-params.js +15 -2
  58. package/lib/rules/no-compositing-layer-props.js +4 -2
  59. package/lib/rules/no-entire-object-hook-deps.d.ts +3 -1
  60. package/lib/rules/no-entire-object-hook-deps.js +317 -63
  61. package/lib/rules/no-excessive-parent-chain.d.ts +5 -0
  62. package/lib/rules/no-excessive-parent-chain.js +273 -0
  63. package/lib/rules/no-firestore-object-arrays.js +345 -30
  64. package/lib/rules/no-hungarian.js +13 -13
  65. package/lib/rules/no-margin-properties.d.ts +7 -1
  66. package/lib/rules/no-margin-properties.js +16 -3
  67. package/lib/rules/no-misleading-boolean-prefixes.d.ts +7 -0
  68. package/lib/rules/no-misleading-boolean-prefixes.js +327 -0
  69. package/lib/rules/no-overridable-method-calls-in-constructor.d.ts +1 -0
  70. package/lib/rules/no-overridable-method-calls-in-constructor.js +260 -0
  71. package/lib/rules/no-passthrough-getters.d.ts +4 -0
  72. package/lib/rules/no-passthrough-getters.js +170 -0
  73. package/lib/rules/no-redundant-usecallback-wrapper.d.ts +8 -0
  74. package/lib/rules/no-redundant-usecallback-wrapper.js +315 -0
  75. package/lib/rules/no-restricted-properties-fix.d.ts +12 -0
  76. package/lib/rules/no-restricted-properties-fix.js +172 -0
  77. package/lib/rules/no-separate-loading-state.d.ts +8 -0
  78. package/lib/rules/no-separate-loading-state.js +142 -0
  79. package/lib/rules/no-stale-state-across-await.d.ts +1 -0
  80. package/lib/rules/no-stale-state-across-await.js +185 -0
  81. package/lib/rules/no-static-constants-in-dynamic-files.d.ts +3 -0
  82. package/lib/rules/no-static-constants-in-dynamic-files.js +149 -0
  83. package/lib/rules/no-try-catch-already-exists-in-transaction.d.ts +1 -0
  84. package/lib/rules/no-try-catch-already-exists-in-transaction.js +342 -0
  85. package/lib/rules/no-undefined-null-passthrough.js +166 -19
  86. package/lib/rules/no-unnecessary-verb-suffix.js +0 -2
  87. package/lib/rules/no-unsafe-firestore-spread.js +8 -5
  88. package/lib/rules/no-unused-props.d.ts +3 -0
  89. package/lib/rules/no-unused-props.js +213 -78
  90. package/lib/rules/optimize-object-boolean-conditions.d.ts +1 -0
  91. package/lib/rules/optimize-object-boolean-conditions.js +234 -0
  92. package/lib/rules/parallelize-async-operations.d.ts +8 -0
  93. package/lib/rules/parallelize-async-operations.js +375 -0
  94. package/lib/rules/prefer-batch-operations.js +199 -33
  95. package/lib/rules/prefer-block-comments-for-declarations.js +13 -3
  96. package/lib/rules/prefer-document-flattening.d.ts +4 -0
  97. package/lib/rules/prefer-document-flattening.js +239 -0
  98. package/lib/rules/prefer-field-paths-in-transforms.d.ts +7 -0
  99. package/lib/rules/prefer-field-paths-in-transforms.js +250 -0
  100. package/lib/rules/prefer-fragment-component.js +3 -3
  101. package/lib/rules/prefer-global-router-state-key.d.ts +7 -3
  102. package/lib/rules/prefer-global-router-state-key.js +230 -31
  103. package/lib/rules/prefer-next-dynamic.d.ts +9 -0
  104. package/lib/rules/prefer-next-dynamic.js +366 -0
  105. package/lib/rules/prefer-nullish-coalescing-boolean-props.d.ts +1 -0
  106. package/lib/rules/prefer-nullish-coalescing-boolean-props.js +430 -0
  107. package/lib/rules/prefer-nullish-coalescing-override.d.ts +6 -0
  108. package/lib/rules/prefer-nullish-coalescing-override.js +182 -0
  109. package/lib/rules/prefer-params-over-parent-id.d.ts +5 -0
  110. package/lib/rules/prefer-params-over-parent-id.js +228 -0
  111. package/lib/rules/prefer-settings-object.js +23 -15
  112. package/lib/rules/prefer-type-alias-over-typeof-constant.d.ts +3 -0
  113. package/lib/rules/prefer-type-alias-over-typeof-constant.js +259 -0
  114. package/lib/rules/prefer-url-tostring-over-tojson.d.ts +2 -0
  115. package/lib/rules/prefer-url-tostring-over-tojson.js +166 -0
  116. package/lib/rules/prefer-use-deep-compare-memo.d.ts +4 -0
  117. package/lib/rules/prefer-use-deep-compare-memo.js +428 -0
  118. package/lib/rules/prefer-usecallback-over-usememo-for-functions.js +24 -1
  119. package/lib/rules/prefer-usememo-over-useeffect-usestate.js +24 -5
  120. package/lib/rules/react-usememo-should-be-component.d.ts +2 -1
  121. package/lib/rules/react-usememo-should-be-component.js +144 -78
  122. package/lib/rules/require-dynamic-firebase-imports.js +2 -1
  123. package/lib/rules/require-image-optimized.js +1 -1
  124. package/lib/rules/require-memo.js +11 -1
  125. package/lib/rules/require-usememo-object-literals.js +7 -1
  126. package/lib/rules/semantic-function-prefixes.js +38 -18
  127. package/lib/rules/sync-onwrite-name-func.js +5 -1
  128. package/lib/rules/test-file-location-enforcement.d.ts +1 -0
  129. package/lib/rules/test-file-location-enforcement.js +57 -0
  130. package/lib/rules/use-custom-link.js +6 -1
  131. package/lib/rules/use-custom-router.js +6 -1
  132. package/lib/rules/use-latest-callback.d.ts +3 -0
  133. package/lib/rules/use-latest-callback.js +270 -0
  134. package/lib/utils/ASTHelpers.js +10 -0
  135. package/lib/utils/createRule.js +1 -1
  136. package/lib/utils/graph/ClassGraphSorterReadability.js +1 -1
  137. package/lib/utils/ruleTester.d.ts +1 -0
  138. package/lib/utils/ruleTester.js +4 -1
  139. package/package.json +21 -14
  140. package/lib/rules/enforce-assertSafe-object-key.d.ts +0 -2
  141. package/lib/rules/no-restricted-imports-dynamic.d.ts +0 -25
  142. package/lib/rules/no-restricted-imports-dynamic.js +0 -213
@@ -1,213 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.RULE_NAME = void 0;
7
- const path_1 = __importDefault(require("path"));
8
- const createRule_1 = require("../utils/createRule");
9
- exports.RULE_NAME = 'no-restricted-imports-dynamic';
10
- exports.default = (0, createRule_1.createRule)({
11
- name: exports.RULE_NAME,
12
- meta: {
13
- type: 'suggestion',
14
- docs: {
15
- description: 'Disallow specified modules when loaded by `import`, with special handling for .dynamic.tsx files',
16
- recommended: 'error',
17
- },
18
- schema: [
19
- {
20
- oneOf: [
21
- {
22
- type: 'object',
23
- properties: {
24
- paths: {
25
- type: 'array',
26
- items: {
27
- oneOf: [
28
- { type: 'string' },
29
- {
30
- type: 'object',
31
- properties: {
32
- name: { type: 'string' },
33
- message: { type: 'string' },
34
- allowTypeImports: { type: 'boolean' },
35
- allowDynamicImports: { type: 'boolean' },
36
- },
37
- additionalProperties: false,
38
- required: ['name'],
39
- },
40
- ],
41
- },
42
- },
43
- patterns: {
44
- type: 'array',
45
- items: {
46
- oneOf: [
47
- { type: 'string' },
48
- {
49
- type: 'object',
50
- properties: {
51
- group: {
52
- type: 'array',
53
- items: { type: 'string' },
54
- minItems: 1,
55
- },
56
- message: { type: 'string' },
57
- caseSensitive: { type: 'boolean' },
58
- allowTypeImports: { type: 'boolean' },
59
- allowDynamicImports: { type: 'boolean' },
60
- },
61
- additionalProperties: false,
62
- required: ['group'],
63
- },
64
- ],
65
- },
66
- },
67
- },
68
- additionalProperties: false,
69
- },
70
- {
71
- type: 'array',
72
- items: {
73
- oneOf: [
74
- { type: 'string' },
75
- {
76
- type: 'object',
77
- properties: {
78
- name: { type: 'string' },
79
- message: { type: 'string' },
80
- allowTypeImports: { type: 'boolean' },
81
- allowDynamicImports: { type: 'boolean' },
82
- },
83
- additionalProperties: false,
84
- required: ['name'],
85
- },
86
- ],
87
- },
88
- },
89
- ],
90
- },
91
- ],
92
- messages: {
93
- restrictedImport: "import '{{importSource}}' is restricted from being used{{customMessage}}",
94
- restrictedImportPattern: "import '{{importSource}}' is restricted from being used by a pattern{{customMessage}}",
95
- },
96
- },
97
- defaultOptions: [{ paths: [], patterns: [] }],
98
- create(context, [options]) {
99
- // Get the file path and name
100
- const filePath = context.getFilename();
101
- const fileName = path_1.default.basename(filePath);
102
- // Check if the file has .dynamic.ts or .dynamic.tsx extension
103
- const isDynamicFile = /\.dynamic\.tsx?$/.test(fileName);
104
- // If this is a dynamic file, we'll allow imports from other dynamic files
105
- if (isDynamicFile) {
106
- return {};
107
- }
108
- // Process options
109
- const restrictedPaths = [];
110
- const restrictedPatterns = [];
111
- if (Array.isArray(options)) {
112
- // Handle array format
113
- for (const item of options) {
114
- if (typeof item === 'string') {
115
- restrictedPaths.push({ name: item });
116
- }
117
- else {
118
- restrictedPaths.push(item);
119
- }
120
- }
121
- }
122
- else if (options && typeof options === 'object') {
123
- // Handle object format
124
- if (options.paths) {
125
- for (const item of options.paths) {
126
- if (typeof item === 'string') {
127
- restrictedPaths.push({ name: item });
128
- }
129
- else {
130
- restrictedPaths.push(item);
131
- }
132
- }
133
- }
134
- if (options.patterns) {
135
- for (const item of options.patterns) {
136
- if (typeof item === 'string') {
137
- restrictedPatterns.push({ group: [item] });
138
- }
139
- else {
140
- restrictedPatterns.push(item);
141
- }
142
- }
143
- }
144
- }
145
- return {
146
- ImportDeclaration(node) {
147
- const importSource = node.source.value;
148
- const importKind = node.importKind;
149
- // Check against restricted paths
150
- for (const restrictedPath of restrictedPaths) {
151
- if (importSource === restrictedPath.name) {
152
- // Skip if it's a type import and type imports are allowed
153
- if (importKind === 'type' &&
154
- restrictedPath.allowTypeImports === true) {
155
- continue;
156
- }
157
- // Skip if it's a dynamic import and dynamic imports are allowed
158
- if (importSource.endsWith('.dynamic') &&
159
- restrictedPath.allowDynamicImports === true) {
160
- continue;
161
- }
162
- context.report({
163
- node,
164
- messageId: 'restrictedImport',
165
- data: {
166
- importSource,
167
- customMessage: restrictedPath.message
168
- ? `: ${restrictedPath.message}`
169
- : '',
170
- },
171
- });
172
- }
173
- }
174
- // Check against restricted patterns
175
- for (const restrictedPattern of restrictedPatterns) {
176
- const { group, caseSensitive = false } = restrictedPattern;
177
- const matched = group.some((pattern) => {
178
- if (pattern.includes('*')) {
179
- const regex = new RegExp(`^${pattern.replace(/\*/g, '.*')}$`, caseSensitive ? '' : 'i');
180
- return regex.test(importSource);
181
- }
182
- return caseSensitive
183
- ? importSource === pattern
184
- : importSource.toLowerCase() === pattern.toLowerCase();
185
- });
186
- if (matched) {
187
- // Skip if it's a type import and type imports are allowed
188
- if (importKind === 'type' &&
189
- restrictedPattern.allowTypeImports === true) {
190
- continue;
191
- }
192
- // Skip if it's a dynamic import and dynamic imports are allowed
193
- if (importSource.endsWith('.dynamic') &&
194
- restrictedPattern.allowDynamicImports === true) {
195
- continue;
196
- }
197
- context.report({
198
- node,
199
- messageId: 'restrictedImportPattern',
200
- data: {
201
- importSource,
202
- customMessage: restrictedPattern.message
203
- ? `: ${restrictedPattern.message}`
204
- : '',
205
- },
206
- });
207
- }
208
- }
209
- },
210
- };
211
- },
212
- });
213
- //# sourceMappingURL=no-restricted-imports-dynamic.js.map