eslint-plugin-use-agnostic 1.6.8 → 1.6.9

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.
@@ -129,6 +129,8 @@ export const importedFileCommentedDirective = "importedFileCommentedDirective";
129
129
  export const commentedDirectiveMessage = "commentedDirectiveMessage";
130
130
  export const specificViolationMessage = "specificViolationMessage";
131
131
  export const specificFailure = "specificFailure";
132
+ export const currentFileEnvironment = "currentFileEnvironment";
133
+ export const importedFileEnvironment = "importedFileEnvironment";
132
134
 
133
135
  /* commentedDirectives_verificationReports */
134
136
 
@@ -155,12 +157,12 @@ export const commentedDirectives_verificationReports = Object.freeze({
155
157
  /* commentedDirectives_blockedImports */
156
158
 
157
159
  /**
158
- * Makes a blockedImport object for the identified blocked import at hand.
160
+ * $COMMENT#JSDOC#DEFINITIONS#AGNOSTIC20#MAKEBLOCKEDIMPORT
159
161
  * @template {CommentedDirectiveWithoutUseAgnosticStrategies} T
160
162
  * @template {CommentedDirectiveWithoutUseAgnosticStrategies} U
161
- * @param {T} currentFileCommentedDirective The current file's commented directive.
162
- * @param {U} importedFileCommentedDirective The imported file's commented directive.
163
- * @returns The blockedImport object for the identified blocked import at hand.
163
+ * @param {T} currentFileCommentedDirective $COMMENT#JSDOC#PARAMS#DIRECTIVE21#CURRENTFILECOMMENTEDDIRECTIVE
164
+ * @param {U} importedFileCommentedDirective $COMMENT#JSDOC#PARAMS#DIRECTIVE21#IMPORTEDFILECOMMENTEDDIRECTIVE
165
+ * @returns $COMMENT#JSDOC#RETURNS#AGNOSTIC20#MAKEBLOCKEDIMPORT
164
166
  */
165
167
  export const makeBlockedImport = (
166
168
  currentFileCommentedDirective,
@@ -181,189 +183,208 @@ export const makeBlockedImport = (
181
183
 
182
184
  export const commentedDirectives_blockedImports = Object.freeze({
183
185
  [USE_SERVER_LOGICS]: Object.freeze([
184
- // USE_SERVER_LOGICS allowed, because Prime Server Logics can compose with one another.
186
+ // USE_SERVER_LOGICS $COMMENT#AGNOSTIC20#FORCOMPOSEDVARIABLES#ALLOWEDBECAUSE $COMMENT#DIRECTIVE21#USE_SERVER_LOGICS#USE_SERVER_LOGICS
185
187
  makeBlockedImport(
186
188
  USE_SERVER_LOGICS,
187
189
  USE_CLIENT_LOGICS
188
- ) /* Prime Client Logics should never leak to the server. */,
189
- // USE_AGNOSTIC_LOGICS allowed, because Prime Agnostic Logics can run safely on the server just like they can on the client.
190
- // USE_SERVER_COMPONENTS allowed, because Lineal Server Components are OK to be composed with Prime Server Logics as long as the Prime Server Logics Module, by convention, does not export React components.
190
+ ) /* $COMMENT#DIRECTIVE21#FORALIASVARIABLES#CLIENTNEVERSERVER */,
191
+ // USE_AGNOSTIC_LOGICS $COMMENT#AGNOSTIC20#FORCOMPOSEDVARIABLES#ALLOWEDBECAUSE $COMMENT#DIRECTIVE21#FORALIASVARIABLES#AGNOSTICCANSERVERCLIENT
192
+ // USE_SERVER_COMPONENTS $COMMENT#AGNOSTIC20#FORCOMPOSEDVARIABLES#ALLOWEDBECAUSE $COMMENT#DIRECTIVE21#USE_SERVER_LOGICS#USE_SERVER_COMPONENTS
191
193
  makeBlockedImport(
192
194
  USE_SERVER_LOGICS,
193
195
  USE_CLIENT_COMPONENTS
194
- ) /* Lineal Client Components, like any Client Components, cannot be tinkered with on the server. */,
195
- // USE_AGNOSTIC_COMPONENTS allowed, because Lineal Agnostic Components can be composed with any Prime Environment Logics agnostically, as long as the Prime Environment Logics Module, by convention, does not export React components.
196
- // USE_SERVER_FUNCTIONS allowed, because (Special) Server Functions, being able to import one another, can compose and do so via Prime Server Logics, despite this method seeming superfluous at first glance. (Perhaps a preferrable use case for this has been found or could be found either today or in the future.)
196
+ ) /* $COMMENT#DIRECTIVE21#USE_SERVER_LOGICS#USE_CLIENT_COMPONENTS */,
197
+ // USE_AGNOSTIC_COMPONENTS $COMMENT#AGNOSTIC20#FORCOMPOSEDVARIABLES#ALLOWEDBECAUSE $COMMENT#DIRECTIVE21#FORALIASVARIABLES#AGNOSTICCOMPONENTSCANANY
198
+ // USE_SERVER_FUNCTIONS $COMMENT#AGNOSTIC20#FORCOMPOSEDVARIABLES#ALLOWEDBECAUSE $COMMENT#DIRECTIVE21#USE_SERVER_LOGICS#USE_SERVER_FUNCTIONS
197
199
  makeBlockedImport(
198
200
  USE_SERVER_LOGICS,
199
201
  USE_CLIENT_CONTEXTS
200
- ) /* (Special) Client Contexts Components, like any Client Components, cannot be tinkered with on the server. */,
201
- // USE_AGNOSTIC_CONDITIONS allowed, because (Special) Agnostic Conditions Components are able to safely render on the server, guaranteeing that only their `ComponentForServer` will be effectively involved in Prime Server Logics Modules.
202
+ ) /* $COMMENT#DIRECTIVE21#USE_SERVER_LOGICS#USE_CLIENT_CONTEXTS */,
203
+ // USE_AGNOSTIC_CONDITIONS $COMMENT#AGNOSTIC20#FORCOMPOSEDVARIABLES#ALLOWEDBECAUSE $COMMENT#DIRECTIVE21#USE_SERVER_LOGICS#USE_AGNOSTIC_CONDITIONS
202
204
  ]),
203
205
  [USE_CLIENT_LOGICS]: Object.freeze([
204
206
  makeBlockedImport(
205
207
  USE_CLIENT_LOGICS,
206
208
  USE_SERVER_LOGICS
207
- ) /* Prime Server Logics should never leak to the client. */,
208
- // USE_CLIENT_LOGICS allowed, because Prime Client Logics can compose with one another.
209
- // USE_AGNOSTIC_LOGICS allowed, because Prime Agnostic Logics can run safely on the client just like they can on the server.
209
+ ) /* $COMMENT#DIRECTIVE21#FORALIASVARIABLES#SERVERNEVERCLIENT */,
210
+ // USE_CLIENT_LOGICS $COMMENT#AGNOSTIC20#FORCOMPOSEDVARIABLES#ALLOWEDBECAUSE $COMMENT#DIRECTIVE21#USE_CLIENT_LOGICS#USE_CLIENT_LOGICS
211
+ // USE_AGNOSTIC_LOGICS $COMMENT#AGNOSTIC20#FORCOMPOSEDVARIABLES#ALLOWEDBECAUSE $COMMENT#DIRECTIVE21#FORALIASVARIABLES#AGNOSTICCANCLIENTSERVER
210
212
  makeBlockedImport(
211
213
  USE_CLIENT_LOGICS,
212
214
  USE_SERVER_COMPONENTS
213
- ) /* Lineal Server Components cannot be tinkered with on the client. */,
214
- // USE_CLIENT_COMPONENTS allowed, because Prime Client Logics, like any Client Components, are OK to be composed with Prime Client Logics as long as the Prime Client Logics Module, by convention, does not export React components.
215
- // USE_AGNOSTIC_COMPONENTS allowed, because Lineal Agnostic Components can be composed with any Prime Environment Logics agnostically, as long as the Prime Environment Logics Module, by convention, does not export React components.
216
- // USE_SERVER_FUNCTIONS allowed, because (Special) Server Functions can technically be attached to any Client Components that are being tinkered with within Client Logics Modules.
217
- // USE_CLIENT_CONTEXTS allowed, because (Special) Client Contexts Components, like any Client Components, are OK to be composed with Prime Client Logics as long as the Prime Client Logics Module, by convention, does not export React components.
218
- // USE_AGNOSTIC_CONDITIONS allowed, because (Special) Agnostic Conditions Components are able to safely render on the client, guaranteeing that only their `ComponentForClient` will be effectively involved in Prime Client Logics Modules.
215
+ ) /* $COMMENT#DIRECTIVE21#USE_CLIENT_LOGICS#USE_SERVER_COMPONENTS */,
216
+ // USE_CLIENT_COMPONENTS $COMMENT#AGNOSTIC20#FORCOMPOSEDVARIABLES#ALLOWEDBECAUSE $COMMENT#DIRECTIVE21#USE_CLIENT_LOGICS#USE_CLIENT_COMPONENTS
217
+ // USE_AGNOSTIC_COMPONENTS $COMMENT#AGNOSTIC20#FORCOMPOSEDVARIABLES#ALLOWEDBECAUSE $COMMENT#DIRECTIVE21#FORALIASVARIABLES#AGNOSTICCOMPONENTSCANANY
218
+ // USE_SERVER_FUNCTIONS $COMMENT#AGNOSTIC20#FORCOMPOSEDVARIABLES#ALLOWEDBECAUSE $COMMENT#DIRECTIVE21#USE_CLIENT_LOGICS#USE_SERVER_FUNCTIONS
219
+ // USE_CLIENT_CONTEXTS $COMMENT#AGNOSTIC20#FORCOMPOSEDVARIABLES#ALLOWEDBECAUSE $COMMENT#DIRECTIVE21#USE_CLIENT_LOGICS#USE_CLIENT_CONTEXTS
220
+ // USE_AGNOSTIC_CONDITIONS $COMMENT#AGNOSTIC20#FORCOMPOSEDVARIABLES#ALLOWEDBECAUSE $COMMENT#DIRECTIVE21#USE_CLIENT_LOGICS#USE_AGNOSTIC_CONDITIONS
219
221
  ]),
220
222
  [USE_AGNOSTIC_LOGICS]: Object.freeze([
221
223
  makeBlockedImport(
222
224
  USE_AGNOSTIC_LOGICS,
223
225
  USE_SERVER_LOGICS
224
- ) /* Prime Server Logics cannot run on both the server and the client. */,
226
+ ) /* $COMMENT#DIRECTIVE21#FORALIASVARIABLES#SERVERLOGICSCANTBOTH */,
225
227
  makeBlockedImport(
226
228
  USE_AGNOSTIC_LOGICS,
227
229
  USE_CLIENT_LOGICS
228
- ) /* Prime Client Logics cannot run on both the server and the client. */,
229
- // USE_AGNOSTIC_LOGICS allowed, because Prime Agnostic Logics can compose with one another.
230
+ ) /* $COMMENT#DIRECTIVE21#FORALIASVARIABLES#CLIENTLOGICSCANTBOTH */,
231
+ // USE_AGNOSTIC_LOGICS $COMMENT#AGNOSTIC20#FORCOMPOSEDVARIABLES#ALLOWEDBECAUSE $COMMENT#DIRECTIVE21#USE_AGNOSTIC_LOGICS#USE_AGNOSTIC_LOGICS
230
232
  makeBlockedImport(
231
233
  USE_AGNOSTIC_LOGICS,
232
234
  USE_SERVER_COMPONENTS
233
- ) /* Lineal Server Components cannot be tinkered with on both the server and the client. */,
235
+ ) /* $COMMENT#DIRECTIVE21#USE_AGNOSTIC_LOGICS#USE_SERVER_COMPONENTS */,
234
236
  makeBlockedImport(
235
237
  USE_AGNOSTIC_LOGICS,
236
238
  USE_CLIENT_COMPONENTS
237
- ) /* Lineal Client Components, like any Client Components, cannot be tinkered with on both the server and the client. */,
238
- // USE_AGNOSTIC_COMPONENTS allowed, because Lineal Agnostic Components can be composed with any Prime Environment Logics agnostically, as long as the Prime Environment Logics Module, by convention, does not export React components.
239
+ ) /* $COMMENT#DIRECTIVE21#USE_AGNOSTIC_LOGICS#USE_CLIENT_COMPONENTS */,
240
+ // USE_AGNOSTIC_COMPONENTS $COMMENT#AGNOSTIC20#FORCOMPOSEDVARIABLES#ALLOWEDBECAUSE $COMMENT#DIRECTIVE21#FORALIASVARIABLES#AGNOSTICCOMPONENTSCANANY
239
241
  makeBlockedImport(
240
242
  USE_AGNOSTIC_LOGICS,
241
243
  USE_SERVER_FUNCTIONS
242
- ) /* (Special) Server Functions can be modified on the server and on the client, but their use cases on both environments are not one-to-one compatible, since they're being addressed as they are on the server and addressed as references on the client. */,
244
+ ) /* $COMMENT#DIRECTIVE21#USE_AGNOSTIC_LOGICS#USE_SERVER_FUNCTIONS */,
243
245
  makeBlockedImport(
244
246
  USE_AGNOSTIC_LOGICS,
245
247
  USE_CLIENT_CONTEXTS
246
- ) /* (Special) Client Contexts Components, like any Client Components, cannot be tinkered with on both the server and the client. */,
247
- // USE_AGNOSTIC_CONDITIONS allowed, because (Special) Agnostic Conditions Components, as if they were Lineal Agnostic Components themselves, can be composed with any Prime Environment Logics agnostically, as long as the Prime Environment Logics Module, by convention, does not export React components.
248
+ ) /* $COMMENT#DIRECTIVE21#USE_AGNOSTIC_LOGICS#USE_CLIENT_CONTEXTS */,
249
+ // USE_AGNOSTIC_CONDITIONS $COMMENT#AGNOSTIC20#FORCOMPOSEDVARIABLES#ALLOWEDBECAUSE $COMMENT#DIRECTIVE21#USE_AGNOSTIC_LOGICS#USE_AGNOSTIC_CONDITIONS
248
250
  ]),
