eslint-plugin-use-agnostic 0.10.2 → 0.10.4

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.
@@ -78,7 +78,7 @@ export const AGNOSTIC_STRATEGIES_MODULE = "Agnostic Strategies Module";
78
78
 
79
79
  // all mappings of "resolved" directives with "resolved" modules
80
80
  // agnostic20
81
- export const effectiveDirectives_effectiveModules = Object.freeze({
81
+ const effectiveDirectives_effectiveModules = Object.freeze({
82
82
  [USE_SERVER_LOGICS]: SERVER_LOGICS_MODULE,
83
83
  [USE_SERVER_COMPONENTS]: SERVER_COMPONENTS_MODULE,
84
84
  [USE_SERVER_FUNCTIONS]: SERVER_FUNCTIONS_MODULE,
@@ -88,12 +88,15 @@ export const effectiveDirectives_effectiveModules = Object.freeze({
88
88
  [USE_AGNOSTIC_COMPONENTS]: AGNOSTIC_COMPONENTS_MODULE,
89
89
  });
90
90
  // and directive21
91
- export const commentedDirectives_commentedModules = Object.freeze({
91
+ const commentedDirectives_commentedModules = Object.freeze({
92
92
  [USE_CLIENT_CONTEXTS]: CLIENT_CONTEXTS_MODULE,
93
93
  [USE_AGNOSTIC_CONDITIONS]: AGNOSTIC_CONDITIONS_MODULE,
94
94
  [USE_AGNOSTIC_STRATEGIES]: AGNOSTIC_STRATEGIES_MODULE,
95
95
  ...effectiveDirectives_effectiveModules,
96
96
  });
97
+ // for commons uses
98
+ export const resolvedDirectives_resolvedModules =
99
+ commentedDirectives_commentedModules;
97
100
 
98
101
  // JavaScript/TypeScript extensions
99
102
  export const TSX = ".tsx";
@@ -105,7 +108,7 @@ export const CJS = ".cjs";
105
108
 
106
109
  // JavaScript/TypeScript extensions array
107
110
  /** @type {Extensions} */
108
- export const EXTENSIONS = [TSX, TS, JSX, JS, MJS, CJS]; // In priority order
111
+ export const EXTENSIONS = Object.freeze([TSX, TS, JSX, JS, MJS, CJS]); // In priority order
109
112
 
110
113
  // message strings
111
114
  export const ARE_NOT_ALLOWED_TO_IMPORT = "are not allowed to import";
@@ -3,20 +3,26 @@ import path from "path";
3
3
 
4
4
  import { loadConfig, createMatchPath } from "tsconfig-paths";
5
5
 
6
- import { EXTENSIONS, ARE_NOT_ALLOWED_TO_IMPORT } from "../constants/bases.js";
6
+ import {
7
+ EXTENSIONS,
8
+ ARE_NOT_ALLOWED_TO_IMPORT,
9
+ resolvedDirectives_resolvedModules,
10
+ } from "../constants/bases.js";
11
+
12
+ import jscommentsConfig from "../../../comments.config.js";
7
13
 
8
14
  /**
9
- * @typedef {import('../../../types/_commons/typedefs').ResolvedDirectives_ResolvedModules} ResolvedDirectives_ResolvedModules
10
- * @typedef {import('../../../types/_commons/typedefs').CurrentFileResolvedDirective} CurrentFileResolvedDirective
15
+ * @typedef {import('../../../types/_commons/typedefs').EffectiveDirective} EffectiveDirective
16
+ * @typedef {import('../../../types/_commons/typedefs').CommentedDirective} CommentedDirective
17
+ * @typedef {import('../../../types/_commons/typedefs').ResolvedDirectiveWithoutUseAgnosticStrategies} ResolvedDirectiveWithoutUseAgnosticStrategies
18
+ * @typedef {import('../../../types/_commons/typedefs').Agnostic20ConfigName} Agnostic20ConfigName
19
+ * @typedef {import('../../../types/_commons/typedefs').Directive21ConfigName} Directive21ConfigName
20
+ * @typedef {import('../../../types/_commons/typedefs').UseAgnosticConfigName} UseAgnosticConfigName
11
21
  * @typedef {import('../../../types/_commons/typedefs').Context<string, readonly unknown[]>} Context
12
22
  */
13
23
 
14
24
  /**
15
- * @template {CurrentFileResolvedDirective} T
16
- * @typedef {import('../../../types/_commons/typedefs').ImportedFileResolvedDirective<T>} ImportedFileResolvedDirective
17
- */
18
- /**
19
- * @template {CurrentFileResolvedDirective} T
25
+ * @template {ResolvedDirectiveWithoutUseAgnosticStrategies} T
20
26
  * @typedef {import('../../../types/_commons/typedefs').ResolvedDirectives_BlockedImports<T>} ResolvedDirectives_BlockedImports
21
27
  */
22
28
 
@@ -114,10 +120,10 @@ export const highlightFirstLineOfCode = (context) => ({
114
120
 
115
121
  /**
116
122
  * Returns a boolean deciding if an imported file's "resolved" directive is incompatible with the current file's "resolved" directive.
117
- * @template {CurrentFileResolvedDirective} T
123
+ * @template {ResolvedDirectiveWithoutUseAgnosticStrategies} T
118
124
  * @param {ResolvedDirectives_BlockedImports<T>} resolvedDirectives_blockedImports The blocked imports object, either for agnostic20 or for directive21.
119
125
  * @param {T} currentFileResolvedDirective The current file's "resolved" directive.
120
- * @param {ImportedFileResolvedDirective<T>} importedFileResolvedDirective The imported file's "resolved" directive.
126
+ * @param {T} importedFileResolvedDirective The imported file's "resolved" directive.
121
127
  * @returns `true` if the import is blocked, as established in respective `resolvedDirectives_blockedImports`.
122
128
  */
123
129
  export const isImportBlocked = (
@@ -134,31 +140,32 @@ export const isImportBlocked = (
134
140
 
135
141
  /**
136
142
  * Makes the intro for each specific import rule violation messages.
137
- * @template {CurrentFileResolvedDirective} T
138
- * @param {ResolvedDirectives_ResolvedModules} resolvedDirectives_resolvedModules The resolved modules object, either for agnostic20 or for directive21.
139
- * @param {CurrentFileResolvedDirective} currentFileResolvedDirective The current file's "resolved" directive.
140
- * @param {ImportedFileResolvedDirective<T>} importedFileResolvedDirective The imported file's "resolved" directive.
143
+ * @template {ResolvedDirectiveWithoutUseAgnosticStrategies} T
144
+ * @template {ResolvedDirectiveWithoutUseAgnosticStrategies} U
145
+ * @param {T} currentFileResolvedDirective The current file's "resolved" directive, excluding `"use agnostic strategies"`.
146
+ * @param {U} importedFileResolvedDirective The imported file's "resolved" directive, excluding `"use agnostic strategies"`.
141
147
  * @returns "[Current file 'resolved' modules] are not allowed to import [imported file 'resolved' modules]."
142
148
  */
143
149
  export const makeIntroForSpecificViolationMessage = (
144
- resolvedDirectives_resolvedModules,
145
150
  currentFileResolvedDirective,
146
151
  importedFileResolvedDirective
147
- ) =>
148
- `${resolvedDirectives_resolvedModules[currentFileResolvedDirective]}s ${ARE_NOT_ALLOWED_TO_IMPORT} ${resolvedDirectives_resolvedModules[importedFileResolvedDirective]}s.`;
152
+ ) => {
153
+ /** @type {`${typeof resolvedDirectives_resolvedModules[T]}s ${typeof ARE_NOT_ALLOWED_TO_IMPORT} ${typeof resolvedDirectives_resolvedModules[U]}s.`} */
154
+ const introForSpecificViolationMessage = `${resolvedDirectives_resolvedModules[currentFileResolvedDirective]}s ${ARE_NOT_ALLOWED_TO_IMPORT} ${resolvedDirectives_resolvedModules[importedFileResolvedDirective]}s.`;
155
+
156
+ return introForSpecificViolationMessage;
157
+ };
149
158
 
150
159
  /* makeMessageFromCurrentFileResolvedDirective */
151
160
 
152
161
  /**
153
162
  * Lists in an message the "resolved" modules incompatible with a "resolved" module based on its "resolved" directive.
154
- * @template {CurrentFileResolvedDirective} T
155
- * @param {ResolvedDirectives_ResolvedModules} resolvedDirectives_resolvedModules The resolved modules object, either for agnostic20 or for directive21.
163
+ * @template {ResolvedDirectiveWithoutUseAgnosticStrategies} T
156
164
  * @param {ResolvedDirectives_BlockedImports<T>} resolvedDirectives_blockedImports The blocked imports object, either for agnostic20 or for directive21.
157
165
  * @param {T} currentFileResolvedDirective The "resolved" directive of the "resolved" module.
158
166
  * @returns The message listing the incompatible "resolved" modules.
159
167
  */
160
168
  export const makeMessageFromCurrentFileResolvedDirective = (
161
- resolvedDirectives_resolvedModules,
162
169
  resolvedDirectives_blockedImports,
163
170
  currentFileResolvedDirective
164
171
  ) => {
@@ -193,10 +200,10 @@ export const makeMessageFromCurrentFileResolvedDirective = (
193
200
 
194
201
  /**
195
202
  * Finds the `message` for the specific violation of "resolved" directives import rules based on `resolvedDirectives_blockedImports`.
196
- * @template {CurrentFileResolvedDirective} T
203
+ * @template {ResolvedDirectiveWithoutUseAgnosticStrategies} T
197
204
  * @param {ResolvedDirectives_BlockedImports<T>} resolvedDirectives_blockedImports The blocked imports object, either for agnostic20 or for directive21.
198
- * @param {T} currentFileResolvedDirective The current file's "resolved" directive.
199
- * @param {ImportedFileResolvedDirective<T>} importedFileResolvedDirective The imported file's "resolved" directive.
205
+ * @param {T} currentFileResolvedDirective The current file's "resolved" directive, excluding `"use agnostic strategies"`.
206
+ * @param {T} importedFileResolvedDirective The imported file's "resolved" directive.
200
207
  * @returns The corresponding `message`.
201
208
  */
202
209
  export const findSpecificViolationMessage = (
@@ -1,4 +1,5 @@
1
1
  import {
2
+ agnostic20ConfigName,
2
3
  USE_SERVER_LOGICS as COMMONS_USE_SERVER_LOGICS,
3
4
  USE_SERVER_COMPONENTS as COMMONS_USE_SERVER_COMPONENTS,
4
5
  USE_SERVER_FUNCTIONS as COMMONS_USE_SERVER_FUNCTIONS,
@@ -6,10 +7,11 @@ import {
6
7
  USE_CLIENT_COMPONENTS as COMMONS_USE_CLIENT_COMPONENTS,
7
8
  USE_AGNOSTIC_LOGICS as COMMONS_USE_AGNOSTIC_LOGICS,
8
9
  USE_AGNOSTIC_COMPONENTS as COMMONS_USE_AGNOSTIC_COMPONENTS,
9
- effectiveDirectives_effectiveModules,
10
10
  } from "../../../_commons/constants/bases.js";
11
11
 
12
- import { makeIntroForSpecificViolationMessage as commonsMakeIntroForSpecificViolationMessage } from "../../../_commons/utilities/helpers.js";
12
+ import { makeIntroForSpecificViolationMessage } from "../../../_commons/utilities/helpers.js";
13
+
14
+ import jscommentsConfig from "../../../../comments.config.js";
13
15
 
14
16
  /**
15
17
  * @typedef {import('../../../../types/agnostic20/_commons/typedefs.js').Directive} Directive
@@ -26,7 +28,11 @@ export const USE_AGNOSTIC = "use agnostic";
26
28
 
27
29
  // directives array
28
30
  /** @type {Directives} */
29
- export const directivesArray = [USE_SERVER, USE_CLIENT, USE_AGNOSTIC];
31
+ export const directivesArray = Object.freeze([
32
+ USE_SERVER,
33
+ USE_CLIENT,
34
+ USE_AGNOSTIC,
35
+ ]);
30
36
 
31
37
  // directives set
32
38
  /** @type {ReadonlySet<Directive>} */
@@ -48,7 +54,7 @@ export const FUNCTIONS = "functions";
48
54
 
49
55
  // mapping directives with effective directives
50
56
  /** @type {Directives_EffectiveDirectives} */
51
- export const directives_effectiveDirectives = Object.freeze({
57
+ export const directives_effectiveDirectives = {
52
58
  [NO_DIRECTIVE]: {
53
59
  [LOGICS]: USE_SERVER_LOGICS,
54
60
  [COMPONENTS]: USE_SERVER_COMPONENTS,
@@ -69,7 +75,7 @@ export const directives_effectiveDirectives = Object.freeze({
69
75
  [COMPONENTS]: USE_AGNOSTIC_COMPONENTS,
70
76
  [FUNCTIONS]: null,
71
77
  },
72
- });
78
+ };
73
79
 
74
80
  // message placeholders
75
81
  export const currentFileEffectiveDirective = "currentFileEffectiveDirective";
@@ -79,209 +85,178 @@ export const specificViolationMessage = "specificViolationMessage";
79
85
 
80
86
  /* effectiveDirectives_BlockedImports */
81
87
 
88
+ const SUGGEST_USE_AGNOSTIC =
89
+ "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
+
91
+ /**
92
+ * Makes a blockedImport object for the identified blocked import at hand.
93
+ * @template {EffectiveDirective} T
94
+ * @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.
98
+ */
99
+ export const makeBlockedImport = (
100
+ currentFileEffectiveDirective,
101
+ importedFileEffectiveDirective
102
+ ) => {
103
+ return Object.freeze({
104
+ blockedImport: importedFileEffectiveDirective,
105
+ message: `${makeIntroForSpecificViolationMessage(
106
+ currentFileEffectiveDirective,
107
+ importedFileEffectiveDirective
108
+ )} ${
109
+ jscommentsConfig[agnostic20ConfigName][currentFileEffectiveDirective][
110
+ importedFileEffectiveDirective
111
+ ]
112
+ }`,
113
+ });
114
+ };
115
+
82
116
  /**
83
- * Makes the intro for each specific import rule violation messages.
84
- * @param {EffectiveDirective} currentFileEffectiveDirective The current file's effective directive.
85
- * @param {EffectiveDirective} importedFileEffectiveDirective The imported file's effective directive.
86
- * @returns "[Current file effective modules] are not allowed to import [imported file effective modules]."
117
+ * Makes a blockedImport object for the identified blocked import at hand enhanced with the suggestion to use the `'use agnostic'` directive.
118
+ * @template {EffectiveDirective} T
119
+ * @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.
87
123
  */
88
- const makeIntroForSpecificViolationMessage = (
124
+ const makeBlockedImportSuggestingUseAgnostic = (
89
125
  currentFileEffectiveDirective,
90
126
  importedFileEffectiveDirective
91
- ) =>
92
- commonsMakeIntroForSpecificViolationMessage(
93
- effectiveDirectives_effectiveModules,
127
+ ) => {
128
+ const blockedImport = makeBlockedImport(
94
129
  currentFileEffectiveDirective,
95
130
  importedFileEffectiveDirective
96
131
  );
132
+ /** @type {`${typeof blockedImport.message} \n${SUGGEST_USE_AGNOSTIC}`} */
133
+ const blockedImportMessageSuggestingUseAgnostic = `${blockedImport.message} \n${SUGGEST_USE_AGNOSTIC}`;
97
134
 
98
- const SUGGEST_USE_AGNOSTIC =
99
- "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.";
135
+ return Object.freeze({
136
+ ...blockedImport,
137
+ message: blockedImportMessageSuggestingUseAgnostic,
138
+ });
139
+ };
100
140
 
101
141
  export const effectiveDirectives_blockedImports = Object.freeze({
102
142
  [USE_SERVER_LOGICS]: [
103
- // USE_SERVER_LOGICS allowed, because Server Logics can compose with one another.
104
- // 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.
105
- // 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.)
106
- {
107
- blockedImport: USE_CLIENT_LOGICS,
108
- message: `${makeIntroForSpecificViolationMessage(
109
- USE_SERVER_LOGICS,
110
- USE_CLIENT_LOGICS
111
- )} Client Logics should never leak to the server.`,
112
- },
113
- {
114
- blockedImport: USE_CLIENT_COMPONENTS,
115
- message: `${makeIntroForSpecificViolationMessage(
116
- USE_SERVER_LOGICS,
117
- USE_CLIENT_COMPONENTS
118
- )} Client Components cannot be tinkered with on the server.`,
119
- },
120
- // USE_AGNOSTIC_LOGICS allowed, because Agnostic Logics can run safely on the server just like they can on the client.
121
- // 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.
143
+ // USE_SERVER_LOGICS allowed, because $COMMENT#AGNOSTIC20#USE_SERVER_LOGICS#USE_SERVER_LOGICS
144
+ // USE_SERVER_COMPONENTS allowed, because $COMMENT#AGNOSTIC20#USE_SERVER_LOGICS#USE_SERVER_COMPONENTS
145
+ // USE_SERVER_FUNCTIONS allowed, because $COMMENT#AGNOSTIC20#USE_SERVER_LOGICS#USE_SERVER_FUNCTIONS
146
+ makeBlockedImport(
147
+ USE_SERVER_LOGICS,
148
+ USE_CLIENT_LOGICS
149
+ ) /* $COMMENT#AGNOSTIC20#USE_SERVER_LOGICS#USE_CLIENT_LOGICS */,
150
+ makeBlockedImport(
151
+ USE_SERVER_LOGICS,
152
+ USE_CLIENT_COMPONENTS
153
+ ) /* $COMMENT#AGNOSTIC20#USE_SERVER_LOGICS#USE_CLIENT_COMPONENTS */,
154
+ // USE_AGNOSTIC_LOGICS allowed, because $COMMENT#AGNOSTIC20#USE_SERVER_LOGICS#USE_AGNOSTIC_LOGICS
155
+ // USE_AGNOSTIC_COMPONENTS allowed, because $COMMENT#AGNOSTIC20#USE_SERVER_LOGICS#USE_AGNOSTIC_COMPONENTS
122
156
  ],
123
157
  [USE_SERVER_COMPONENTS]: [
124
- // USE_SERVER_LOGICS allowed, because Server Logics, being logic from the server, can safely support Server Components.
125
- // 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.
126
- // 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.
127
- {
128
- blockedImport: USE_CLIENT_LOGICS,
129
- message: `${makeIntroForSpecificViolationMessage(
130
- USE_SERVER_COMPONENTS,
131
- USE_CLIENT_LOGICS
132
- )} Client Logics should never leak to the server.`,
133
- },
134
- // 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.
135
- // USE_AGNOSTIC_LOGICS allowed, because Agnostic Logics can run safely on the server just like they can on the client.
136
- // USE_AGNOSTIC_COMPONENTS allowed, because Agnostic Components can render safely on the server just like they can on the client.
158
+ // USE_SERVER_LOGICS allowed, because $COMMENT#AGNOSTIC20#USE_SERVER_COMPONENTS#USE_SERVER_LOGICS
159
+ // USE_SERVER_COMPONENTS allowed, because $COMMENT#AGNOSTIC20#USE_SERVER_COMPONENTS#USE_SERVER_COMPONENTS
160
+ // USE_SERVER_FUNCTIONS allowed, because $COMMENT#AGNOSTIC20#USE_SERVER_COMPONENTS#USE_SERVER_FUNCTIONS
161
+ makeBlockedImport(
162
+ USE_SERVER_COMPONENTS,
163
+ USE_CLIENT_LOGICS
164
+ ) /* $COMMENT#AGNOSTIC20#USE_SERVER_COMPONENTS#USE_CLIENT_LOGICS */,
165
+ // USE_CLIENT_COMPONENTS allowed, because $COMMENT#AGNOSTIC20#USE_SERVER_COMPONENTS#USE_CLIENT_COMPONENTS
166
+ // USE_AGNOSTIC_LOGICS allowed, because $COMMENT#AGNOSTIC20#USE_SERVER_COMPONENTS#USE_AGNOSTIC_LOGICS
167
+ // USE_AGNOSTIC_COMPONENTS allowed, because $COMMENT#AGNOSTIC20#USE_SERVER_COMPONENTS#USE_AGNOSTIC_COMPONENTS
137
168
  ],
138
169
  [USE_SERVER_FUNCTIONS]: [
139
- // USE_SERVER_LOGICS allowed, because Server Logics, being logic from the server, can safely support Server Functions.
140
- {
141
- blockedImport: USE_SERVER_COMPONENTS,
142
- message: `${makeIntroForSpecificViolationMessage(
143
- USE_SERVER_FUNCTIONS,
144
- USE_SERVER_COMPONENTS
145
- )} Server Components aren't allowed because Server Functions have no business working with React Components.`,
146
- },
147
- // 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.)
148
- {
149
- blockedImport: USE_CLIENT_LOGICS,
150
- message: `${makeIntroForSpecificViolationMessage(
151
- USE_SERVER_FUNCTIONS,
152
- USE_CLIENT_LOGICS
153
- )} Client Logics should never leak to the server.`,
154
- },
155
- {
156
- blockedImport: USE_CLIENT_COMPONENTS,
157
- message: `${makeIntroForSpecificViolationMessage(
158
- USE_SERVER_FUNCTIONS,
159
- USE_CLIENT_COMPONENTS
160
- )} Client Components aren't allowed because Server Functions have no business working with React Components.`,
161
- },
162
- // USE_AGNOSTIC_LOGICS allowed, because Agnostic Logics can run safely on the server just like they can on the client.
163
- {
164
- blockedImport: USE_AGNOSTIC_COMPONENTS,
165
- message: `${makeIntroForSpecificViolationMessage(
166
- USE_SERVER_FUNCTIONS,
167
- USE_AGNOSTIC_COMPONENTS
168
- )} Agnostic Components aren't allowed because Server Functions have no business working with React Components.`,
169
- },
170
+ // USE_SERVER_LOGICS allowed, because $COMMENT#AGNOSTIC20#USE_SERVER_FUNCTIONS#USE_SERVER_LOGICS
171
+ makeBlockedImport(
172
+ USE_SERVER_FUNCTIONS,
173
+ USE_SERVER_COMPONENTS
174
+ ) /* $COMMENT#AGNOSTIC20#USE_SERVER_FUNCTIONS#USE_SERVER_COMPONENTS */,
175
+ // USE_SERVER_FUNCTIONS allowed, because $COMMENT#AGNOSTIC20#USE_SERVER_FUNCTIONS#USE_SERVER_FUNCTIONS
176
+ makeBlockedImport(
177
+ USE_SERVER_FUNCTIONS,
178
+ USE_CLIENT_LOGICS
179
+ ) /* $COMMENT#AGNOSTIC20#USE_SERVER_FUNCTIONS#USE_CLIENT_LOGICS */,
180
+ makeBlockedImport(
181
+ USE_SERVER_FUNCTIONS,
182
+ USE_CLIENT_COMPONENTS
183
+ ) /* $COMMENT#AGNOSTIC20#USE_SERVER_FUNCTIONS#USE_CLIENT_COMPONENTS */,
184
+ // USE_AGNOSTIC_LOGICS allowed, because $COMMENT#AGNOSTIC20#USE_SERVER_FUNCTIONS#USE_AGNOSTIC_LOGICS
185
+ makeBlockedImport(
186
+ USE_SERVER_FUNCTIONS,
187
+ USE_AGNOSTIC_COMPONENTS
188
+ ) /* $COMMENT#AGNOSTIC20#USE_SERVER_FUNCTIONS#USE_AGNOSTIC_COMPONENTS */,
170
189
  ],
171
190
  [USE_CLIENT_LOGICS]: [
172
- {
173
- blockedImport: USE_SERVER_LOGICS,
174
- message: `${makeIntroForSpecificViolationMessage(
175
- USE_CLIENT_LOGICS,
176
- USE_SERVER_LOGICS
177
- )} Server Logics should never leak to the client.
178
- ${SUGGEST_USE_AGNOSTIC}`,
179
- },
180
- {
181
- blockedImport: USE_SERVER_COMPONENTS,
182
- message: `${makeIntroForSpecificViolationMessage(
183
- USE_CLIENT_LOGICS,
184
- USE_SERVER_COMPONENTS
185
- )} Server Components cannot be thinkered with on the client.
186
- ${SUGGEST_USE_AGNOSTIC}`,
187
- },
188
- // USE_SERVER_FUNCTIONS allowed, because Server Functions can technically be attached to Client Components that are being tinkered with within Client Logics Modules.
189
- // USE_CLIENT_LOGICS allowed, because Client Logics can compose with one another.
190
- // 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.
191
- // USE_AGNOSTIC_LOGICS allowed, because Agnostic Logics can run safely on the client just like they can on the server.
192
- // 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.
191
+ makeBlockedImportSuggestingUseAgnostic(
192
+ USE_CLIENT_LOGICS,
193
+ USE_SERVER_LOGICS
194
+ ) /* $COMMENT#AGNOSTIC20#USE_CLIENT_LOGICS#USE_SERVER_LOGICS */,
195
+ makeBlockedImportSuggestingUseAgnostic(
196
+ USE_CLIENT_LOGICS,
197
+ USE_SERVER_COMPONENTS
198
+ ) /* $COMMENT#AGNOSTIC20#USE_CLIENT_LOGICS#USE_SERVER_COMPONENTS */,
199
+ // USE_SERVER_FUNCTIONS allowed, because $COMMENT#AGNOSTIC20#USE_CLIENT_LOGICS#USE_SERVER_FUNCTIONS
200
+ // USE_CLIENT_LOGICS allowed, because $COMMENT#AGNOSTIC20#USE_CLIENT_LOGICS#USE_CLIENT_LOGICS
201
+ // USE_CLIENT_COMPONENTS allowed, because $COMMENT#AGNOSTIC20#USE_CLIENT_LOGICS#USE_CLIENT_COMPONENTS
202
+ // USE_AGNOSTIC_LOGICS allowed, because $COMMENT#AGNOSTIC20#USE_CLIENT_LOGICS#USE_AGNOSTIC_LOGICS
203
+ // USE_AGNOSTIC_COMPONENTS allowed, because $COMMENT#AGNOSTIC20#USE_CLIENT_LOGICS#USE_AGNOSTIC_COMPONENTS
193
204
  ],
194
205
  [USE_CLIENT_COMPONENTS]: [
195
- {
196
- blockedImport: USE_SERVER_LOGICS,
197
- message: `${makeIntroForSpecificViolationMessage(
198
- USE_CLIENT_COMPONENTS,
199
- USE_SERVER_LOGICS
200
- )} Server Logics should never leak to the client.
201
- ${SUGGEST_USE_AGNOSTIC}`,
202
- },
203
- {
204
- blockedImport: USE_SERVER_COMPONENTS,
205
- message: `${makeIntroForSpecificViolationMessage(
206
- USE_CLIENT_COMPONENTS,
207
- USE_SERVER_COMPONENTS
208
- )} Server Components may only pass through Client Components via the children prop within Server Components Modules.
209
- ${SUGGEST_USE_AGNOSTIC}`,
210
- },
211
- // USE_SERVER_FUNCTIONS allowed, because Server Functions are specifically triggered by Client Components.
212
- // USE_CLIENT_LOGICS allowed, because Client Logics, being logic from the client, can safely support Client Components.
213
- // USE_CLIENT_COMPONENTS allowed, because Client Components can compose with one another.
214
- // USE_AGNOSTIC_LOGICS allowed, because Agnostic Logics can run safely on the client just like they can on the server.
215
- // USE_AGNOSTIC_COMPONENTS allowed, because Agnostic Components can render safely on the client just like they can on the server.
206
+ makeBlockedImportSuggestingUseAgnostic(
207
+ USE_CLIENT_LOGICS,
208
+ USE_SERVER_LOGICS
209
+ ) /* $COMMENT#AGNOSTIC20#USE_CLIENT_LOGICS#USE_SERVER_LOGICS */,
210
+ makeBlockedImportSuggestingUseAgnostic(
211
+ USE_CLIENT_LOGICS,
212
+ USE_SERVER_COMPONENTS
213
+ ) /* $COMMENT#AGNOSTIC20#USE_CLIENT_LOGICS#USE_SERVER_COMPONENTS */,
214
+ // USE_SERVER_FUNCTIONS allowed, because $COMMENT#AGNOSTIC20#USE_CLIENT_COMPONENTS#USE_SERVER_FUNCTIONS
215
+ // USE_CLIENT_LOGICS allowed, because $COMMENT#AGNOSTIC20#USE_CLIENT_COMPONENTS#USE_CLIENT_LOGICS
216
+ // USE_CLIENT_COMPONENTS allowed, because $COMMENT#AGNOSTIC20#USE_CLIENT_COMPONENTS#USE_CLIENT_COMPONENTS
217
+ // USE_AGNOSTIC_LOGICS allowed, because $COMMENT#AGNOSTIC20#USE_CLIENT_COMPONENTS#USE_AGNOSTIC_LOGICS
218
+ // USE_AGNOSTIC_COMPONENTS allowed, because $COMMENT#AGNOSTIC20#USE_CLIENT_COMPONENTS#USE_AGNOSTIC_COMPONENTS
216
219
  ],
217
220
  [USE_AGNOSTIC_LOGICS]: [
218
- {
219
- blockedImport: USE_SERVER_LOGICS,
220
- message: `${makeIntroForSpecificViolationMessage(
221
- USE_AGNOSTIC_LOGICS,
222
- USE_SERVER_LOGICS
223
- )} Server Logics cannot run on both the server and the client.
224
- ${SUGGEST_USE_AGNOSTIC}`,
225
- },
226
- {
227
- blockedImport: USE_SERVER_COMPONENTS,
228
- message: `${makeIntroForSpecificViolationMessage(
229
- USE_AGNOSTIC_LOGICS,
230
- USE_SERVER_COMPONENTS
231
- )} Server Components cannot be tinkered with on both the server and the client.
232
- ${SUGGEST_USE_AGNOSTIC}`,
233
- },
234
- {
235
- blockedImport: USE_SERVER_FUNCTIONS,
236
- message: `${makeIntroForSpecificViolationMessage(
237
- USE_AGNOSTIC_LOGICS,
238
- USE_SERVER_FUNCTIONS
239
- )} 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.`,
240
- },
241
- {
242
- blockedImport: USE_CLIENT_LOGICS,
243
- message: `${makeIntroForSpecificViolationMessage(
244
- USE_AGNOSTIC_LOGICS,
245
- USE_CLIENT_LOGICS
246
- )} Client Logics cannot run on both the server and the client.`,
247
- },
248
- {
249
- blockedImport: USE_CLIENT_COMPONENTS,
250
- message: `${makeIntroForSpecificViolationMessage(
251
- USE_AGNOSTIC_LOGICS,
252
- USE_CLIENT_COMPONENTS
253
- )} Client Components cannot be tinkered with on both the server and the client.`,
254
- },
255
- // USE_AGNOSTIC_LOGICS allowed, because Agnostic Logics can compose with one another.
256
- // 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.
221
+ makeBlockedImportSuggestingUseAgnostic(
222
+ USE_AGNOSTIC_LOGICS,
223
+ USE_SERVER_LOGICS
224
+ ) /* $COMMENT#AGNOSTIC20#USE_AGNOSTIC_LOGICS#USE_SERVER_LOGICS */,
225
+ makeBlockedImportSuggestingUseAgnostic(
226
+ USE_AGNOSTIC_LOGICS,
227
+ USE_SERVER_COMPONENTS
228
+ ) /* $COMMENT#AGNOSTIC20#USE_AGNOSTIC_LOGICS#USE_SERVER_COMPONENTS */,
229
+ makeBlockedImport(
230
+ USE_AGNOSTIC_LOGICS,
231
+ USE_SERVER_FUNCTIONS
232
+ ) /* $COMMENT#AGNOSTIC20#USE_AGNOSTIC_LOGICS#USE_SERVER_FUNCTIONS */,
233
+ makeBlockedImport(
234
+ USE_AGNOSTIC_LOGICS,
235
+ USE_CLIENT_LOGICS
236
+ ) /* $COMMENT#AGNOSTIC20#USE_AGNOSTIC_LOGICS#USE_CLIENT_LOGICS */,
237
+ makeBlockedImport(
238
+ USE_AGNOSTIC_LOGICS,
239
+ USE_CLIENT_COMPONENTS
240
+ ) /* $COMMENT#AGNOSTIC20#USE_AGNOSTIC_LOGICS#USE_CLIENT_COMPONENTS */,
241
+ // USE_AGNOSTIC_LOGICS allowed, because $COMMENT#AGNOSTIC20#USE_AGNOSTIC_LOGICS#USE_AGNOSTIC_LOGICS
242
+ // USE_AGNOSTIC_COMPONENTS allowed, because $COMMENT#AGNOSTIC20#USE_AGNOSTIC_LOGICS#USE_AGNOSTIC_COMPONENTS
257
243
  ],
258
244
  [USE_AGNOSTIC_COMPONENTS]: [
259
- {
260
- blockedImport: USE_SERVER_LOGICS,
261
- message: `${makeIntroForSpecificViolationMessage(
262
- USE_AGNOSTIC_COMPONENTS,
263
- USE_SERVER_LOGICS
264
- )} Server Logics cannot run on both the server and the client.
265
- ${SUGGEST_USE_AGNOSTIC}`,
266
- },
267
- {
268
- blockedImport: USE_SERVER_COMPONENTS,
269
- message: `${makeIntroForSpecificViolationMessage(
270
- USE_AGNOSTIC_COMPONENTS,
271
- USE_SERVER_COMPONENTS
272
- )} 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.
273
- ${SUGGEST_USE_AGNOSTIC}`,
274
- },
275
- // 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.
276
- {
277
- blockedImport: USE_CLIENT_LOGICS,
278
- message: `${makeIntroForSpecificViolationMessage(
279
- USE_AGNOSTIC_COMPONENTS,
280
- USE_CLIENT_LOGICS
281
- )} Client Logics cannot run on both the server and the client.`,
282
- },
283
- // 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.
284
- // USE_AGNOSTIC_LOGICS allowed, because Agnostic Logics, being environment-agnostic logic, can safely support Agnostic Components.
285
- // USE_AGNOSTIC_COMPONENTS allowed, because Agnostic Components can compose with one another.
245
+ makeBlockedImportSuggestingUseAgnostic(
246
+ USE_AGNOSTIC_COMPONENTS,
247
+ USE_SERVER_LOGICS
248
+ ) /* $COMMENT#AGNOSTIC20#USE_AGNOSTIC_COMPONENTS#USE_SERVER_LOGICS */,
249
+ makeBlockedImportSuggestingUseAgnostic(
250
+ USE_AGNOSTIC_COMPONENTS,
251
+ USE_SERVER_COMPONENTS
252
+ ) /* $COMMENT#AGNOSTIC20#USE_AGNOSTIC_COMPONENTS#USE_SERVER_COMPONENTS */,
253
+ // USE_SERVER_FUNCTIONS allowed, because $COMMENT#AGNOSTIC20#USE_AGNOSTIC_COMPONENTS#USE_SERVER_FUNCTIONS
254
+ makeBlockedImport(
255
+ USE_AGNOSTIC_COMPONENTS,
256
+ USE_CLIENT_LOGICS
257
+ ) /* $COMMENT#AGNOSTIC20#USE_AGNOSTIC_COMPONENTS#USE_CLIENT_LOGICS */,
258
+ // USE_CLIENT_COMPONENTS allowed, because $COMMENT#AGNOSTIC20#USE_AGNOSTIC_COMPONENTS#USE_CLIENT_COMPONENTS
259
+ // USE_AGNOSTIC_LOGICS allowed, because $COMMENT#AGNOSTIC20#USE_AGNOSTIC_COMPONENTS#USE_AGNOSTIC_LOGICS
260
+ // USE_AGNOSTIC_COMPONENTS allowed, because $COMMENT#AGNOSTIC20#USE_AGNOSTIC_COMPONENTS#USE_AGNOSTIC_COMPONENTS
286
261
  ],
287
262
  });
@@ -1,4 +1,3 @@
1
- import { effectiveDirectives_effectiveModules } from "../../../_commons/constants/bases.js";
2
1
  import {
3
2
  USE_SERVER,
4
3
  LOGICS,
@@ -145,7 +144,6 @@ export const makeMessageFromCurrentFileEffectiveDirective = (
145
144
  effectiveDirective
146
145
  ) =>
147
146
  makeMessageFromCurrentFileResolvedDirective(
148
- effectiveDirectives_effectiveModules,
149
147
  effectiveDirectives_blockedImports,
150
148
  effectiveDirective
151
149
  );
@@ -1,4 +1,5 @@
1
1
  import {
2
+ directive21ConfigName,
2
3
  USE_SERVER_LOGICS as COMMONS_USE_SERVER_LOGICS,
3
4
  USE_CLIENT_LOGICS as COMMONS_USE_CLIENT_LOGICS,
4
5
  USE_AGNOSTIC_LOGICS as COMMONS_USE_AGNOSTIC_LOGICS,
@@ -9,11 +10,12 @@ import {
9
10
  USE_CLIENT_CONTEXTS as COMMONS_USE_CLIENT_CONTEXTS,
10
11
  USE_AGNOSTIC_CONDITIONS as COMMONS_USE_AGNOSTIC_CONDITIONS,
11
12
  USE_AGNOSTIC_STRATEGIES as COMMONS_USE_AGNOSTIC_STRATEGIES,
12
- commentedDirectives_commentedModules,
13
13
  } from "../../../_commons/constants/bases.js";
14
14
 
15
15
  import { makeIntroForSpecificViolationMessage as commonsMakeIntroForSpecificViolationMessage } from "../../../_commons/utilities/helpers.js";
16
16
 
17
+ import jscommentsConfig from "../../../../comments.config.js";
18
+
17
19
  /**
18
20
  * @typedef {import('../../../../types/directive21/_commons/typedefs.js').CommentedDirective} CommentedDirective
19
21
  * @typedef {import('../../../../types/directive21/_commons/typedefs.js').CommentedDirectiveWithoutUseAgnosticStrategies} CommentedDirectiveWithoutUseAgnosticStrategies
@@ -36,7 +38,7 @@ export const USE_AGNOSTIC_STRATEGIES = COMMONS_USE_AGNOSTIC_STRATEGIES;
36
38
 
37
39
  // commented directives array
38
40
  /** @type {CommentedDirectives} */
39
- export const commentedDirectivesArray = [
41
+ export const commentedDirectivesArray = Object.freeze([
40
42
  USE_SERVER_LOGICS,
41
43
  USE_CLIENT_LOGICS,
42
44
  USE_AGNOSTIC_LOGICS,
@@ -47,7 +49,7 @@ export const commentedDirectivesArray = [
47
49
  USE_CLIENT_CONTEXTS,
48
50
  USE_AGNOSTIC_CONDITIONS,
49
51
  USE_AGNOSTIC_STRATEGIES,
50
- ];
52
+ ]);
51
53
 
52
54
  // commented directives set
53
55
  /** @type {ReadonlySet<CommentedDirective>} */
@@ -80,7 +82,7 @@ export const AT_AGNOSTIC_CONDITIONS = "@agnosticConditions";
80
82
 
81
83
  // commented strategies array
82
84
  /** @type {CommentedStrategies} */
83
- export const strategiesArray = [
85
+ export const strategiesArray = Object.freeze([
84
86
  AT_SERVER_LOGICS,
85
87
  AT_CLIENT_LOGICS,
86
88
  AT_AGNOSTIC_LOGICS,
@@ -90,7 +92,7 @@ export const strategiesArray = [
90
92
  AT_SERVER_FUNCTIONS,
91
93
  AT_CLIENT_CONTEXTS,
92
94
  AT_AGNOSTIC_CONDITIONS,
93
- ];
95
+ ]);
94
96
 
95
97
  // commented strategies set
96
98
  /** @type {ReadonlySet<CommentedStrategy>} */
@@ -174,296 +176,215 @@ export const commentedDirectives_verificationReports = Object.freeze({
174
176
  /* commentedDirectives_blockedImports */
175
177
 
176
178
  /**
177
- * Makes the intro for each specific import rule violation messages.
178
- * @param {CommentedDirective} currentFileCommentedDirective The current file's commented directive.
179
- * @param {CommentedDirectiveWithoutUseAgnosticStrategies} importedFileCommentedDirective The imported file's commented directive.
180
- * @returns "[Current file commented modules] are not allowed to import [imported file commented modules]."
179
+ * Makes a blockedImport object for the identified blocked import at hand.
180
+ * @template {CommentedDirectiveWithoutUseAgnosticStrategies} T
181
+ * @template {CommentedDirectiveWithoutUseAgnosticStrategies} U
182
+ * @param {T} currentFileCommentedDirective The current file's commented directive.
183
+ * @param {U} importedFileCommentedDirective The imported file's commented directive.
184
+ * @returns The blockedImport object for the identified blocked import at hand.
181
185
  */
182
- const makeIntroForSpecificViolationMessage = (
186
+ export const makeBlockedImport = (
183
187
  currentFileCommentedDirective,
184
188
  importedFileCommentedDirective
185
- ) =>
186
- commonsMakeIntroForSpecificViolationMessage(
187
- commentedDirectives_commentedModules,
188
- currentFileCommentedDirective,
189
- importedFileCommentedDirective
190
- );
189
+ ) => {
190
+ return Object.freeze({
191
+ blockedImport: importedFileCommentedDirective,
192
+ message: `${commonsMakeIntroForSpecificViolationMessage(
193
+ currentFileCommentedDirective,
194
+ importedFileCommentedDirective
195
+ )} ${
196
+ jscommentsConfig[directive21ConfigName][currentFileCommentedDirective][
197
+ importedFileCommentedDirective
198
+ ]
199
+ }`,
200
+ });
201
+ };
191
202
 
192
203
  export const commentedDirectives_blockedImports = Object.freeze({
193
204
  [USE_SERVER_LOGICS]: [
194
- // USE_SERVER_LOGICS allowed, because Prime Server Logics can compose with one another.
195
- {
196
- blockedImport: USE_CLIENT_LOGICS,
197
- message: `${makeIntroForSpecificViolationMessage(
198
- USE_SERVER_LOGICS,
199
- USE_CLIENT_LOGICS
200
- )} Prime Client Logics should never leak to the server.`,
201
- },
202
- // USE_AGNOSTIC_LOGICS allowed, because Prime Agnostic Logics can run safely on the server just like they can on the client.
203
- // 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.
204
- {
205
- blockedImport: USE_CLIENT_COMPONENTS,
206
- message: `${makeIntroForSpecificViolationMessage(
207
- USE_SERVER_LOGICS,
208
- USE_CLIENT_COMPONENTS
209
- )} Lineal Client Components, like any Client Components, cannot be tinkered with on the server.`,
210
- },
211
- // 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.
212
- // 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.)
213
- {
214
- blockedImport: USE_CLIENT_CONTEXTS,
215
- message: `${makeIntroForSpecificViolationMessage(
216
- USE_SERVER_LOGICS,
217
- USE_CLIENT_CONTEXTS
218
- )} (Special) Client Contexts Components, like any Client Components, cannot be tinkered with on the server.`,
219
- },
220
- // 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.
205
+ // USE_SERVER_LOGICS allowed, because $COMMENT#DIRECTIVE21#USE_SERVER_LOGICS#USE_SERVER_LOGICS
206
+ makeBlockedImport(
207
+ USE_SERVER_LOGICS,
208
+ USE_CLIENT_LOGICS
209
+ ) /* $COMMENT#DIRECTIVE21#USE_SERVER_LOGICS#USE_CLIENT_LOGICS */,
210
+ // USE_AGNOSTIC_LOGICS allowed, because $COMMENT#DIRECTIVE21#USE_SERVER_LOGICS#USE_AGNOSTIC_LOGICS
211
+ // USE_SERVER_COMPONENTS allowed, because $COMMENT#DIRECTIVE21#USE_SERVER_LOGICS#USE_SERVER_COMPONENTS
212
+ makeBlockedImport(
213
+ USE_SERVER_LOGICS,
214
+ USE_CLIENT_COMPONENTS
215
+ ) /* $COMMENT#DIRECTIVE21#USE_SERVER_LOGICS#USE_CLIENT_COMPONENTS */,
216
+ // USE_AGNOSTIC_COMPONENTS allowed, because $COMMENT#DIRECTIVE21#USE_SERVER_LOGICS#USE_AGNOSTIC_COMPONENTS
217
+ // USE_SERVER_FUNCTIONS allowed, because $COMMENT#DIRECTIVE21#USE_SERVER_LOGICS#USE_SERVER_FUNCTIONS
218
+ makeBlockedImport(
219
+ USE_SERVER_LOGICS,
220
+ USE_CLIENT_CONTEXTS
221
+ ) /* $COMMENT#DIRECTIVE21#USE_SERVER_LOGICS#USE_CLIENT_CONTEXTS */,
222
+ // USE_AGNOSTIC_CONDITIONS allowed, because $COMMENT#DIRECTIVE21#USE_SERVER_LOGICS#USE_AGNOSTIC_CONDITIONS
221
223
  ],
222
224
  [USE_CLIENT_LOGICS]: [
223
- {
224
- blockedImport: USE_SERVER_LOGICS,
225
- message: `${makeIntroForSpecificViolationMessage(
226
- USE_CLIENT_LOGICS,
227
- USE_SERVER_LOGICS
228
- )} Prime Server Logics should never leak to the client.`,
229
- },
230
- // USE_CLIENT_LOGICS allowed, because Prime Client Logics can compose with one another.
231
- // USE_AGNOSTIC_LOGICS allowed, because Prime Agnostic Logics can run safely on the client just like they can on the server.
232
- {
233
- blockedImport: USE_SERVER_COMPONENTS,
234
- message: `${makeIntroForSpecificViolationMessage(
235
- USE_CLIENT_LOGICS,
236
- USE_SERVER_COMPONENTS
237
- )} Lineal Server Components cannot be thinkered with on the client.`,
238
- },
239
- // USE_CLIENT_COMPONENTS allowed, because Lineal Client 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.
240
- // 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.
241
- // USE_SERVER_FUNCTIONS allowed, because (Special) Server Functions can technically be attached to Client Components that are being tinkered with within Client Logics Modules.
242
- // 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.
243
- // 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.
225
+ makeBlockedImport(
226
+ USE_CLIENT_LOGICS,
227
+ USE_SERVER_LOGICS
228
+ ) /* $COMMENT#DIRECTIVE21#USE_CLIENT_LOGICS#USE_SERVER_LOGICS */,
229
+ // USE_CLIENT_LOGICS allowed, because $COMMENT#DIRECTIVE21#USE_CLIENT_LOGICS#USE_CLIENT_LOGICS
230
+ // USE_AGNOSTIC_LOGICS allowed, because $COMMENT#DIRECTIVE21#USE_CLIENT_LOGICS#USE_AGNOSTIC_LOGICS
231
+ makeBlockedImport(
232
+ USE_CLIENT_LOGICS,
233
+ USE_SERVER_COMPONENTS
234
+ ) /* $COMMENT#DIRECTIVE21#USE_CLIENT_LOGICS#USE_SERVER_COMPONENTS */,
235
+ // USE_CLIENT_COMPONENTS allowed, because $COMMENT#DIRECTIVE21#USE_CLIENT_LOGICS#USE_CLIENT_COMPONENTS
236
+ // USE_AGNOSTIC_COMPONENTS allowed, because $COMMENT#DIRECTIVE21#USE_CLIENT_LOGICS#USE_AGNOSTIC_COMPONENTS
237
+ // USE_SERVER_FUNCTIONS allowed, because $COMMENT#DIRECTIVE21#USE_CLIENT_LOGICS#USE_SERVER_FUNCTIONS
238
+ // USE_CLIENT_CONTEXTS allowed, because $COMMENT#DIRECTIVE21#USE_CLIENT_LOGICS#USE_CLIENT_CONTEXTS
239
+ // USE_AGNOSTIC_CONDITIONS allowed, because $COMMENT#DIRECTIVE21#USE_CLIENT_LOGICS#USE_AGNOSTIC_CONDITIONS
244
240
  ],
245
241
  [USE_AGNOSTIC_LOGICS]: [
246
- {
247
- blockedImport: USE_SERVER_LOGICS,
248
- message: `${makeIntroForSpecificViolationMessage(
249
- USE_AGNOSTIC_LOGICS,
250
- USE_SERVER_LOGICS
251
- )} Prime Server Logics cannot run on both the server and the client.`,
252
- },
253
- {
254
- blockedImport: USE_CLIENT_LOGICS,
255
- message: `${makeIntroForSpecificViolationMessage(
256
- USE_AGNOSTIC_LOGICS,
257
- USE_CLIENT_LOGICS
258
- )} Prime Client Logics cannot run on both the server and the client.`,
259
- },
260
- // USE_AGNOSTIC_LOGICS allowed, because Prime Agnostic Logics can compose with one another.
261
- {
262
- blockedImport: USE_SERVER_COMPONENTS,
263
- message: `${makeIntroForSpecificViolationMessage(
264
- USE_AGNOSTIC_LOGICS,
265
- USE_SERVER_COMPONENTS
266
- )} Lineal Server Components cannot be tinkered with on both the server and the client.`,
267
- },
268
- {
269
- blockedImport: USE_CLIENT_COMPONENTS,
270
- message: `${makeIntroForSpecificViolationMessage(
271
- USE_AGNOSTIC_LOGICS,
272
- USE_CLIENT_COMPONENTS
273
- )} Lineal Client Components, like any Client Components, cannot be tinkered with on both the server and the client.`,
274
- },
275
- // 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.
276
- {
277
- blockedImport: USE_SERVER_FUNCTIONS,
278
- message: `${makeIntroForSpecificViolationMessage(
279
- USE_AGNOSTIC_LOGICS,
280
- USE_SERVER_FUNCTIONS
281
- )} (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.`,
282
- },
283
- {
284
- blockedImport: USE_CLIENT_CONTEXTS,
285
- message: `${makeIntroForSpecificViolationMessage(
286
- USE_AGNOSTIC_LOGICS,
287
- USE_CLIENT_CONTEXTS
288
- )} (Special) Client Contexts Components, like any Client Components, cannot be tinkered with on both the server and the client.`,
289
- },
290
- // 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.
242
+ makeBlockedImport(
243
+ USE_AGNOSTIC_LOGICS,
244
+ USE_SERVER_LOGICS
245
+ ) /* $COMMENT#DIRECTIVE21#USE_AGNOSTIC_LOGICS#USE_SERVER_LOGICS */,
246
+ makeBlockedImport(
247
+ USE_AGNOSTIC_LOGICS,
248
+ USE_CLIENT_LOGICS
249
+ ) /* $COMMENT#DIRECTIVE21#USE_AGNOSTIC_LOGICS#USE_CLIENT_LOGICS */,
250
+ // USE_AGNOSTIC_LOGICS allowed, because $COMMENT#DIRECTIVE21#USE_AGNOSTIC_LOGICS#USE_AGNOSTIC_LOGICS
251
+ makeBlockedImport(
252
+ USE_AGNOSTIC_LOGICS,
253
+ USE_SERVER_COMPONENTS
254
+ ) /* $COMMENT#DIRECTIVE21#USE_AGNOSTIC_LOGICS#USE_SERVER_COMPONENTS */,
255
+ makeBlockedImport(
256
+ USE_AGNOSTIC_LOGICS,
257
+ USE_CLIENT_COMPONENTS
258
+ ) /* $COMMENT#DIRECTIVE21#USE_AGNOSTIC_LOGICS#USE_CLIENT_COMPONENTS */,
259
+ // USE_AGNOSTIC_COMPONENTS allowed, because $COMMENT#DIRECTIVE21#USE_AGNOSTIC_LOGICS#USE_AGNOSTIC_COMPONENTS
260
+ makeBlockedImport(
261
+ USE_AGNOSTIC_LOGICS,
262
+ USE_SERVER_FUNCTIONS
263
+ ) /* $COMMENT#DIRECTIVE21#USE_AGNOSTIC_LOGICS#USE_SERVER_FUNCTIONS */,
264
+ makeBlockedImport(
265
+ USE_AGNOSTIC_LOGICS,
266
+ USE_CLIENT_CONTEXTS
267
+ ) /* $COMMENT#DIRECTIVE21#USE_AGNOSTIC_LOGICS#USE_CLIENT_CONTEXTS */,
268
+ // USE_AGNOSTIC_CONDITIONS allowed, because $COMMENT#DIRECTIVE21#USE_AGNOSTIC_LOGICS#USE_AGNOSTIC_CONDITIONS
291
269
  ],
292
270
  [USE_SERVER_COMPONENTS]: [
293
- // USE_SERVER_LOGICS allowed, because Prime Server Logics, being logic from the server, can safely support Lineal Server Components.
294
- {
295
- blockedImport: USE_CLIENT_LOGICS,
296
- message: `${makeIntroForSpecificViolationMessage(
297
- USE_SERVER_COMPONENTS,
298
- USE_CLIENT_LOGICS
299
- )} Prime Client Logics should never leak to the server.`,
300
- },
301
- // USE_AGNOSTIC_LOGICS allowed, because Prime Agnostic Logics can run safely on the server just like they can on the client.
302
- // 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.
303
- // USE_CLIENT_COMPONENTS allowed, because Lineal Client Components can be nested inside Server Components to create client boundaries when the root of the application is planted on the server.
304
- // USE_AGNOSTIC_COMPONENTS allowed, because Lineal Agnostic Components can render safely on the server just like they can on the client.
305
- // 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.
306
- // USE_CLIENT_CONTEXTS allowed, because (Special) Client Contexts Components can be nested inside 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.
307
- // 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.
271
+ // USE_SERVER_LOGICS allowed, because $COMMENT#DIRECTIVE21#USE_SERVER_COMPONENTS#USE_SERVER_LOGICS
272
+ makeBlockedImport(
273
+ USE_SERVER_COMPONENTS,
274
+ USE_CLIENT_LOGICS
275
+ ) /* $COMMENT#DIRECTIVE21#USE_SERVER_COMPONENTS#USE_CLIENT_LOGICS */,
276
+ // USE_AGNOSTIC_LOGICS allowed, because $COMMENT#DIRECTIVE21#USE_SERVER_COMPONENTS#USE_AGNOSTIC_LOGICS
277
+ // USE_SERVER_COMPONENTS allowed, because $COMMENT#DIRECTIVE21#USE_SERVER_COMPONENTS#USE_SERVER_COMPONENTS
278
+ // USE_CLIENT_COMPONENTS allowed, because $COMMENT#DIRECTIVE21#USE_SERVER_COMPONENTS#USE_CLIENT_COMPONENTS
279
+ // USE_AGNOSTIC_COMPONENTS allowed, because $COMMENT#DIRECTIVE21#USE_SERVER_COMPONENTS#USE_AGNOSTIC_COMPONENTS
280
+ // USE_SERVER_FUNCTIONS allowed, because $COMMENT#DIRECTIVE21#USE_SERVER_COMPONENTS#USE_SERVER_FUNCTIONS
281
+ // USE_CLIENT_CONTEXTS allowed, because $COMMENT#DIRECTIVE21#USE_SERVER_COMPONENTS#USE_CLIENT_CONTEXTS
282
+ // USE_AGNOSTIC_CONDITIONS allowed, because $COMMENT#DIRECTIVE21#USE_SERVER_COMPONENTS#USE_AGNOSTIC_CONDITIONS
308
283
  ],
309
284
  [USE_CLIENT_COMPONENTS]: [
310
- {
311
- blockedImport: USE_SERVER_LOGICS,
312
- message: `${makeIntroForSpecificViolationMessage(
313
- USE_CLIENT_COMPONENTS,
314
- USE_SERVER_LOGICS
315
- )} Prime Server Logics should never leak to the client.`,
316
- },
317
- // USE_CLIENT_LOGICS allowed, because Prime Client Logics, being logic from the client, can safely support Lineal Client Components, like any Client Components.
318
- // USE_AGNOSTIC_LOGICS allowed, because Prime Agnostic Logics can run safely on the client just like they can on the server.
319
- {
320
- blockedImport: USE_SERVER_COMPONENTS,
321
- message: `${makeIntroForSpecificViolationMessage(
322
- USE_CLIENT_COMPONENTS,
323
- USE_SERVER_COMPONENTS
324
- )} Lineal Server Components cannot be the children of Lineal Client Components.`,
325
- },
326
- // USE_CLIENT_COMPONENTS allowed, because Lineal Client Components can compose with one another.
327
- // USE_AGNOSTIC_COMPONENTS allowed, because Lineal Agnostic Components can render safely on the client just like they can on the server.
328
- // USE_SERVER_FUNCTIONS allowed, because (Special) Server Functions are specifically triggered by Client Components.
329
- // 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 grand-children of an ancestor Lineal Client Component, enforcing them to render exclusively on the client.
330
- // 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.
285
+ makeBlockedImport(
286
+ USE_CLIENT_COMPONENTS,
287
+ USE_SERVER_LOGICS
288
+ ) /* $COMMENT#DIRECTIVE21#USE_CLIENT_COMPONENTS#USE_SERVER_LOGICS */,
289
+ // USE_CLIENT_LOGICS allowed, because $COMMENT#DIRECTIVE21#USE_CLIENT_COMPONENTS#USE_CLIENT_LOGICS
290
+ // USE_AGNOSTIC_LOGICS allowed, because $COMMENT#DIRECTIVE21#USE_CLIENT_COMPONENTS#USE_AGNOSTIC_LOGICS
291
+ makeBlockedImport(
292
+ USE_CLIENT_COMPONENTS,
293
+ USE_SERVER_COMPONENTS
294
+ ) /* $COMMENT#DIRECTIVE21#USE_CLIENT_COMPONENTS#USE_SERVER_COMPONENTS */,
295
+ // USE_CLIENT_COMPONENTS allowed, because $COMMENT#DIRECTIVE21#USE_CLIENT_COMPONENTS#USE_CLIENT_COMPONENTS
296
+ // USE_AGNOSTIC_COMPONENTS allowed, because $COMMENT#DIRECTIVE21#USE_CLIENT_COMPONENTS#USE_AGNOSTIC_COMPONENTS
297
+ // USE_SERVER_FUNCTIONS allowed, because $COMMENT#DIRECTIVE21#USE_CLIENT_COMPONENTS#USE_SERVER_FUNCTIONS
298
+ // USE_CLIENT_CONTEXTS allowed, because $COMMENT#DIRECTIVE21#USE_CLIENT_COMPONENTS#USE_CLIENT_CONTEXTS
299
+ // USE_AGNOSTIC_CONDITIONS allowed, because $COMMENT#DIRECTIVE21#USE_CLIENT_COMPONENTS#USE_AGNOSTIC_CONDITIONS
331
300
  ],
332
301
  [USE_AGNOSTIC_COMPONENTS]: [
333
- {
334
- blockedImport: USE_SERVER_LOGICS,
335
- message: `${makeIntroForSpecificViolationMessage(
336
- USE_AGNOSTIC_COMPONENTS,
337
- USE_SERVER_LOGICS
338
- )} Prime Server Logics cannot run on both the server and the client.`,
339
- },
340
- {
341
- blockedImport: USE_CLIENT_LOGICS,
342
- message: `${makeIntroForSpecificViolationMessage(
343
- USE_AGNOSTIC_COMPONENTS,
344
- USE_CLIENT_LOGICS
345
- )} Prime Client Logics cannot run on both the server and the client.`,
346
- },
347
- // USE_AGNOSTIC_LOGICS allowed, because Prime Agnostic Logics, being environment-agnostic logic, can safely support Agnostic Components.
348
- {
349
- blockedImport: USE_SERVER_COMPONENTS,
350
- message: `${makeIntroForSpecificViolationMessage(
351
- USE_AGNOSTIC_COMPONENTS,
352
- USE_SERVER_COMPONENTS
353
- )} 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.`,
354
- },
355
- // USE_CLIENT_COMPONENTS allowed, because Lineal Client Components can be nested inside Agnostic Components to create client boundaries when the root of the application is planted on the server.
356
- // USE_AGNOSTIC_COMPONENTS allowed, because Lineal Agnostic Components, can compose with one another.
357
- // 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.
358
- // USE_CLIENT_CONTEXTS allowed, because (Special) Client Contexts Components can be nested inside 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.
359
- // 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 Server Components to be nested in Agnostic Components.
302
+ makeBlockedImport(
303
+ USE_AGNOSTIC_COMPONENTS,
304
+ USE_SERVER_LOGICS
305
+ ) /* $COMMENT#DIRECTIVE21#USE_AGNOSTIC_COMPONENTS#USE_SERVER_LOGICS */,
306
+ makeBlockedImport(
307
+ USE_AGNOSTIC_COMPONENTS,
308
+ USE_CLIENT_LOGICS
309
+ ) /* $COMMENT#DIRECTIVE21#USE_AGNOSTIC_COMPONENTS#USE_CLIENT_LOGICS */,
310
+ // USE_AGNOSTIC_LOGICS allowed, because $COMMENT#DIRECTIVE21#USE_AGNOSTIC_COMPONENTS#USE_AGNOSTIC_LOGICS
311
+ makeBlockedImport(
312
+ USE_AGNOSTIC_COMPONENTS,
313
+ USE_SERVER_COMPONENTS
314
+ ) /* $COMMENT#DIRECTIVE21#USE_AGNOSTIC_COMPONENTS#USE_SERVER_COMPONENTS */,
315
+ // USE_CLIENT_COMPONENTS allowed, because $COMMENT#DIRECTIVE21#USE_AGNOSTIC_COMPONENTS#USE_CLIENT_COMPONENTS
316
+ // USE_AGNOSTIC_COMPONENTS allowed, because $COMMENT#DIRECTIVE21#USE_AGNOSTIC_COMPONENTS#USE_AGNOSTIC_COMPONENTS
317
+ // USE_SERVER_FUNCTIONS allowed, because $COMMENT#DIRECTIVE21#USE_AGNOSTIC_COMPONENTS#USE_SERVER_FUNCTIONS
318
+ // USE_CLIENT_CONTEXTS allowed, because $COMMENT#DIRECTIVE21#USE_AGNOSTIC_COMPONENTS#USE_CLIENT_CONTEXTS
319
+ // USE_AGNOSTIC_CONDITIONS allowed, because $COMMENT#DIRECTIVE21#USE_AGNOSTIC_COMPONENTS#USE_AGNOSTIC_CONDITIONS
360
320
  ],
361
321
  [USE_SERVER_FUNCTIONS]: [
362
- // USE_SERVER_LOGICS allowed, because Prime Server Logics, being logic from the server, can safely support (Special) Server Functions.
363
- {
364
- blockedImport: USE_CLIENT_LOGICS,
365
- message: `${makeIntroForSpecificViolationMessage(
366
- USE_SERVER_FUNCTIONS,
367
- USE_CLIENT_LOGICS
368
- )} Prime Client Logics should never leak to the server.`,
369
- },
370
- // USE_AGNOSTIC_LOGICS allowed, because Prime Agnostic Logics can run safely on the server just like they can on the client.
371
- {
372
- blockedImport: USE_SERVER_COMPONENTS,
373
- message: `${makeIntroForSpecificViolationMessage(
374
- USE_SERVER_FUNCTIONS,
375
- USE_SERVER_COMPONENTS
376
- )} Lineal Server Components aren't allowed because (Special) Server Functions have no business working with React Components.`,
377
- },
378
- {
379
- blockedImport: USE_CLIENT_COMPONENTS,
380
- message: `${makeIntroForSpecificViolationMessage(
381
- USE_SERVER_FUNCTIONS,
382
- USE_CLIENT_COMPONENTS
383
- )} Lineal Client Components aren't allowed because (Special) Server Functions have no business working with React Components.`,
384
- },
385
- {
386
- blockedImport: USE_AGNOSTIC_COMPONENTS,
387
- message: `${makeIntroForSpecificViolationMessage(
388
- USE_SERVER_FUNCTIONS,
389
- USE_AGNOSTIC_COMPONENTS
390
- )} Lineal Agnostic Components aren't allowed because (Special) Server Functions have no business working with React Components.`,
391
- },
392
- // 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.)
393
- {
394
- blockedImport: USE_CLIENT_CONTEXTS,
395
- message: `${makeIntroForSpecificViolationMessage(
396
- USE_SERVER_FUNCTIONS,
397
- USE_CLIENT_CONTEXTS
398
- )} (Special) Client Contexts Components aren't allowed because (Special) Server Functions have no business working with React Components.`,
399
- },
400
- {
401
- blockedImport: USE_AGNOSTIC_CONDITIONS,
402
- message: `${makeIntroForSpecificViolationMessage(
403
- USE_SERVER_FUNCTIONS,
404
- USE_AGNOSTIC_CONDITIONS
405
- )} (Special) Agnostic Conditions Components aren't allowed because (Special) Server Functions have no business working with React Components.`,
406
- },
322
+ // USE_SERVER_LOGICS allowed, because $COMMENT#DIRECTIVE21#USE_SERVER_FUNCTIONS#USE_SERVER_LOGICS
323
+ makeBlockedImport(
324
+ USE_SERVER_FUNCTIONS,
325
+ USE_CLIENT_LOGICS
326
+ ) /* $COMMENT#DIRECTIVE21#USE_SERVER_FUNCTIONS#USE_CLIENT_LOGICS */,
327
+ // USE_AGNOSTIC_LOGICS allowed, because $COMMENT#DIRECTIVE21#USE_SERVER_FUNCTIONS#USE_AGNOSTIC_LOGICS
328
+ makeBlockedImport(
329
+ USE_SERVER_FUNCTIONS,
330
+ USE_SERVER_COMPONENTS
331
+ ) /* $COMMENT#DIRECTIVE21#USE_SERVER_FUNCTIONS#USE_SERVER_COMPONENTS */,
332
+ makeBlockedImport(
333
+ USE_SERVER_FUNCTIONS,
334
+ USE_CLIENT_COMPONENTS
335
+ ) /* $COMMENT#DIRECTIVE21#USE_SERVER_FUNCTIONS#USE_CLIENT_COMPONENTS */,
336
+ makeBlockedImport(
337
+ USE_SERVER_FUNCTIONS,
338
+ USE_AGNOSTIC_COMPONENTS
339
+ ) /* $COMMENT#DIRECTIVE21#USE_SERVER_FUNCTIONS#USE_AGNOSTIC_COMPONENTS */,
340
+ // USE_SERVER_FUNCTIONS allowed, because $COMMENT#DIRECTIVE21#USE_SERVER_FUNCTIONS#USE_SERVER_FUNCTIONS
341
+ makeBlockedImport(
342
+ USE_SERVER_FUNCTIONS,
343
+ USE_CLIENT_CONTEXTS
344
+ ) /* $COMMENT#DIRECTIVE21#USE_SERVER_FUNCTIONS#USE_CLIENT_CONTEXTS */,
345
+ makeBlockedImport(
346
+ USE_SERVER_FUNCTIONS,
347
+ USE_AGNOSTIC_CONDITIONS
348
+ ) /* $COMMENT#DIRECTIVE21#USE_SERVER_FUNCTIONS#USE_AGNOSTIC_CONDITIONS */,
407
349
  ],
408
350
  [USE_CLIENT_CONTEXTS]: [
409
- {
410
- blockedImport: USE_SERVER_LOGICS,
411
- message: `${makeIntroForSpecificViolationMessage(
412
- USE_CLIENT_CONTEXTS,
413
- USE_SERVER_LOGICS
414
- )} Prime Server Logics should never leak to the client.`,
415
- },
416
- // USE_CLIENT_LOGICS allowed, because Prime Client Logics, being logic from the client, can safely support (Special) Client Contexts Components, like any Client Components.
417
- // USE_AGNOSTIC_LOGICS allowed, because Prime Agnostic Logics can run safely on the client just like they can on the server.
418
- {
419
- blockedImport: USE_SERVER_COMPONENTS,
420
- message: `${makeIntroForSpecificViolationMessage(
421
- USE_CLIENT_CONTEXTS,
422
- USE_SERVER_COMPONENTS
423
- )} Lineal Server Components may only pass through (Special) Client Contexts Components via the children prop within Server Components Modules.`,
424
- },
425
- // USE_CLIENT_COMPONENTS allowed, because Lineal Client Components can create client boundaries within (Special) Client Contexts Components.
426
- // USE_AGNOSTIC_COMPONENTS allowed, because Lineal Agnostic Components can render safely on the client just like they can on the server.
427
- // USE_SERVER_FUNCTIONS allowed, because (Special) Server Functions are specifically triggered by Client Components.
428
- // USE_CLIENT_CONTEXTS allowed, because (Special) Client Contexts Components can compose with one another.
429
- // 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 (Special) Client Contexts Components to safely and indirectly compose with child Server Components within Client Contexts Modules.
351
+ makeBlockedImport(
352
+ USE_CLIENT_CONTEXTS,
353
+ USE_SERVER_LOGICS
354
+ ) /* $COMMENT#DIRECTIVE21#USE_CLIENT_CONTEXTS#USE_SERVER_LOGICS */,
355
+ // USE_CLIENT_LOGICS allowed, because $COMMENT#DIRECTIVE21#USE_CLIENT_CONTEXTS#USE_CLIENT_LOGICS
356
+ // USE_AGNOSTIC_LOGICS allowed, because $COMMENT#DIRECTIVE21#USE_CLIENT_CONTEXTS#USE_AGNOSTIC_LOGICS
357
+ makeBlockedImport(
358
+ USE_CLIENT_CONTEXTS,
359
+ USE_SERVER_COMPONENTS
360
+ ) /* $COMMENT#DIRECTIVE21#USE_CLIENT_CONTEXTS#USE_SERVER_COMPONENTS */,
361
+ // USE_CLIENT_COMPONENTS allowed, because $COMMENT#DIRECTIVE21#USE_CLIENT_CONTEXTS#USE_CLIENT_COMPONENTS
362
+ // USE_AGNOSTIC_COMPONENTS allowed, because $COMMENT#DIRECTIVE21#USE_CLIENT_CONTEXTS#USE_AGNOSTIC_COMPONENTS
363
+ // USE_SERVER_FUNCTIONS allowed, because $COMMENT#DIRECTIVE21#USE_CLIENT_CONTEXTS#USE_SERVER_FUNCTIONS
364
+ // USE_CLIENT_CONTEXTS allowed, because $COMMENT#DIRECTIVE21#USE_CLIENT_CONTEXTS#USE_CLIENT_CONTEXTS
365
+ // USE_AGNOSTIC_CONDITIONS allowed, because $COMMENT#DIRECTIVE21#USE_CLIENT_CONTEXTS#USE_AGNOSTIC_CONDITIONS
430
366
  ],
431
367
  [USE_AGNOSTIC_CONDITIONS]: [
432
- {
433
- blockedImport: USE_SERVER_LOGICS,
434
- message: `${makeIntroForSpecificViolationMessage(
435
- USE_AGNOSTIC_CONDITIONS,
436
- USE_SERVER_LOGICS
437
- )} Prime Server Logics cannot run on both the server and the client.`,
438
- },
439
- {
440
- blockedImport: USE_CLIENT_LOGICS,
441
- message: `${makeIntroForSpecificViolationMessage(
442
- USE_AGNOSTIC_CONDITIONS,
443
- USE_CLIENT_LOGICS
444
- )} Prime Client Logics cannot run on both the server and the client.`,
445
- },
446
- // USE_AGNOSTIC_LOGICS allowed, because Prime Agnostic Logics, being environment-agnostic logic, can safely support 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.)
447
- // USE_SERVER_COMPONENTS allowed, because Lineal Server Components are to be paired as `ComponentForServer` components with `ComponentForClient` components to form (Special) Agnostic Conditions Components.
448
- // USE_CLIENT_COMPONENTS allowed, because Lineal Client Components are to be paired as `ComponentForClient` components with `ComponentForServer` components to form (Special) Agnostic Conditions Components.
449
- // USE_AGNOSTIC_COMPONENTS allowed, because Lineal Agnostic Components can take the place of `ComponentForServer` and/or `ComponentForClient` components to form (Special) Agnostic Conditions Components.
450
- {
451
- blockedImport: USE_SERVER_FUNCTIONS,
452
- message: `${makeIntroForSpecificViolationMessage(
453
- USE_AGNOSTIC_CONDITIONS,
454
- USE_SERVER_FUNCTIONS
455
- )} (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.`,
456
- },
457
- {
458
- blockedImport: USE_CLIENT_CONTEXTS,
459
- message: `${makeIntroForSpecificViolationMessage(
460
- USE_AGNOSTIC_CONDITIONS,
461
- USE_CLIENT_CONTEXTS
462
- )} (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.`,
463
- },
464
- // 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.
465
- ],
466
- [USE_AGNOSTIC_STRATEGIES]: [
467
- // (Special) Agnostic Strategies Modules can import all known modules, except themselves since they cannot be imported as they are, only as and via Strategies. (Since Agnostic Strategies Modules cannot be imported as they are, there is no such things as a 'use agnostic strategies' importFileCommentedDirective.)
368
+ makeBlockedImport(
369
+ USE_AGNOSTIC_CONDITIONS,
370
+ USE_SERVER_LOGICS
371
+ ) /* $COMMENT#DIRECTIVE21#USE_AGNOSTIC_CONDITIONS#USE_SERVER_LOGICS */,
372
+ makeBlockedImport(
373
+ USE_AGNOSTIC_CONDITIONS,
374
+ USE_CLIENT_LOGICS
375
+ ) /* $COMMENT#DIRECTIVE21#USE_AGNOSTIC_CONDITIONS#USE_CLIENT_LOGICS */,
376
+ // USE_AGNOSTIC_LOGICS allowed, because $COMMENT#DIRECTIVE21#USE_AGNOSTIC_CONDITIONS#USE_AGNOSTIC_LOGICS
377
+ // USE_SERVER_COMPONENTS allowed, because $COMMENT#DIRECTIVE21#USE_AGNOSTIC_CONDITIONS#USE_SERVER_COMPONENTS
378
+ // USE_CLIENT_COMPONENTS allowed, because $COMMENT#DIRECTIVE21#USE_AGNOSTIC_CONDITIONS#USE_CLIENT_COMPONENTS
379
+ // USE_AGNOSTIC_COMPONENTS allowed, because $COMMENT#DIRECTIVE21#USE_AGNOSTIC_CONDITIONS#USE_AGNOSTIC_COMPONENTS
380
+ makeBlockedImport(
381
+ USE_AGNOSTIC_CONDITIONS,
382
+ USE_SERVER_FUNCTIONS
383
+ ) /* $COMMENT#DIRECTIVE21#USE_AGNOSTIC_CONDITIONS#USE_SERVER_FUNCTIONS */,
384
+ makeBlockedImport(
385
+ USE_AGNOSTIC_CONDITIONS,
386
+ USE_CLIENT_CONTEXTS
387
+ ) /* $COMMENT#DIRECTIVE21#USE_AGNOSTIC_CONDITIONS#USE_CLIENT_CONTEXTS */,
388
+ // USE_AGNOSTIC_CONDITIONS allowed, because $COMMENT#DIRECTIVE21#USE_AGNOSTIC_CONDITIONS#USE_AGNOSTIC_CONDITIONS
468
389
  ],
469
390
  });
@@ -186,6 +186,9 @@ export const importsFlow = (context, node, currentFileCommentedDirective) => {
186
186
  if (result.skip) return;
187
187
  const { importedFileCommentedDirective } = result;
188
188
 
189
+ // returns early is the current file is an Agnostic Strategies Module
190
+ if (currentFileCommentedDirective === USE_AGNOSTIC_STRATEGIES) return;
191
+
189
192
  if (
190
193
  isImportBlocked(
191
194
  currentFileCommentedDirective,
@@ -1,7 +1,4 @@
1
- import {
2
- exportNotStrategized,
3
- commentedDirectives_commentedModules,
4
- } from "../../../_commons/constants/bases.js";
1
+ import { exportNotStrategized } from "../../../_commons/constants/bases.js";
5
2
  import {
6
3
  USE_AGNOSTIC_LOGICS,
7
4
  USE_AGNOSTIC_STRATEGIES,
@@ -138,7 +135,7 @@ export const getCommentedDirectiveFromCurrentModule = (context) => {
138
135
  * - `'use agnostic strategies'`: Agnostic Strategies Modules may export JSX.
139
136
  * @param {CommentedDirective} directive The commented directive as written on top of the file (cannot be `null` at that stage).
140
137
  * @param {Extension} extension The JavaScript (TypeScript) extension of the file.
141
- * @returns {CommentedDirective | null} The verified commented directive, from which imports rules are applied. Returns `null` if the verification failed, upon which an error will be reported depending on the commented directive, since the error logic here is strictly binary.
138
+ * @returns The verified commented directive, from which imports rules are applied. Returns `null` if the verification failed, upon which an error will be reported depending on the commented directive, since the error logic here is strictly binary.
142
139
  */
143
140
  export const getVerifiedCommentedDirective = (directive, extension) => {
144
141
  const rule = commentedDirectives_extensionRules[directive];
@@ -226,8 +223,9 @@ export const getStrategizedDirective = (context, node) => {
226
223
 
227
224
  /**
228
225
  * Returns a boolean deciding if an imported file's commented directive is incompatible with the current file's commented directive.
229
- * @param {CommentedDirective} currentFileCommentedDirective The current file's commented directive.
230
- * @param {CommentedDirectiveWithoutUseAgnosticStrategies} importedFileCommentedDirective The imported file's commented directive.
226
+ * @template {CommentedDirectiveWithoutUseAgnosticStrategies} T
227
+ * @param {T} currentFileCommentedDirective The current file's commented directive.
228
+ * @param {T} importedFileCommentedDirective The imported file's commented directive.
231
229
  * @returns `true` if the import is blocked, as established in `commentedDirectives_BlockedImports`.
232
230
  */
233
231
  export const isImportBlocked = (
@@ -244,14 +242,13 @@ export const isImportBlocked = (
244
242
 
245
243
  /**
246
244
  * Lists in an message the commented modules incompatible with a commented module based on its commented directive.
247
- * @param {CommentedDirective} commentedDirective The commented directive of the commented module.
245
+ * @param {CommentedDirectiveWithoutUseAgnosticStrategies} commentedDirective The commented directive of the commented module.
248
246
  * @returns The message listing the incompatible commented modules.
249
247
  */
250
248
  export const makeMessageFromCurrentFileCommentedDirective = (
251
249
  commentedDirective
252
250
  ) =>
253
251
  makeMessageFromCurrentFileResolvedDirective(
254
- commentedDirectives_commentedModules,
255
252
  commentedDirectives_blockedImports,
256
253
  commentedDirective
257
254
  );
@@ -260,8 +257,9 @@ export const makeMessageFromCurrentFileCommentedDirective = (
260
257
 
261
258
  /**
262
259
  * Finds the `message` for the specific violation of commented directives import rules based on `commentedDirectives_BlockedImports`.
263
- * @param {CommentedDirective} currentFileCommentedDirective The current file's commented directive.
264
- * @param {CommentedDirectiveWithoutUseAgnosticStrategies} importedFileCommentedDirective The imported file's commented directive.
260
+ * @template {CommentedDirectiveWithoutUseAgnosticStrategies} T
261
+ * @param {T} currentFileCommentedDirective The current file's commented directive.
262
+ * @param {T} importedFileCommentedDirective The imported file's commented directive.
265
263
  * @returns The corresponding `message`.
266
264
  */
267
265
  export const findSpecificViolationMessage = (
@@ -8,7 +8,7 @@ import {
8
8
  } from "../_commons/constants/bases.js";
9
9
 
10
10
  /**
11
- * @typedef {import('../../types/agnostic20/_commons/typedefs.js').Plugin} Plugin
11
+ * @typedef {import('../../types/directive21/_commons/typedefs.js').Plugin} Plugin
12
12
  */
13
13
 
14
14
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-use-agnostic",
3
- "version": "0.10.2",
3
+ "version": "0.10.4",
4
4
  "description": "Highlights problematic server-client imports in projects made with the Fullstack React Architecture.",
5
5
  "keywords": [
6
6
  "eslint",