eslint-plugin-use-agnostic 1.2.3 → 1.3.1

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.
@@ -11,7 +11,11 @@ import {
11
11
 
12
12
  import { makeIntroForSpecificViolationMessage } from "../../../_commons/utilities/helpers.js";
13
13
 
14
- import { data as jscommentsConfig } from "../../../../comments.config.js";
14
+ import { resolvedConfigData } from "../../../../jscomments/_commons/constants/bases.js";
15
+
16
+ // const resolvedConfigData = await import("../../../../comments.config.json", {
17
+ // assert: { type: "json" },
18
+ // });
15
19
 
16
20
  /**
17
21
  * @typedef {import('../../../../types/agnostic20/_commons/typedefs.js').Directive} Directive
@@ -89,12 +93,12 @@ const SUGGEST_USE_AGNOSTIC =
89
93
  "If the module you're trying to import does not possess any server-side code however, please mark it with this plugin's own and eponymous 'use agnostic' directive to signal its compatibility across all environments.";
90
94
 
91
95
  /**
92
- * Makes a blockedImport object for the identified blocked import at hand.
96
+ * $COMMENT#JSDOC#DEFINITIONS#AGNOSTIC20#MAKEBLOCKEDIMPORT
93
97
  * @template {EffectiveDirective} T
94
98
  * @template {EffectiveDirective} U
95
- * @param {T} currentFileEffectiveDirective The current file's effective directive.
96
- * @param {U} importedFileEffectiveDirective The imported file's effective directive.
97
- * @returns The blockedImport object for the identified blocked import at hand.
99
+ * @param {T} currentFileEffectiveDirective $COMMENT#JSDOC#PARAMS#AGNOSTIC20#CURRENTFILEEFFECTIVEDIRECTIVE
100
+ * @param {U} importedFileEffectiveDirective $COMMENT#JSDOC#PARAMS#AGNOSTIC20#IMPORTEDFILEEFFECTIVEDIRECTIVE
101
+ * @returns $COMMENT#JSDOC#RETURNS#AGNOSTIC20#MAKEBLOCKEDIMPORT
98
102
  */
99
103
  export const makeBlockedImport = (
100
104
  currentFileEffectiveDirective,
@@ -106,7 +110,7 @@ export const makeBlockedImport = (
106
110
  currentFileEffectiveDirective,
107
111
  importedFileEffectiveDirective
108
112
  )} ${
109
- jscommentsConfig[agnostic20ConfigName][currentFileEffectiveDirective][
113
+ resolvedConfigData[agnostic20ConfigName][currentFileEffectiveDirective][
110
114
  importedFileEffectiveDirective
111
115
  ]
112
116
  }`,
@@ -114,12 +118,12 @@ export const makeBlockedImport = (
114
118
  };
115
119
 
116
120
  /**
117
- * Makes a blockedImport object for the identified blocked import at hand enhanced with the suggestion to use the `'use agnostic'` directive.
121
+ * $COMMENT#JSDOC#DEFINITIONS#AGNOSTIC20#MAKEBLOCKEDIMPORTSUGGESTINGUSEAGNOSTIC
118
122
  * @template {EffectiveDirective} T
119
123
  * @template {EffectiveDirective} U
120
- * @param {T} currentFileEffectiveDirective The current file's effective directive.
121
- * @param {U} importedFileEffectiveDirective The imported file's effective directive.
122
- * @returns The enhanced blockedImport object with the suggestion to use the `'use agnostic'` directive.
124
+ * @param {T} currentFileEffectiveDirective $COMMENT#JSDOC#PARAMS#AGNOSTIC20#CURRENTFILEEFFECTIVEDIRECTIVE
125
+ * @param {U} importedFileEffectiveDirective $COMMENT#JSDOC#PARAMS#AGNOSTIC20#IMPORTEDFILEEFFECTIVEDIRECTIVE
126
+ * @returns $COMMENT#JSDOC#RETURNS#AGNOSTIC20#MAKEBLOCKEDIMPORTSUGGESTINGUSEAGNOSTIC
123
127
  */
124
128
  const makeBlockedImportSuggestingUseAgnostic = (
125
129
  currentFileEffectiveDirective,
@@ -138,125 +142,130 @@ const makeBlockedImportSuggestingUseAgnostic = (
138
142
  });
139
143
  };
140
144
 
145
+ // The final boss is going to be to building this from the config.
146
+ // Probably in the blocked import thing.
147
+ // But so that means I'm going to need using resolveConfig, or maybe I could give resolveConfig an option that allows it to return the actual config data with all values recursively resolved.
148
+ // That's what I would do, then I would just need to use the object of the config data instead of `jscommentsConfig[agnostic20ConfigName]` for makeBlockedImport.
149
+ // const jscommentsConfigData = makeResolvedConfig(configPath)
141
150
  export const effectiveDirectives_blockedImports = Object.freeze({
142
151
  [USE_SERVER_LOGICS]: Object.freeze([
143
- // USE_SERVER_LOGICS allowed, because Server Logics can compose with one another.
144
- // USE_SERVER_COMPONENTS allowed, because Server Components are OK to be composed with Server Logics as long as the Server Logics Module, by convention, does not export React components.
145
- // USE_SERVER_FUNCTIONS allowed, because Server Functions, being able to import one another, can compose and do so via 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.)
152
+ // USE_SERVER_LOGICS $COMMENT#AGNOSTIC20#FORCOMPOSEDVARIABLES#ALLOWEDBECAUSE $COMMENT#AGNOSTIC20#USE_SERVER_LOGICS#USE_SERVER_LOGICS
153
+ // USE_SERVER_COMPONENTS $COMMENT#AGNOSTIC20#FORCOMPOSEDVARIABLES#ALLOWEDBECAUSE $COMMENT#AGNOSTIC20#USE_SERVER_LOGICS#USE_SERVER_COMPONENTS
154
+ // USE_SERVER_FUNCTIONS $COMMENT#AGNOSTIC20#FORCOMPOSEDVARIABLES#ALLOWEDBECAUSE $COMMENT#AGNOSTIC20#USE_SERVER_LOGICS#USE_SERVER_FUNCTIONS
146
155
  makeBlockedImport(
147
156
  USE_SERVER_LOGICS,
148
157
  USE_CLIENT_LOGICS
149
- ) /* Client Logics should never leak to the server, such as would be the case here in a Server Logics Module. */,
158
+ ) /* $COMMENT#AGNOSTIC20#FORALIASVARIABLES#CLIENTNEVERSERVER */,
150
159
  makeBlockedImport(
151
160
  USE_SERVER_LOGICS,
152
161
  USE_CLIENT_COMPONENTS
153
- ) /* Client Components cannot be tinkered with on the server. */,
154
- // USE_AGNOSTIC_LOGICS allowed, because Agnostic Logics can run safely on the server just like they can on the client, such as is the case here in a Server Logics Module.
155
- // USE_AGNOSTIC_COMPONENTS allowed, because Agnostic Components can be composed with Logics on the server just like they can on the client, as long at the Server Logics Module, by convention, does not export React components.
162
+ ) /* $COMMENT#AGNOSTIC20#USE_SERVER_LOGICS#USE_CLIENT_COMPONENTS */,
163
+ // USE_AGNOSTIC_LOGICS $COMMENT#AGNOSTIC20#FORCOMPOSEDVARIABLES#ALLOWEDBECAUSE $COMMENT#AGNOSTIC20#FORALIASVARIABLES#AGNOSTICCANSERVERCLIENT
164
+ // USE_AGNOSTIC_COMPONENTS $COMMENT#AGNOSTIC20#FORCOMPOSEDVARIABLES#ALLOWEDBECAUSE $COMMENT#AGNOSTIC20#USE_SERVER_LOGICS#USE_AGNOSTIC_COMPONENTS
156
165
  ]),
157
166
  [USE_SERVER_COMPONENTS]: Object.freeze([
158
- // USE_SERVER_LOGICS allowed, because Server Logics, being logic from the server, can safely support Server Components.
159
- // USE_SERVER_COMPONENTS allowed, because Server Components can compose with one another, assuming thanks to the inclusion of the 'use agnostic' directive that they are actual Server Components.
160
- // USE_SERVER_FUNCTIONS allowed, because Server Functions can be passed to imported Client Components within Server Components Modules, even though indeed Server Components Modules and Server Components can make their own Server Functions through inline 'use server' directives.
167
+ // USE_SERVER_LOGICS $COMMENT#AGNOSTIC20#FORCOMPOSEDVARIABLES#ALLOWEDBECAUSE $COMMENT#AGNOSTIC20#USE_SERVER_COMPONENTS#USE_SERVER_LOGICS
168
+ // USE_SERVER_COMPONENTS $COMMENT#AGNOSTIC20#FORCOMPOSEDVARIABLES#ALLOWEDBECAUSE $COMMENT#AGNOSTIC20#USE_SERVER_COMPONENTS#USE_SERVER_COMPONENTS
169
+ // USE_SERVER_FUNCTIONS $COMMENT#AGNOSTIC20#FORCOMPOSEDVARIABLES#ALLOWEDBECAUSE $COMMENT#AGNOSTIC20#USE_SERVER_COMPONENTS#USE_SERVER_FUNCTIONS
161
170
  makeBlockedImport(
162
171
  USE_SERVER_COMPONENTS,
163
172
  USE_CLIENT_LOGICS
164
- ) /* Client Logics should never leak to the server, such as would be the case here in a Server Components Module. */,
165
- // USE_CLIENT_COMPONENTS allowed, because Client Components can be nested inside Server Components either to wrap some of the tree with client state accessible through child Client Components and pass through Server Components, or to create client boundaries when the root of the application is planted on the server.
166
- // USE_AGNOSTIC_LOGICS allowed, because Agnostic Logics can run safely on the server just like they can on the client, such as is the case here in a Server Components Module.
167
- // USE_AGNOSTIC_COMPONENTS allowed, because Agnostic Components can render safely on the server just like they can on the client.
173
+ ) /* $COMMENT#AGNOSTIC20#FORALIASVARIABLES#CLIENTNEVERSERVER */,
174
+ // USE_CLIENT_COMPONENTS $COMMENT#AGNOSTIC20#FORCOMPOSEDVARIABLES#ALLOWEDBECAUSE $COMMENT#AGNOSTIC20#USE_SERVER_COMPONENTS#USE_CLIENT_COMPONENTS
175
+ // USE_AGNOSTIC_LOGICS $COMMENT#AGNOSTIC20#FORCOMPOSEDVARIABLES#ALLOWEDBECAUSE $COMMENT#AGNOSTIC20#FORALIASVARIABLES#AGNOSTICCANSERVERCLIENT
176
+ // USE_AGNOSTIC_COMPONENTS $COMMENT#AGNOSTIC20#FORCOMPOSEDVARIABLES#ALLOWEDBECAUSE $COMMENT#AGNOSTIC20#USE_SERVER_COMPONENTS#USE_AGNOSTIC_COMPONENTS
168
177
  ]),
169
178
  [USE_SERVER_FUNCTIONS]: Object.freeze([
170
- // USE_SERVER_LOGICS allowed, because Server Logics, being logic from the server, can safely support Server Functions.
179
+ // USE_SERVER_LOGICS $COMMENT#AGNOSTIC20#FORCOMPOSEDVARIABLES#ALLOWEDBECAUSE $COMMENT#AGNOSTIC20#USE_SERVER_FUNCTIONS#USE_SERVER_LOGICS
171
180
  makeBlockedImport(
172
181
  USE_SERVER_FUNCTIONS,
173
182
  USE_SERVER_COMPONENTS
174
- ) /* Server Components aren't allowed because Server Functions have no business working with React Components. */,
175
- // USE_SERVER_FUNCTIONS allowed, because Server Functions, even though they don't need to import one another and the same results can be generated via 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.)
183
+ ) /* $COMMENT#AGNOSTIC20#USE_SERVER_FUNCTIONS#USE_SERVER_COMPONENTS */,
184
+ // USE_SERVER_FUNCTIONS $COMMENT#AGNOSTIC20#FORCOMPOSEDVARIABLES#ALLOWEDBECAUSE $COMMENT#AGNOSTIC20#USE_SERVER_FUNCTIONS#USE_SERVER_FUNCTIONS
176
185
  makeBlockedImport(
177
186
  USE_SERVER_FUNCTIONS,
178
187
  USE_CLIENT_LOGICS
179
- ) /* Client Logics should never leak to the server, such as would be the case here in a Server Functions Module. */,
188
+ ) /* $COMMENT#AGNOSTIC20#FORALIASVARIABLES#CLIENTNEVERSERVER */,
180
189
  makeBlockedImport(
181
190
  USE_SERVER_FUNCTIONS,
182
191
  USE_CLIENT_COMPONENTS
183
- ) /* Client Components aren't allowed because Server Functions have no business working with React Components. */,
184
- // USE_AGNOSTIC_LOGICS allowed, because Agnostic Logics can run safely on the server just like they can on the client, such as is the case here in a Server Functions Module.
192
+ ) /* $COMMENT#AGNOSTIC20#USE_SERVER_FUNCTIONS#USE_CLIENT_COMPONENTS */,
193
+ // USE_AGNOSTIC_LOGICS $COMMENT#AGNOSTIC20#FORCOMPOSEDVARIABLES#ALLOWEDBECAUSE $COMMENT#AGNOSTIC20#FORALIASVARIABLES#AGNOSTICCANSERVERCLIENT
185
194
  makeBlockedImport(
186
195
  USE_SERVER_FUNCTIONS,
187
196
  USE_AGNOSTIC_COMPONENTS
188
- ) /* Agnostic Components aren't allowed because Server Functions have no business working with React Components. */,
197
+ ) /* $COMMENT#AGNOSTIC20#USE_SERVER_FUNCTIONS#USE_AGNOSTIC_COMPONENTS */,
189
198
  ]),
190
199
  [USE_CLIENT_LOGICS]: Object.freeze([
191
200
  makeBlockedImportSuggestingUseAgnostic(
192
201
  USE_CLIENT_LOGICS,
193
202
  USE_SERVER_LOGICS
194
- ) /* Server Logics should never leak to the client, such as would be the case here in a Client Logics Module. */,
203
+ ) /* $COMMENT#AGNOSTIC20#FORALIASVARIABLES#SERVERNEVERCLIENT */,
195
204
  makeBlockedImportSuggestingUseAgnostic(
196
205
  USE_CLIENT_LOGICS,
197
206
  USE_SERVER_COMPONENTS
198
- ) /* Server Components cannot be thinkered with on the client. */,
199
- // USE_SERVER_FUNCTIONS allowed, because Server Functions can technically be attached to Client Components that are being tinkered with within Client Logics Modules.
200
- // USE_CLIENT_LOGICS allowed, because Client Logics can compose with one another.
201
- // USE_CLIENT_COMPONENTS allowed, because Client Components are OK to be composed with Client Logics as long as the Client Logics Module, by convention, does not export React components.
202
- // USE_AGNOSTIC_LOGICS allowed, because Agnostic Logics can run safely on the client just like they can on the server, such as is the case here in a Client Logics Module.
203
- // USE_AGNOSTIC_COMPONENTS allowed, because Agnostic Components can be composed with Logics on the client just like they can on the server, as long as the Client Logics Module, by convention, does not export React components.
207
+ ) /* $COMMENT#AGNOSTIC20#USE_CLIENT_LOGICS#USE_SERVER_COMPONENTS */,
208
+ // USE_SERVER_FUNCTIONS $COMMENT#AGNOSTIC20#FORCOMPOSEDVARIABLES#ALLOWEDBECAUSE $COMMENT#AGNOSTIC20#USE_CLIENT_LOGICS#USE_SERVER_FUNCTIONS
209
+ // USE_CLIENT_LOGICS $COMMENT#AGNOSTIC20#FORCOMPOSEDVARIABLES#ALLOWEDBECAUSE $COMMENT#AGNOSTIC20#USE_CLIENT_LOGICS#USE_CLIENT_LOGICS
210
+ // USE_CLIENT_COMPONENTS $COMMENT#AGNOSTIC20#FORCOMPOSEDVARIABLES#ALLOWEDBECAUSE $COMMENT#AGNOSTIC20#USE_CLIENT_LOGICS#USE_CLIENT_COMPONENTS
211
+ // USE_AGNOSTIC_LOGICS $COMMENT#AGNOSTIC20#FORCOMPOSEDVARIABLES#ALLOWEDBECAUSE $COMMENT#AGNOSTIC20#FORALIASVARIABLES#AGNOSTICCANCLIENTSERVER
212
+ // USE_AGNOSTIC_COMPONENTS $COMMENT#AGNOSTIC20#FORCOMPOSEDVARIABLES#ALLOWEDBECAUSE $COMMENT#AGNOSTIC20#USE_CLIENT_LOGICS#USE_AGNOSTIC_COMPONENTS
204
213
  ]),
205
214
  [USE_CLIENT_COMPONENTS]: Object.freeze([
206
215
  makeBlockedImportSuggestingUseAgnostic(
207
216
  USE_CLIENT_LOGICS,
208
217
  USE_SERVER_LOGICS
209
- ) /* Server Logics should never leak to the client, such as would be the case here in a Client Logics Module. */,
218
+ ) /* $COMMENT#AGNOSTIC20#FORALIASVARIABLES#SERVERNEVERCLIENT */,
210
219
  makeBlockedImportSuggestingUseAgnostic(
211
220
  USE_CLIENT_LOGICS,
212
221
  USE_SERVER_COMPONENTS
213
- ) /* Server Components cannot be thinkered with on the client. */,
214
- // USE_SERVER_FUNCTIONS allowed, because Server Functions are specifically triggered by Client Components.
215
- // USE_CLIENT_LOGICS allowed, because Client Logics, being logic from the client, can safely support Client Components.
216
- // USE_CLIENT_COMPONENTS allowed, because Client Components can compose with one another.
217
- // USE_AGNOSTIC_LOGICS allowed, because Agnostic Logics can run safely on the client just like they can on the server, such as is the case here in a Client Components Module.
218
- // USE_AGNOSTIC_COMPONENTS allowed, because Agnostic Components can render safely on the client just like they can on the server.
222
+ ) /* $COMMENT#AGNOSTIC20#USE_CLIENT_LOGICS#USE_SERVER_COMPONENTS */,
223
+ // USE_SERVER_FUNCTIONS $COMMENT#AGNOSTIC20#FORCOMPOSEDVARIABLES#ALLOWEDBECAUSE $COMMENT#AGNOSTIC20#USE_CLIENT_COMPONENTS#USE_SERVER_FUNCTIONS
224
+ // USE_CLIENT_LOGICS $COMMENT#AGNOSTIC20#FORCOMPOSEDVARIABLES#ALLOWEDBECAUSE $COMMENT#AGNOSTIC20#USE_CLIENT_COMPONENTS#USE_CLIENT_LOGICS
225
+ // USE_CLIENT_COMPONENTS $COMMENT#AGNOSTIC20#FORCOMPOSEDVARIABLES#ALLOWEDBECAUSE $COMMENT#AGNOSTIC20#USE_CLIENT_COMPONENTS#USE_CLIENT_COMPONENTS
226
+ // USE_AGNOSTIC_LOGICS $COMMENT#AGNOSTIC20#FORCOMPOSEDVARIABLES#ALLOWEDBECAUSE $COMMENT#AGNOSTIC20#FORALIASVARIABLES#AGNOSTICCANCLIENTSERVER
227
+ // USE_AGNOSTIC_COMPONENTS $COMMENT#AGNOSTIC20#FORCOMPOSEDVARIABLES#ALLOWEDBECAUSE $COMMENT#AGNOSTIC20#USE_CLIENT_COMPONENTS#USE_AGNOSTIC_COMPONENTS
219
228
  ]),
220
229
  [USE_AGNOSTIC_LOGICS]: Object.freeze([
221
230
  makeBlockedImportSuggestingUseAgnostic(
222
231
  USE_AGNOSTIC_LOGICS,
223
232
  USE_SERVER_LOGICS
224
- ) /* Server Logics cannot run on both the server and the client, such as would be the case here in an Agnostic Logics Module. */,
233
+ ) /* $COMMENT#AGNOSTIC20#FORALIASVARIABLES#SERVERLOGICSCANTBOTH */,
225
234
  makeBlockedImportSuggestingUseAgnostic(
226
235
  USE_AGNOSTIC_LOGICS,
227
236
  USE_SERVER_COMPONENTS
228
- ) /* Server Components cannot be tinkered with on both the server and the client. */,
237
+ ) /* $COMMENT#AGNOSTIC20#USE_AGNOSTIC_LOGICS#USE_SERVER_COMPONENTS */,
229
238
  makeBlockedImport(
230
239
  USE_AGNOSTIC_LOGICS,
231
240
  USE_SERVER_FUNCTIONS
232
- ) /* 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. */,
241
+ ) /* $COMMENT#AGNOSTIC20#USE_AGNOSTIC_LOGICS#USE_SERVER_FUNCTIONS */,
233
242
  makeBlockedImport(
234
243
  USE_AGNOSTIC_LOGICS,
235
244
  USE_CLIENT_LOGICS
236
- ) /* Client Logics cannot run on both the server and the client, such as would be the case here in an Agnostic Logics Module. */,
245
+ ) /* $COMMENT#AGNOSTIC20#FORALIASVARIABLES#CLIENTLOGICSCANTBOTH */,
237
246
  makeBlockedImport(
238
247
  USE_AGNOSTIC_LOGICS,
239
248
  USE_CLIENT_COMPONENTS
240
- ) /* Client Components cannot be tinkered with on both the server and the client. */,
241
- // USE_AGNOSTIC_LOGICS allowed, because Agnostic Logics can compose with one another.
242
- // USE_AGNOSTIC_COMPONENTS allowed, because Agnostic Components can be composed with Logics agnostically as long as the Agnostic Logics Module, by convention, does not export React components.
249
+ ) /* $COMMENT#AGNOSTIC20#USE_AGNOSTIC_LOGICS#USE_CLIENT_COMPONENTS */,
250
+ // USE_AGNOSTIC_LOGICS $COMMENT#AGNOSTIC20#FORCOMPOSEDVARIABLES#ALLOWEDBECAUSE $COMMENT#AGNOSTIC20#USE_AGNOSTIC_LOGICS#USE_AGNOSTIC_LOGICS
251
+ // USE_AGNOSTIC_COMPONENTS $COMMENT#AGNOSTIC20#FORCOMPOSEDVARIABLES#ALLOWEDBECAUSE $COMMENT#AGNOSTIC20#USE_AGNOSTIC_LOGICS#USE_AGNOSTIC_COMPONENTS
243
252
  ]),
244
253
  [USE_AGNOSTIC_COMPONENTS]: Object.freeze([
245
254
  makeBlockedImportSuggestingUseAgnostic(
246
255
  USE_AGNOSTIC_COMPONENTS,
247
256
  USE_SERVER_LOGICS
248
- ) /* Server Logics cannot run on both the server and the client, such as would be the case here in an Agnostic Components Module. */,
257
+ ) /* $COMMENT#AGNOSTIC20#FORALIASVARIABLES#SERVERLOGICSCANTBOTH */,
249
258
  makeBlockedImportSuggestingUseAgnostic(
250
259
  USE_AGNOSTIC_COMPONENTS,
251
260
  USE_SERVER_COMPONENTS
252
- ) /* Server Components, unlike 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. */,
253
- // USE_SERVER_FUNCTIONS allowed, because Server Functions can be passed to Client Components as props when Client Components are also legally imported into Agnostic Components Modules.
261
+ ) /* $COMMENT#AGNOSTIC20#USE_AGNOSTIC_COMPONENTS#USE_SERVER_COMPONENTS */,
262
+ // USE_SERVER_FUNCTIONS $COMMENT#AGNOSTIC20#FORCOMPOSEDVARIABLES#ALLOWEDBECAUSE $COMMENT#AGNOSTIC20#USE_AGNOSTIC_COMPONENTS#USE_SERVER_FUNCTIONS
254
263
  makeBlockedImport(
255
264
  USE_AGNOSTIC_COMPONENTS,
256
265
  USE_CLIENT_LOGICS
257
- ) /* Client Logics cannot run on both the server and the client, such as would be the case here in an Agnostic Components Module. */,
258
- // USE_CLIENT_COMPONENTS allowed, because Client Components can be nested inside Agnostic Components either to wrap some of the tree with client state accessible through child Client Components and pass through Server Components (if still on the Server Tree), or to create client boundaries when the root of the application is planted on the server.
259
- // USE_AGNOSTIC_LOGICS allowed, because Agnostic Logics, being environment-agnostic logic, can safely support Agnostic Components.
260
- // USE_AGNOSTIC_COMPONENTS allowed, because Agnostic Components can compose with one another.
266
+ ) /* $COMMENT#AGNOSTIC20#FORALIASVARIABLES#CLIENTLOGICSCANTBOTH */,
267
+ // USE_CLIENT_COMPONENTS $COMMENT#AGNOSTIC20#FORCOMPOSEDVARIABLES#ALLOWEDBECAUSE $COMMENT#AGNOSTIC20#USE_AGNOSTIC_COMPONENTS#USE_CLIENT_COMPONENTS
268
+ // USE_AGNOSTIC_LOGICS $COMMENT#AGNOSTIC20#FORCOMPOSEDVARIABLES#ALLOWEDBECAUSE $COMMENT#AGNOSTIC20#USE_AGNOSTIC_COMPONENTS#USE_AGNOSTIC_LOGICS
269
+ // USE_AGNOSTIC_COMPONENTS $COMMENT#AGNOSTIC20#FORCOMPOSEDVARIABLES#ALLOWEDBECAUSE $COMMENT#AGNOSTIC20#USE_AGNOSTIC_COMPONENTS#USE_AGNOSTIC_COMPONENTS
261
270
  ]),
262
271
  });
@@ -39,9 +39,9 @@ import {
39
39
  /* currentFileFlow */
40
40
 
41
41
  /**
42
- * The flow that begins the import rules enforcement rule, retrieving the effective directive of the current file before comparing it to upcoming effective directives of the files it imports.
43
- * @param {Context} context The ESLint rule's `context` object.
44
- * @returns Either an object with `skip: true` to disregard or one with the non-null `currentFileEffectiveDirective`.
42
+ * $COMMENT#JSDOC#DEFINITIONS#AGNOSTIC20#CURRENTFILEFLOW
43
+ * @param {Context} context $COMMENT#JSDOC#PARAMS#CONTEXTB
44
+ * @returns $COMMENT#JSDOC#RETURNS#AGNOSTIC20#CURRENTFILEFLOW
45
45
  */
46
46
  export const currentFileFlow = (context) => {
47
47
  const skipTrue = { ...skip, currentFileEffectiveDirective: undefined };
@@ -94,10 +94,10 @@ export const currentFileFlow = (context) => {
94
94
  /* importedFileFlow */
95
95
 
96
96
  /**
97
- * The flow that is shared between import and re-export traversals to obtain the import file's effective directive.
98
- * @param {Context} context The ESLint rule's `context` object.
99
- * @param {ImportDeclaration} node The ESLint `node` of the rule's current traversal.
100
- * @returns Either an object with `skip: true` to disregard or one with the non-null `importedFileEffectiveDirective`.
97
+ * $COMMENT#JSDOC#DEFINITIONS#AGNOSTIC20#IMPORTEDFILEFLOW
98
+ * @param {Context} context $COMMENT#JSDOC#PARAMS#CONTEXTB
99
+ * @param {ImportDeclaration} node $COMMENT#JSDOC#PARAMS#NODE
100
+ * @returns $COMMENT#JSDOC#RETURNS#AGNOSTIC20#IMPORTEDFILEFLOW
101
101
  */
102
102
  const importedFileFlow = (context, node) => {
103
103
  const skipTrue = { ...skip, importedFileEffectiveDirective: undefined };
@@ -143,11 +143,11 @@ const importedFileFlow = (context, node) => {
143
143
 
144
144
  /* importsFlow */
145
145
 
146
- /** The full flow for import traversals to enforce effective directives import rules.
147
- * @param {Context} context The ESLint rule's `context` object.
148
- * @param {ImportDeclaration} node The ESLint `node` of the rule's current traversal.
149
- * @param {EffectiveDirective} currentFileEffectiveDirective The current file's effective directive.
150
- * @returns Early if the flow needs to be interrupted.
146
+ /** $COMMENT#JSDOC#DEFINITIONS#AGNOSTIC20#IMPORTSFLOW
147
+ * @param {Context} context $COMMENT#JSDOC#PARAMS#CONTEXTB
148
+ * @param {ImportDeclaration} node $COMMENT#JSDOC#PARAMS#NODE
149
+ * @param {EffectiveDirective} currentFileEffectiveDirective $COMMENT#JSDOC#PARAMS#AGNOSTIC20#CURRENTFILEEFFECTIVEDIRECTIVE
150
+ * @returns $COMMENT#JSDOC#RETURNS#AGNOSTIC20#IMPORTSFLOW
151
151
  */
152
152
  export const importsFlow = (context, node, currentFileEffectiveDirective) => {
153
153
  // does not operate on `import type`
@@ -183,11 +183,11 @@ export const importsFlow = (context, node, currentFileEffectiveDirective) => {
183
183
 
184
184
  /* reExportsFlow */
185
185
 
186
- /** The full flow for export traversals, shared between `ExportNamedDeclaration` and `ExportAllDeclaration`, to ensure same effective directive re-exports.
187
- * @param {Context} context The ESLint rule's `context` object.
188
- * @param {ExportNamedDeclaration | ExportAllDeclaration} node The ESLint `node` of the rule's current traversal.
189
- * @param {EffectiveDirective} currentFileEffectiveDirective The current file's effective directive.
190
- * @returns Early if the flow needs to be interrupted.
186
+ /** $COMMENT#JSDOC#DEFINITIONS#AGNOSTIC20#REEXPORTSFLOW
187
+ * @param {Context} context $COMMENT#JSDOC#PARAMS#CONTEXTB
188
+ * @param {ExportNamedDeclaration | ExportAllDeclaration} node $COMMENT#JSDOC#PARAMS#NODE
189
+ * @param {EffectiveDirective} currentFileEffectiveDirective $COMMENT#JSDOC#PARAMS#AGNOSTIC20#CURRENTFILEEFFECTIVEDIRECTIVE
190
+ * @returns $COMMENT#JSDOC#RETURNS#AGNOSTIC20#IMPORTSFLOW
191
191
  */
192
192
  export const reExportsFlow = (context, node, currentFileEffectiveDirective) => {
193
193
  // does not operate on `export type`
@@ -28,13 +28,13 @@ import {
28
28
  /* getDirectiveFromModule */
29
29
 
30
30
  /**
31
- * Gets the directive of a module from its Abstract Syntax Tree.
32
- * - `null` denotes a server-by-default module, ideally a Server Module.
33
- * - `'use server'` denotes a Server Functions Module.
34
- * - `'use client'` denotes a Client Module.
35
- * - `'use agnostic'` denotes an Agnostic Module (formerly Shared Module).
36
- * @param {AST} ast The module's AST (Abstract Syntax Tree).
37
- * @returns The directive, or lack thereof via `null`. The lack of a directive is considered server-by-default.
31
+ * $COMMENT#JSDOC#DEFINITIONS#AGNOSTIC20#GETDIRECTIVEFROMMODULE
32
+ * - $COMMENT#JSDOC#DETAILS#AGNOSTIC20#NULLDIRECTIVE
33
+ * - $COMMENT#JSDOC#DETAILS#AGNOSTIC20#USESERVER
34
+ * - $COMMENT#JSDOC#DETAILS#AGNOSTIC20#USECLIENT
35
+ * - $COMMENT#JSDOC#DETAILS#AGNOSTIC20#USEAGNOSTIC
36
+ * @param {AST} ast $COMMENT#JSDOC#PARAMS#AGNOSTIC20#AST
37
+ * @returns $COMMENT#JSDOC#RETURNS#AGNOSTIC20#GETDIRECTIVEFROMMODULE
38
38
  */
39
39
  export const getDirectiveFromModule = (ast) => {
40
40
  // the AST body to check for the top-of-the-file directive
@@ -63,13 +63,13 @@ export const getDirectiveFromModule = (ast) => {
63
63
  /* getDirectiveFromCurrentModule */
64
64
 
65
65
  /**
66
- * Gets the directive of the current module.
67
- * - `null` denotes a server-by-default module, ideally a Server Module.
68
- * - `'use server'` denotes a Server Functions Module.
69
- * - `'use client'` denotes a Client Module.
70
- * - `'use agnostic'` denotes an Agnostic Module (formerly Shared Module).
71
- * @param {Context} context The ESLint rule's `context` object.
72
- * @returns The directive, or lack thereof via `null`. The lack of a directive is considered server-by-default.
66
+ * $COMMENT#JSDOC#DEFINITIONS#AGNOSTIC20#GETDIRECTIVEFROMCURRENTMODULE
67
+ * - $COMMENT#JSDOC#DETAILS#AGNOSTIC20#NULLDIRECTIVE
68
+ * - $COMMENT#JSDOC#DETAILS#AGNOSTIC20#USESERVER
69
+ * - $COMMENT#JSDOC#DETAILS#AGNOSTIC20#USECLIENT
70
+ * - $COMMENT#JSDOC#DETAILS#AGNOSTIC20#USEAGNOSTIC
71
+ * @param {Context} context $COMMENT#JSDOC#PARAMS#CONTEXTB
72
+ * @returns $COMMENT#JSDOC#RETURNS#AGNOSTIC20#GETDIRECTIVEFROMMODULE
73
73
  */
74
74
  export const getDirectiveFromCurrentModule = (context) => {
75
75
  // the AST of the current module
@@ -81,13 +81,13 @@ export const getDirectiveFromCurrentModule = (context) => {
81
81
  /* getDirectiveFromImportedModule */
82
82
 
83
83
  /**
84
- * Gets the directive of the imported module.
85
- * - `null` denotes a server-by-default module, ideally a Server Module.
86
- * - `'use server'` denotes a Server Functions Module.
87
- * - `'use client'` denotes a Client Module.
88
- * - `'use agnostic'` denotes an Agnostic Module (formerly Shared Module).
89
- * @param {string} resolvedPath The resolved path of the imported module.
90
- * @returns The directive, or lack thereof via `null`. The lack of a directive is considered server-by-default.
84
+ * $COMMENT#JSDOC#DEFINITIONS#AGNOSTIC20#GETDIRECTIVEFROMIMPORTEDMODULE
85
+ * - $COMMENT#JSDOC#DETAILS#AGNOSTIC20#NULLDIRECTIVE
86
+ * - $COMMENT#JSDOC#DETAILS#AGNOSTIC20#USESERVER
87
+ * - $COMMENT#JSDOC#DETAILS#AGNOSTIC20#USECLIENT
88
+ * - $COMMENT#JSDOC#DETAILS#AGNOSTIC20#USEAGNOSTIC
89
+ * @param {string} resolvedPath $COMMENT#JSDOC#PARAMS#RESOLVEDPATH
90
+ * @returns $COMMENT#JSDOC#RETURNS#AGNOSTIC20#GETDIRECTIVEFROMMODULE
91
91
  */
92
92
  export const getDirectiveFromImportedModule = (resolvedPath) => {
93
93
  // the AST of the imported module
@@ -99,17 +99,17 @@ export const getDirectiveFromImportedModule = (resolvedPath) => {
99
99
  /* getEffectiveDirective */
100
100
 
101
101
  /**
102
- * Gets the effective directive of a module, based on the combination of its directive (or lack thereof) and its extension (depending on whether it ends with 'x' for JSX).
103
- * - `'use server logics'` denotes a Server Logics Module.
104
- * - `'use server components'` denotes a Server Components Module.
105
- * - `'use server functions'` denotes a Server Functions Module.
106
- * - `'use client logics'` denotes a Client Logics Module.
107
- * - `'use client components'` denotes a Client Components Module.
108
- * - `'use agnostic logics'` denotes an Agnostic Logics Module.
109
- * - `'use agnostic components'` denotes an Agnostic Components Module.
110
- * @param {Directive | NoDirective} directive The directive as written on top of the file (`"no directive"` if no valid directive).
111
- * @param {Extension} extension The JavaScript (TypeScript) extension of the file.
112
- * @returns The effective directive, from which imports rules are applied.
102
+ * $COMMENT#JSDOC#DEFINITIONS#AGNOSTIC20#GETEFFECTIVEDIRECTIVE
103
+ * - $COMMENT#JSDOC#DETAILS#AGNOSTIC20#USESERVERLOGICS
104
+ * - $COMMENT#JSDOC#DETAILS#AGNOSTIC20#USESERVERCOMPONENTS
105
+ * - $COMMENT#JSDOC#DETAILS#AGNOSTIC20#USESERVERFUNCTIONS
106
+ * - $COMMENT#JSDOC#DETAILS#AGNOSTIC20#USECLIENTLOGICS
107
+ * - $COMMENT#JSDOC#DETAILS#AGNOSTIC20#USECLIENTCOMPONENTS
108
+ * - $COMMENT#JSDOC#DETAILS#AGNOSTIC20#USEAGNOSTICLOGICS
109
+ * - $COMMENT#JSDOC#DETAILS#AGNOSTIC20#USEAGNOSTICCOMPONENTS
110
+ * @param {Directive | NoDirective} directive $COMMENT#JSDOC#PARAMS#AGNOSTIC20#DIRECTIVE
111
+ * @param {Extension} extension $COMMENT#JSDOC#PARAMS#EXTENSION
112
+ * @returns $COMMENT#JSDOC#RETURNS#AGNOSTIC20#GETEFFECTIVEDIRECTIVE
113
113
  */
114
114
  export const getEffectiveDirective = (directive, extension) => {
115
115
  const moduleKind = extension.endsWith("x")
@@ -124,10 +124,10 @@ export const getEffectiveDirective = (directive, extension) => {
124
124
  /* isImportBlocked */
125
125
 
126
126
  /**
127
- * Returns a boolean deciding if an imported file's effective directive is incompatible with the current file's effective directive.
128
- * @param {EffectiveDirective} currentFileEffectiveDirective The current file's effective directive.
129
- * @param {EffectiveDirective} importedFileEffectiveDirective The imported file's effective directive.
130
- * @returns `true` if the import is blocked, as established in `effectiveDirectives_BlockedImports`.
127
+ * $COMMENT#JSDOC#DEFINITIONS#AGNOSTIC20#ISIMPORTBLOCKED
128
+ * @param {EffectiveDirective} currentFileEffectiveDirective $COMMENT#JSDOC#PARAMS#AGNOSTIC20#CURRENTFILEEFFECTIVEDIRECTIVE
129
+ * @param {EffectiveDirective} importedFileEffectiveDirective $COMMENT#JSDOC#PARAMS#AGNOSTIC20#IMPORTEDFILEEFFECTIVEDIRECTIVE
130
+ * @returns $COMMENT#JSDOC#RETURNS#AGNOSTIC20#ISIMPORTBLOCKED
131
131
  */
132
132
  export const isImportBlocked = (
133
133
  currentFileEffectiveDirective,
@@ -142,9 +142,9 @@ export const isImportBlocked = (
142
142
  /* makeMessageFromCurrentFileEffectiveDirective */
143
143
 
144
144
  /**
145
- * Lists in an message the effective modules incompatible with an effective module based on its effective directive.
146
- * @param {EffectiveDirective} effectiveDirective The effective directive of the effective module.
147
- * @returns The message listing the incompatible effective modules.
145
+ * $COMMENT#JSDOC#DEFINITIONS#AGNOSTIC20#MAKEMESSAGEFROMCURRENTFILEEFFECTIVEDIRECTIVE
146
+ * @param {EffectiveDirective} effectiveDirective $COMMENT#JSDOC#PARAMS#AGNOSTIC20#EFFECTIVEDIRECTIVE
147
+ * @returns $COMMENT#JSDOC#RETURNS#AGNOSTIC20#MAKEMESSAGEFROMCURRENTFILEEFFECTIVEDIRECTIVE
148
148
  */
149
149
  export const makeMessageFromCurrentFileEffectiveDirective = (
150
150
  effectiveDirective
@@ -157,10 +157,10 @@ export const makeMessageFromCurrentFileEffectiveDirective = (
157
157
  /* findSpecificViolationMessage */
158
158
 
159
159
  /**
160
- * Finds the `message` for the specific violation of effective directives import rules based on `effectiveDirectives_BlockedImports`.
161
- * @param {EffectiveDirective} currentFileEffectiveDirective The current file's effective directive.
162
- * @param {EffectiveDirective} importedFileEffectiveDirective The imported file's effective directive.
163
- * @returns The corresponding `message`.
160
+ * $COMMENT#JSDOC#DEFINITIONS#AGNOSTIC20#FINDSPECIFICVIOLATIONMESSAGE
161
+ * @param {EffectiveDirective} currentFileEffectiveDirective $COMMENT#JSDOC#PARAMS#AGNOSTIC20#CURRENTFILEEFFECTIVEDIRECTIVE
162
+ * @param {EffectiveDirective} importedFileEffectiveDirective $COMMENT#JSDOC#PARAMS#AGNOSTIC20#IMPORTEDFILEEFFECTIVEDIRECTIVE
163
+ * @returns $COMMENT#JSDOC#RETURNS#FINDSPECIFICVIOLATIONMESSAGE
164
164
  */
165
165
  export const findSpecificViolationMessage = (
166
166
  currentFileEffectiveDirective,
@@ -12,9 +12,9 @@ import {
12
12
  */
13
13
 
14
14
  /**
15
- * Makes the agnostic20 config for the use-agnostic ESLint plugin.
16
- * @param {Plugin} plugin The use-agnostic ESLint plugin itself.
17
- * @returns The agnostic20 config's name as a key and its config as its value.
15
+ * $COMMENT#JSDOC#DEFINITIONS#AGNOSTIC20#MAKEAGNOSTIC20CONFIG
16
+ * @param {Plugin} plugin $COMMENT#JSDOC#PARAMS#PLUGIN
17
+ * @returns $COMMENT#JSDOC#RETURNS#AGNOSTIC20#MAKEAGNOSTIC20CONFIG
18
18
  */
19
19
  export const makeAgnostic20Config = (plugin) => ({
20
20
  [agnostic20ConfigName]: defineConfig([