249
251
  [USE_SERVER_COMPONENTS]: Object.freeze([
250
- // USE_SERVER_LOGICS allowed, because Prime Server Logics, being logic from the server, can safely support Lineal Server Components.
252
+ // USE_SERVER_LOGICS $COMMENT#AGNOSTIC20#FORCOMPOSEDVARIABLES#ALLOWEDBECAUSE $COMMENT#DIRECTIVE21#USE_SERVER_COMPONENTS#USE_SERVER_LOGICS
251
253
  makeBlockedImport(
252
254
  USE_SERVER_COMPONENTS,
253
255
  USE_CLIENT_LOGICS
254
- ) /* Prime Client Logics should never leak to the server. */,
255
- // USE_AGNOSTIC_LOGICS allowed, because Prime Agnostic Logics can run safely on the server just like they can on the client.
256
- // USE_SERVER_COMPONENTS allowed, because Lineal Server Components can compose with one another, now that thanks to the inclusion of Agnostic Components they are actual Server Components.
257
- // USE_CLIENT_COMPONENTS allowed, because Lineal Client Components can be nested inside Lineal Server Components to create client boundaries when the root of the application is planted on the server.
258
- // USE_AGNOSTIC_COMPONENTS allowed, because Lineal Agnostic Components can render safely on the server just like they can on the client.
259
- // USE_SERVER_FUNCTIONS allowed, because (Special) Server Functions can be passed to imported Client Components within Lineal Server Components Modules, even though indeed Lineal Server Components Modules and Lineal Server Components can make their own Server Functions through inline `'use server'` directives.
260
- // USE_CLIENT_CONTEXTS allowed, because (Special) Client Contexts Components can be nested inside Lineal Server Components to wrap some of the tree with client state accessible through child Client Components, and to pass through Server Components when the root of the application is planted on the server.
261
- // USE_AGNOSTIC_CONDITIONS allowed, because (Special) Agnostic Conditions Components, as if they were Lineal Agnostic Components themselves, can render safely on the server just like they can on the client.
256
+ ) /* $COMMENT#DIRECTIVE21#FORALIASVARIABLES#CLIENTNEVERSERVER */,
257
+ // USE_AGNOSTIC_LOGICS $COMMENT#AGNOSTIC20#FORCOMPOSEDVARIABLES#ALLOWEDBECAUSE $COMMENT#DIRECTIVE21#FORALIASVARIABLES#AGNOSTICCANSERVERCLIENT
258
+ // USE_SERVER_COMPONENTS $COMMENT#AGNOSTIC20#FORCOMPOSEDVARIABLES#ALLOWEDBECAUSE $COMMENT#DIRECTIVE21#USE_SERVER_COMPONENTS#USE_SERVER_COMPONENTS
259
+ // USE_CLIENT_COMPONENTS $COMMENT#AGNOSTIC20#FORCOMPOSEDVARIABLES#ALLOWEDBECAUSE $COMMENT#DIRECTIVE21#USE_SERVER_COMPONENTS#USE_CLIENT_COMPONENTS
260
+ // USE_AGNOSTIC_COMPONENTS $COMMENT#AGNOSTIC20#FORCOMPOSEDVARIABLES#ALLOWEDBECAUSE $COMMENT#DIRECTIVE21#USE_SERVER_COMPONENTS#USE_AGNOSTIC_COMPONENTS
261
+ // USE_SERVER_FUNCTIONS $COMMENT#AGNOSTIC20#FORCOMPOSEDVARIABLES#ALLOWEDBECAUSE $COMMENT#DIRECTIVE21#USE_SERVER_COMPONENTS#USE_SERVER_FUNCTIONS
262
+ // USE_CLIENT_CONTEXTS $COMMENT#AGNOSTIC20#FORCOMPOSEDVARIABLES#ALLOWEDBECAUSE $COMMENT#DIRECTIVE21#USE_SERVER_COMPONENTS#USE_CLIENT_CONTEXTS
263
+ // USE_AGNOSTIC_CONDITIONS $COMMENT#AGNOSTIC20#FORCOMPOSEDVARIABLES#ALLOWEDBECAUSE $COMMENT#DIRECTIVE21#USE_SERVER_COMPONENTS#USE_AGNOSTIC_CONDITIONS
262
264
  ]),
263
265
  [USE_CLIENT_COMPONENTS]: Object.freeze([
264
266
  makeBlockedImport(
265
267
  USE_CLIENT_COMPONENTS,
266
268
  USE_SERVER_LOGICS
267
- ) /* Prime Server Logics should never leak to the client. */,
268
- // USE_CLIENT_LOGICS allowed, because Prime Client Logics, being logic from the client, can safely support Lineal Client Components, like any Client Components.
269
- // USE_AGNOSTIC_LOGICS allowed, because Prime Agnostic Logics can run safely on the client just like they can on the server.
269
+ ) /* $COMMENT#DIRECTIVE21#FORALIASVARIABLES#SERVERNEVERCLIENT */,
270
+ // USE_CLIENT_LOGICS $COMMENT#AGNOSTIC20#FORCOMPOSEDVARIABLES#ALLOWEDBECAUSE $COMMENT#DIRECTIVE21#USE_CLIENT_COMPONENTS#USE_CLIENT_LOGICS
271
+ // USE_AGNOSTIC_LOGICS $COMMENT#AGNOSTIC20#FORCOMPOSEDVARIABLES#ALLOWEDBECAUSE $COMMENT#DIRECTIVE21#FORALIASVARIABLES#AGNOSTICCANCLIENTSERVER
270
272
  makeBlockedImport(
271
273
  USE_CLIENT_COMPONENTS,
272
274
  USE_SERVER_COMPONENTS
273
- ) /* Lineal Server Components cannot be the children of Lineal Client Components. */,
274
- // USE_CLIENT_COMPONENTS allowed, because Lineal Client Components can compose with one another.
275
- // USE_AGNOSTIC_COMPONENTS allowed, because Lineal Agnostic Components can render safely on the client just like they can on the server.
276
- // USE_SERVER_FUNCTIONS allowed, because (Special) Server Functions can be specifically triggered by Client Components.
277
- // USE_CLIENT_CONTEXTS allowed, because (Special) Client Contexts Components can effectively become Lineal and only render their children on the client via this mechanism since, by a Client Contexts Component being the child of a Lineal Client Component, the Client Contexts Component's children become the grandchildren of an ancestor Lineal Client Component, enforcing them to render exclusively on the client.
278
- // USE_AGNOSTIC_CONDITIONS allowed, because (Special) Agnostic Conditions Components, as if they were Lineal Agnostic Components themselves, can render safely on the client just like they can on the server.
275
+ ) /* $COMMENT#DIRECTIVE21#USE_CLIENT_COMPONENTS#USE_SERVER_COMPONENTS */,
276
+ // USE_CLIENT_COMPONENTS $COMMENT#AGNOSTIC20#FORCOMPOSEDVARIABLES#ALLOWEDBECAUSE $COMMENT#DIRECTIVE21#USE_CLIENT_COMPONENTS#USE_CLIENT_COMPONENTS
277
+ // USE_AGNOSTIC_COMPONENTS $COMMENT#AGNOSTIC20#FORCOMPOSEDVARIABLES#ALLOWEDBECAUSE $COMMENT#DIRECTIVE21#FORALIASVARIABLES#AGNOSTICCOMPONENTSRENDERANY
278
+ // USE_SERVER_FUNCTIONS $COMMENT#AGNOSTIC20#FORCOMPOSEDVARIABLES#ALLOWEDBECAUSE $COMMENT#DIRECTIVE21#FORALIASVARIABLES#SERVERFUNCTIONSCLIENT
279
+ // USE_CLIENT_CONTEXTS $COMMENT#AGNOSTIC20#FORCOMPOSEDVARIABLES#ALLOWEDBECAUSE $COMMENT#DIRECTIVE21#USE_CLIENT_COMPONENTS#USE_CLIENT_CONTEXTS
280
+ // USE_AGNOSTIC_CONDITIONS $COMMENT#AGNOSTIC20#FORCOMPOSEDVARIABLES#ALLOWEDBECAUSE $COMMENT#DIRECTIVE21#USE_CLIENT_COMPONENTS#USE_AGNOSTIC_CONDITIONS
279
281
  ]),
280
282
  [USE_AGNOSTIC_COMPONENTS]: Object.freeze([
281
283
  makeBlockedImport(
282
284
  USE_AGNOSTIC_COMPONENTS,
283
285
  USE_SERVER_LOGICS
284
- ) /* Prime Server Logics cannot run on both the server and the client. */,
286
+ ) /* $COMMENT#DIRECTIVE21#FORALIASVARIABLES#SERVERLOGICSCANTBOTH */,
285
287
  makeBlockedImport(
286
288
  USE_AGNOSTIC_COMPONENTS,
287
289
  USE_CLIENT_LOGICS
288
- ) /* Prime Client Logics cannot run on both the server and the client. */,
289
- // USE_AGNOSTIC_LOGICS allowed, because Prime Agnostic Logics, being environment-agnostic logic, can safely support any Agnostic Components.
290
+ ) /* $COMMENT#DIRECTIVE21#FORALIASVARIABLES#CLIENTLOGICSCANTBOTH */,
291
+ // USE_AGNOSTIC_LOGICS $COMMENT#AGNOSTIC20#FORCOMPOSEDVARIABLES#ALLOWEDBECAUSE $COMMENT#DIRECTIVE21#USE_AGNOSTIC_COMPONENTS#USE_AGNOSTIC_LOGICS
290
292
  makeBlockedImport(
291
293
  USE_AGNOSTIC_COMPONENTS,
292
294
  USE_SERVER_COMPONENTS
293
- ) /* Lineal Server Components, unlike Lineal Client Components, cannot make silos of their own once on the opposing environment (the client in this case), and therefore cannot be executed from the client, making them unable to execute agnostically from both the server and the client. */,
294
- // USE_CLIENT_COMPONENTS allowed, because Lineal Client Components can be nested inside Lineal Agnostic Components to create client boundaries when the root of the application is planted on the server.
295
- // USE_AGNOSTIC_COMPONENTS allowed, because Lineal Agnostic Components can compose with one another.
296
- // USE_SERVER_FUNCTIONS allowed, because (Special) Server Functions can be passed to Client Components as props when Client Components are also legally imported into Agnostic Components Modules.
297
- // USE_CLIENT_CONTEXTS allowed, because (Special) Client Contexts Components can be nested inside Lineal Agnostic Components to wrap some of the tree with client state accessible through child Client Components, and to pass through Server Components — if still on the Server Tree — when the root of the application is planted on the server.
298
- // USE_AGNOSTIC_CONDITIONS allowed, because (Special) Agnostic Conditions Components can compose with Lineal Agnostic Components as if they were Lineal Agnostic Components themselves, making them a necessary mechanism for Lineal Server Components to be nested in any Agnostic Components.
295
+ ) /* $COMMENT#DIRECTIVE21#USE_AGNOSTIC_COMPONENTS#USE_SERVER_COMPONENTS */,
296
+ // USE_CLIENT_COMPONENTS $COMMENT#AGNOSTIC20#FORCOMPOSEDVARIABLES#ALLOWEDBECAUSE $COMMENT#DIRECTIVE21#USE_AGNOSTIC_COMPONENTS#USE_CLIENT_COMPONENTS
297
+ // USE_AGNOSTIC_COMPONENTS $COMMENT#AGNOSTIC20#FORCOMPOSEDVARIABLES#ALLOWEDBECAUSE $COMMENT#DIRECTIVE21#USE_AGNOSTIC_COMPONENTS#USE_AGNOSTIC_COMPONENTS
298
+ // USE_SERVER_FUNCTIONS $COMMENT#AGNOSTIC20#FORCOMPOSEDVARIABLES#ALLOWEDBECAUSE $COMMENT#DIRECTIVE21#USE_AGNOSTIC_COMPONENTS#USE_SERVER_FUNCTIONS
299
+ // USE_CLIENT_CONTEXTS $COMMENT#AGNOSTIC20#FORCOMPOSEDVARIABLES#ALLOWEDBECAUSE $COMMENT#DIRECTIVE21#USE_AGNOSTIC_COMPONENTS#USE_CLIENT_CONTEXTS
300
+ // USE_AGNOSTIC_CONDITIONS $COMMENT#AGNOSTIC20#FORCOMPOSEDVARIABLES#ALLOWEDBECAUSE $COMMENT#DIRECTIVE21#USE_AGNOSTIC_COMPONENTS#USE_AGNOSTIC_CONDITIONS
299
301
  ]),
300
302
  [USE_SERVER_FUNCTIONS]: Object.freeze([
301
- // USE_SERVER_LOGICS allowed, because Prime Server Logics, being logic from the server, can safely support (Special) Server Functions.
303
+ // USE_SERVER_LOGICS $COMMENT#AGNOSTIC20#FORCOMPOSEDVARIABLES#ALLOWEDBECAUSE $COMMENT#DIRECTIVE21#USE_SERVER_FUNCTIONS#USE_SERVER_LOGICS
302
304
  makeBlockedImport(
303
305
  USE_SERVER_FUNCTIONS,
304
306
  USE_CLIENT_LOGICS
305
- ) /* Prime Client Logics should never leak to the server. */,
306
- // USE_AGNOSTIC_LOGICS allowed, because Prime Agnostic Logics can run safely on the server just like they can on the client.
307
+ ) /* $COMMENT#DIRECTIVE21#FORALIASVARIABLES#CLIENTNEVERSERVER */,
308
+ // USE_AGNOSTIC_LOGICS $COMMENT#AGNOSTIC20#FORCOMPOSEDVARIABLES#ALLOWEDBECAUSE $COMMENT#DIRECTIVE21#FORALIASVARIABLES#AGNOSTICCANSERVERCLIENT
307
309
  makeBlockedImport(
308
310
  USE_SERVER_FUNCTIONS,
309
311
  USE_SERVER_COMPONENTS
310
- ) /* Lineal Server Components aren't allowed because (Special) Server Functions have no business working with React Components. */,
312
+ ) /* $COMMENT#DIRECTIVE21#USE_SERVER_FUNCTIONS#USE_SERVER_COMPONENTS */,
311
313
  makeBlockedImport(
312
314
  USE_SERVER_FUNCTIONS,
313
315
  USE_CLIENT_COMPONENTS
314
- ) /* Lineal Client Components aren't allowed because (Special) Server Functions have no business working with React Components. */,
316
+ ) /* $COMMENT#DIRECTIVE21#USE_SERVER_FUNCTIONS#USE_CLIENT_COMPONENTS */,
315
317
  makeBlockedImport(
316
318
  USE_SERVER_FUNCTIONS,
317
319
  USE_AGNOSTIC_COMPONENTS
318
- ) /* Lineal Agnostic Components aren't allowed because (Special) Server Functions have no business working with React Components. */,
319
- // USE_SERVER_FUNCTIONS allowed, because (Special) Server Functions, even though they don't need to import one another and the same results can be generated via Prime Server Logics for the outcome of a single Server Function, can still compose with one another. (Perhaps a preferrable use case for this has been found or could be found either today or in the future.)
320
+ ) /* $COMMENT#DIRECTIVE21#USE_SERVER_FUNCTIONS#USE_AGNOSTIC_COMPONENTS */,
321
+ // USE_SERVER_FUNCTIONS $COMMENT#AGNOSTIC20#FORCOMPOSEDVARIABLES#ALLOWEDBECAUSE $COMMENT#DIRECTIVE21#USE_SERVER_FUNCTIONS#USE_SERVER_FUNCTIONS
320
322
  makeBlockedImport(
321
323
  USE_SERVER_FUNCTIONS,
322
324
  USE_CLIENT_CONTEXTS
323
- ) /* (Special) Client Contexts Components aren't allowed because (Special) Server Functions have no business working with React Components. */,
325
+ ) /* $COMMENT#DIRECTIVE21#USE_SERVER_FUNCTIONS#USE_CLIENT_CONTEXTS */,
324
326
  makeBlockedImport(
325
327
  USE_SERVER_FUNCTIONS,
326
328
  USE_AGNOSTIC_CONDITIONS
327
- ) /* (Special) Agnostic Conditions Components aren't allowed because (Special) Server Functions have no business working with React Components. */,
329
+ ) /* $COMMENT#DIRECTIVE21#USE_SERVER_FUNCTIONS#USE_AGNOSTIC_CONDITIONS */,
328
330
  ]),
329
331
  [USE_CLIENT_CONTEXTS]: Object.freeze([
330
332
  makeBlockedImport(
331
333
  USE_CLIENT_CONTEXTS,
332
334
  USE_SERVER_LOGICS
333
- ) /* Prime Server Logics should never leak to the client. */,
334
- // USE_CLIENT_LOGICS allowed, because Prime Client Logics, being logic from the client, can safely support (Special) Client Contexts Components, like any Client Components.
335
- // USE_AGNOSTIC_LOGICS allowed, because Prime Agnostic Logics can run safely on the client just like they can on the server.
335
+ ) /* $COMMENT#DIRECTIVE21#FORALIASVARIABLES#SERVERNEVERCLIENT */,
336
+ // USE_CLIENT_LOGICS $COMMENT#AGNOSTIC20#FORCOMPOSEDVARIABLES#ALLOWEDBECAUSE $COMMENT#DIRECTIVE21#USE_CLIENT_CONTEXTS#USE_CLIENT_LOGICS
337
+ // USE_AGNOSTIC_LOGICS $COMMENT#AGNOSTIC20#FORCOMPOSEDVARIABLES#ALLOWEDBECAUSE $COMMENT#DIRECTIVE21#FORALIASVARIABLES#AGNOSTICCANCLIENTSERVER
336
338
  makeBlockedImport(
337
339
  USE_CLIENT_CONTEXTS,
338
340
  USE_SERVER_COMPONENTS
339
- ) /* Lineal Server Components may only pass through (Special) Client Contexts Components via the children prop within Server Components Modules. */,
340
- // USE_CLIENT_COMPONENTS allowed, because Lineal Client Components can create client boundaries within (Special) Client Contexts Components.
341
- // USE_AGNOSTIC_COMPONENTS allowed, because Lineal Agnostic Components can render safely on the client just like they can on the server.
342
- // USE_SERVER_FUNCTIONS allowed, because (Special) Server Functions can be specifically triggered by Client Components.
343
- // USE_CLIENT_CONTEXTS allowed, because (Special) Client Contexts Components can compose with one another.
344
- // USE_AGNOSTIC_CONDITIONS allowed, because (Special) Agnostic Conditions Components, as if they were Lineal Agnostic Components themselves, can render safely on the client just like they can on the server, in a mechanism that allows Client Contexts Components to safely and indirectly compose with child Server Components within Client Contexts Modules.
341
+ ) /* $COMMENT#DIRECTIVE21#USE_CLIENT_CONTEXTS#USE_SERVER_COMPONENTS */,
342
+ // USE_CLIENT_COMPONENTS $COMMENT#AGNOSTIC20#FORCOMPOSEDVARIABLES#ALLOWEDBECAUSE $COMMENT#DIRECTIVE21#USE_CLIENT_CONTEXTS#USE_CLIENT_COMPONENTS
343
+ // USE_AGNOSTIC_COMPONENTS $COMMENT#AGNOSTIC20#FORCOMPOSEDVARIABLES#ALLOWEDBECAUSE $COMMENT#DIRECTIVE21#FORALIASVARIABLES#AGNOSTICCOMPONENTSRENDERANY
344
+ // USE_SERVER_FUNCTIONS $COMMENT#AGNOSTIC20#FORCOMPOSEDVARIABLES#ALLOWEDBECAUSE $COMMENT#DIRECTIVE21#FORALIASVARIABLES#SERVERFUNCTIONSCLIENT
345
+ // USE_CLIENT_CONTEXTS $COMMENT#AGNOSTIC20#FORCOMPOSEDVARIABLES#ALLOWEDBECAUSE $COMMENT#DIRECTIVE21#USE_CLIENT_CONTEXTS#USE_CLIENT_CONTEXTS
346
+ // USE_AGNOSTIC_CONDITIONS $COMMENT#AGNOSTIC20#FORCOMPOSEDVARIABLES#ALLOWEDBECAUSE $COMMENT#DIRECTIVE21#USE_CLIENT_CONTEXTS#USE_AGNOSTIC_CONDITIONS
345
347
  ]),
346
348
  [USE_AGNOSTIC_CONDITIONS]: Object.freeze([
347
349
  makeBlockedImport(
348
350
  USE_AGNOSTIC_CONDITIONS,
349
351
  USE_SERVER_LOGICS
350
- ) /* Prime Server Logics cannot run on both the server and the client. */,
352
+ ) /* $COMMENT#DIRECTIVE21#FORALIASVARIABLES#SERVERLOGICSCANTBOTH */,
351
353
  makeBlockedImport(
352
354
  USE_AGNOSTIC_CONDITIONS,
353
355
  USE_CLIENT_LOGICS
354
- ) /* Prime Client Logics cannot run on both the server and the client. */,
355
- // USE_AGNOSTIC_LOGICS allowed, because Prime Agnostic Logics, being environment-agnostic logic, can safely support any Agnostic Components, including (Special) Agnostic Conditions Components. (In this case this is necessary for the import of the `conditionAgnosticComponent` function needed to make Agnostic Conditions Components.)
356
- // USE_SERVER_COMPONENTS allowed, because Lineal Server Components are to be paired as `ComponentForServer` components with `ComponentForClient` components to form (Special) Agnostic Conditions Components.
357
- // USE_CLIENT_COMPONENTS allowed, because Lineal Client Components are to be paired as `ComponentForClient` components with `ComponentForServer` components to form (Special) Agnostic Conditions Components.
358
- // USE_AGNOSTIC_COMPONENTS allowed, because Lineal Agnostic Components can take the place of `ComponentForServer` and/or `ComponentForClient` components to form (Special) Agnostic Conditions Components.
356
+ ) /* $COMMENT#DIRECTIVE21#FORALIASVARIABLES#CLIENTLOGICSCANTBOTH */,
357
+ // USE_AGNOSTIC_LOGICS $COMMENT#AGNOSTIC20#FORCOMPOSEDVARIABLES#ALLOWEDBECAUSE $COMMENT#DIRECTIVE21#USE_AGNOSTIC_CONDITIONS#USE_AGNOSTIC_LOGICS
358
+ // USE_SERVER_COMPONENTS $COMMENT#AGNOSTIC20#FORCOMPOSEDVARIABLES#ALLOWEDBECAUSE $COMMENT#DIRECTIVE21#USE_AGNOSTIC_CONDITIONS#USE_SERVER_COMPONENTS
359
+ // USE_CLIENT_COMPONENTS $COMMENT#AGNOSTIC20#FORCOMPOSEDVARIABLES#ALLOWEDBECAUSE $COMMENT#DIRECTIVE21#USE_AGNOSTIC_CONDITIONS#USE_CLIENT_COMPONENTS
360
+ // USE_AGNOSTIC_COMPONENTS $COMMENT#AGNOSTIC20#FORCOMPOSEDVARIABLES#ALLOWEDBECAUSE $COMMENT#DIRECTIVE21#USE_AGNOSTIC_CONDITIONS#USE_AGNOSTIC_COMPONENTS
359
361
  makeBlockedImport(
360
362
  USE_AGNOSTIC_CONDITIONS,
361
363
  USE_SERVER_FUNCTIONS
362
- ) /* (Special) Server Functions are not accepted because (Special) Agnostic Conditions Components only take finite, imported components as arguments in their making. As such, assigning props to these components, including Server Functions, is not made within Agnostic Conditions Modules. */,
364
+ ) /* $COMMENT#DIRECTIVE21#USE_AGNOSTIC_CONDITIONS#USE_SERVER_FUNCTIONS */,
363
365
  makeBlockedImport(
364
366
  USE_AGNOSTIC_CONDITIONS,
365
367
  USE_CLIENT_CONTEXTS
366
- ) /* (Special) Client Contexts Components cannot be used as component arguments for (Special) Agnostic Conditions Components since they only take Lineal Components as arguments in their making. */,
367
- // USE_AGNOSTIC_CONDITIONS allowed, because (Special) Agnostic Conditions Components, despite not being Lineal Components themselves, output components that can only be Lineal and compatible with their attributed rendering environments, making them acceptable arguments in the making of Agnostic Conditions Components.
368
+ ) /* $COMMENT#DIRECTIVE21#USE_AGNOSTIC_CONDITIONS#USE_CLIENT_CONTEXTS */,
369
+ // USE_AGNOSTIC_CONDITIONS $COMMENT#AGNOSTIC20#FORCOMPOSEDVARIABLES#ALLOWEDBECAUSE $COMMENT#DIRECTIVE21#USE_AGNOSTIC_CONDITIONS#USE_AGNOSTIC_CONDITIONS
368
370
  ]),
369
371
  });
372
+
373
+ /* environments_allowedChainedImportEnvironments */
374
+
375
+ export const SERVER = "server";
376
+ export const CLIENT = "client";
377
+ export const AGNOSTIC = "agnostic";
378
+
379
+ /** @type {readonly [typeof SERVER, typeof AGNOSTIC]} */
380
+ const server_allowedChainImportEnvironments = Object.freeze([SERVER, AGNOSTIC]);
381
+ /** @type {readonly [typeof CLIENT, typeof AGNOSTIC]} */
382
+ const client_allowedChainImportEnvironments = Object.freeze([CLIENT, AGNOSTIC]);
383
+ /** @type {readonly [typeof AGNOSTIC]} */
384
+ const agnostic_allowedChainImportEnvironments = Object.freeze([AGNOSTIC]);
385
+
386
+ export const environments_allowedChainImportEnvironments = Object.freeze({
387
+ [SERVER]: server_allowedChainImportEnvironments,
388
+ [CLIENT]: client_allowedChainImportEnvironments,
389
+ [AGNOSTIC]: agnostic_allowedChainImportEnvironments,
390
+ });
@@ -1,10 +1,11 @@
1
1
  import {
2
2
  reExportNotSameMessageId,
3
3
  importBreaksCommentedImportRulesMessageId,
4
- noCommentedDirective,
5
- commentedDirectiveVerificationFailed,
6
- importNotStrategized,
7
- exportNotStrategized,
4
+ noCommentedDirectiveMessageId,
5
+ commentedDirectiveVerificationFailedMessageId,
6
+ importNotStrategizedMessageId,
7
+ exportNotStrategizedMessageId,
8
+ cantChainImportAcrossEnvironmentsMessageId,
8
9
  } from "../../../_commons/constants/bases.js";
9
10
  import {
10
11
  currentFileCommentedDirective,
@@ -12,6 +13,8 @@ import {
12
13
  commentedDirectiveMessage,
13
14
  specificViolationMessage,
14
15
  specificFailure,
16
+ currentFileEnvironment,
17
+ importedFileEnvironment,
15
18
  } from "../constants/bases.js";
16
19
 
17
20
  import {
@@ -38,14 +41,15 @@ const rule = {
38
41
  Here, "{{ ${currentFileCommentedDirective} }}" and "{{ ${importedFileCommentedDirective} }}" are not the same. Please re-export only from modules that have the same commented directive as the current module. `,
39
42
  [importBreaksCommentedImportRulesMessageId]: `{{ ${commentedDirectiveMessage} }}
40
43
  In this case, {{ ${specificViolationMessage} }} `,
41
- [noCommentedDirective]: `No commented directive detected.
44
+ [noCommentedDirectiveMessageId]: `No commented directive detected.
42
45
  All targeted modules need to be marked with their respective directives (\`// "use server logics"\`, etc.) for the purpose of this linting rule, evaluated from the first JavaScript comment starting on the first column within the first three lines of a module. `,
43
- [commentedDirectiveVerificationFailed]: `The commented directive could not pass verification due to an incompatible combination with its file extension.
46
+ [commentedDirectiveVerificationFailedMessageId]: `The commented directive could not pass verification due to an incompatible combination with its file extension.
44
47
  In this context, {{ ${specificFailure} }} `,
45
- [importNotStrategized]: `Imports from Agnostic Strategies Modules must be strategized (\`/* @serverLogics */\`, etc.).
48
+ [importNotStrategizedMessageId]: `Imports from Agnostic Strategies Modules must be strategized (\`/* @serverLogics */\`, etc.).
46
49
  Please include a Strategy that corresponds to the kind of module this import would be mapped to. `,
47
- [exportNotStrategized]: `Exports from Agnostic Strategies Modules must be strategized (\`/* @serverLogics */\`, etc.).
50
+ [exportNotStrategizedMessageId]: `Exports from Agnostic Strategies Modules must be strategized (\`/* @serverLogics */\`, etc.).
48
51
  Please include a Strategy that corresponds to the kind of module this export would be mapped to. `,
52
+ [cantChainImportAcrossEnvironmentsMessageId]: `Because imports are actually references instead of modules across environments, it is not possible to chain-import between the {{ ${currentFileEnvironment} }} environment and the {{ ${importedFileEnvironment} }} environment. In these cases, only direct imports apply. `,
49
53
  },
50
54
  },
51
55
  create: (context) => {
@@ -0,0 +1,100 @@
1
+ /**
2
+ * @typedef {import("../../../../types/_commons/typedefs.js").SourceCode} SourceCode
3
+ * @typedef {import("../../../../types/_commons/typedefs.js").ImportDeclaration} ImportDeclaration
4
+ * @typedef {import("../../../../types/_commons/typedefs.js").ExportAllDeclaration} ExportAllDeclaration
5
+ * @typedef {import("../../../../types/_commons/typedefs.js").ExportNamedDeclarationWithSource} ExportNamedDeclarationWithSource
6
+ * @typedef {import("../../../../types/_commons/typedefs.js").ExportNamedDeclarationWithoutSourceWithMultiple} ExportNamedDeclarationWithoutSourceWithMultiple
7
+ * @typedef {import("../../../../types/_commons/typedefs.js").ExportNamedDeclarationWithoutSourceWithSingle} ExportNamedDeclarationWithoutSourceWithSingle
8
+ * @typedef {import("../../../../types/_commons/typedefs.js").ExportDefaultDeclaration} ExportDefaultDeclaration
9
+ */
10
+
11
+ import { walkAST } from "../../../_commons/utilities/walk-ast.js";
12
+
13
+ /**
14
+ * Analyzes a source code exports to detect re-exports.
15
+ * @param {SourceCode} sourceCode
16
+ * @returns
17
+ */
18
+ export const analyzeExportsForReExports = (sourceCode) => {
19
+ /** @type {Map<string, {source: string, importNode: ImportDeclaration}>} */
20
+ const importMap = new Map();
21
+
22
+ /** @type {{node: ExportAllDeclaration | ExportNamedDeclarationWithSource, source: string}[]} */
23
+ const reExportsWithSource = [];
24
+
25
+ /** @type {{identifier: string, node: ExportNamedDeclarationWithoutSourceWithMultiple | ExportNamedDeclarationWithoutSourceWithSingle | ExportDefaultDeclaration, importNode: ImportDeclaration, source: string}[]} */
26
+ const reExportsViaLocal = [];
27
+
28
+ walkAST(sourceCode, (node) => {
29
+ if (node.type === "ImportDeclaration") {
30
+ const moduleName = node.source?.value;
31
+ if (moduleName) {
32
+ for (const spec of node.specifiers) {
33
+ importMap.set(spec.local.name, {
34
+ source: moduleName,
35
+ importNode: node,
36
+ });
37
+ }
38
+ }
39
+ }
40
+
41
+ // works
42
+ if (
43
+ node.type === "ExportAllDeclaration" &&
44
+ node.exportKind === "value" &&
45
+ node.source
46
+ ) {
47
+ reExportsWithSource.push({ node, source: node.source.value });
48
+ }
49
+
50
+ // works
51
+ if (
52
+ node.type === "ExportNamedDeclaration" &&
53
+ node.exportKind === "value" &&
54
+ node.source
55
+ ) {
56
+ reExportsWithSource.push({ node, source: node.source.value });
57
+ }
58
+
59
+ // works
60
+ if (
61
+ node.type === "ExportNamedDeclaration" &&
62
+ node.exportKind === "value" &&
63
+ node.source === null &&
64
+ node.specifiers?.length
65
+ ) {
66
+ for (const spec of node.specifiers) {
67
+ const local = spec.local?.name;
68
+ if (importMap.has(local)) {
69
+ const info = importMap.get(local);
70
+ reExportsViaLocal.push({
71
+ identifier: local,
72
+ exportNode: node,
73
+ importNode: info.importNode,
74
+ source: info.source,
75
+ });
76
+ }
77
+ }
78
+ }
79
+
80
+ // works
81
+ if (
82
+ node.type === "ExportDefaultDeclaration" &&
83
+ node.exportKind === "value" &&
84
+ node.declaration.type === "Identifier"
85
+ ) {
86
+ const name = node.declaration.name;
87
+ if (importMap.has(name)) {
88
+ const info = importMap.get(name);
89
+ reExportsViaLocal.push({
90
+ identifier: name,
91
+ exportNode: node,
92
+ importNode: info.importNode,
93
+ source: info.source,
94
+ });
95
+ }
96
+ }
97
+ });
98
+
99
+ return { reExportsWithSource, reExportsViaLocal };
100
+ };