eslint-plugin-use-agnostic 0.9.6 → 0.9.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,16 +1,5 @@
1
+ import { effectiveDirectives_effectiveModules } from "../../../_commons/constants/bases.js";
1
2
  import {
2
- TSX,
3
- TS,
4
- JSX,
5
- JS,
6
- MJS,
7
- CJS,
8
- useServerJSXMessageId,
9
- importBreaksEffectiveImportRulesMessageId,
10
- reExportNotSameMessageId,
11
- } from "../../../_commons/constants/bases.js";
12
- import {
13
- NO_DIRECTIVE,
14
3
  USE_SERVER,
15
4
  USE_CLIENT,
16
5
  USE_AGNOSTIC,
@@ -21,9 +10,9 @@ import {
21
10
  USE_CLIENT_COMPONENTS,
22
11
  USE_AGNOSTIC_LOGICS,
23
12
  USE_AGNOSTIC_COMPONENTS,
24
- effectiveDirectives_EffectiveModules,
25
13
  directivesArray,
26
- effectiveDirectives_BlockedImports,
14
+ directives_effectiveDirectives,
15
+ effectiveDirectives_blockedImports,
27
16
  } from "../constants/bases.js";
28
17
 
29
18
  import {
@@ -33,6 +22,13 @@ import {
33
22
  findSpecificViolationMessage as commonsFindSpecificViolationMessage,
34
23
  } from "../../../_commons/utilities/helpers.js";
35
24
 
25
+ /**
26
+ * @typedef {import('../../../../types/agnostic20/_commons/typedefs.js').Context} Context
27
+ * @typedef {import('../../../../types/agnostic20/_commons/typedefs.js').Directive} Directive
28
+ * @typedef {import('../../../../types/agnostic20/_commons/typedefs.js').Extension} Extension
29
+ * @typedef {import('../../../../types/agnostic20/_commons/typedefs.js').EffectiveDirective} EffectiveDirective
30
+ */
31
+
36
32
  /* getDirectiveFromCurrentModule */
37
33
 
38
34
  /**
@@ -41,7 +37,7 @@ import {
41
37
  * - `'use client'` denotes a Client Module.
42
38
  * - `'use server'` denotes a Server Functions Module.
43
39
  * - `'use agnostic'` denotes an Agnostic Module (formerly Shared Module).
44
- * @param {Readonly<import('@typescript-eslint/utils').TSESLint.RuleContext<typeof reExportNotSameMessageId | typeof importBreaksEffectiveImportRulesMessageId | typeof useServerJSXMessageId, []>>} context The ESLint rule's `context` object.
40
+ * @param {Context} context The ESLint rule's `context` object.
45
41
  * @returns The directive, or lack thereof via `null`. The lack of a directive is considered server-by-default.
46
42
  */
47
43
  export const getDirectiveFromCurrentModule = (context) => {
@@ -79,15 +75,14 @@ export const getDirectiveFromCurrentModule = (context) => {
79
75
  * - `'use client components'` denotes a Client Components Module.
80
76
  * - `'use agnostic logics'` denotes an Agnostic Logics Module.
81
77
  * - `'use agnostic components'` denotes an Agnostic Components Module.
82
- * @param {NO_DIRECTIVE | USE_SERVER | USE_CLIENT | USE_AGNOSTIC} directive The directive as written on top of the file (`null` if no valid directive).
83
- * @param {TSX | TS | JSX | JS | MJS | CJS} extension The JavaScript (TypeScript) extension of the file.
78
+ * @param {Directive | null} directive The directive as written on top of the file (`null` if no valid directive).
79
+ * @param {Extension} extension The JavaScript (TypeScript) extension of the file.
84
80
  * @returns The effective directive, from which imports rules are applied.
85
81
  */
86
82
  export const getEffectiveDirective = (directive, extension) => {
87
83
  // I could use a map, but because this is in JS with JSDoc, a manual solution is peculiarly more typesafe.
88
- if (directive === NO_DIRECTIVE && !extension.endsWith("x"))
89
- return USE_SERVER_LOGICS;
90
- if (directive === NO_DIRECTIVE && extension.endsWith("x"))
84
+ if (directive === null && !extension.endsWith("x")) return USE_SERVER_LOGICS;
85
+ if (directive === null && extension.endsWith("x"))
91
86
  return USE_SERVER_COMPONENTS;
92
87
  if (directive === USE_SERVER && !extension.endsWith("x"))
93
88
  return USE_SERVER_FUNCTIONS;
@@ -102,6 +97,23 @@ export const getEffectiveDirective = (directive, extension) => {
102
97
 
103
98
  return null; // default error, should be unreachable
104
99
  };
100
+ // directives_effectiveDirectives
101
+ /**
102
+ * @param {Directive | null} directive
103
+ * @param {Extension} extension
104
+ * @returns
105
+ */
106
+ export const trueGetEffectiveDirective = (directive, extension) => {
107
+ const type = extension.endsWith("x")
108
+ ? "components"
109
+ : directive === USE_SERVER
110
+ ? "functions"
111
+ : "logics";
112
+
113
+ const a = directives_effectiveDirectives[directive];
114
+
115
+ return directives_effectiveDirectives[directive]?.[type] ?? null;
116
+ };
105
117
 
106
118
  /* getDirectiveFromImportedModule */
107
119
 
@@ -139,8 +151,8 @@ export const getDirectiveFromImportedModule = (resolvedImportPath) => {
139
151
 
140
152
  /**
141
153
  * Returns a boolean deciding if an imported file's effective directive is incompatible with the current file's effective directive.
142
- * @param {USE_SERVER_LOGICS | USE_SERVER_COMPONENTS | USE_SERVER_FUNCTIONS | USE_CLIENT_LOGICS | USE_CLIENT_COMPONENTS | USE_AGNOSTIC_LOGICS | USE_AGNOSTIC_COMPONENTS} currentFileEffectiveDirective The current file's effective directive.
143
- * @param {USE_SERVER_LOGICS | USE_SERVER_COMPONENTS | USE_SERVER_FUNCTIONS | USE_CLIENT_LOGICS | USE_CLIENT_COMPONENTS | USE_AGNOSTIC_LOGICS | USE_AGNOSTIC_COMPONENTS} importedFileEffectiveDirective The imported file's effective directive.
154
+ * @param {EffectiveDirective} currentFileEffectiveDirective The current file's effective directive.
155
+ * @param {EffectiveDirective} importedFileEffectiveDirective The imported file's effective directive.
144
156
  * @returns `true` if the import is blocked, as established in `effectiveDirectives_BlockedImports`.
145
157
  */
146
158
  export const isImportBlocked = (
@@ -148,7 +160,7 @@ export const isImportBlocked = (
148
160
  importedFileEffectiveDirective
149
161
  ) =>
150
162
  commonsIsImportBlocked(
151
- effectiveDirectives_BlockedImports,
163
+ effectiveDirectives_blockedImports,
152
164
  currentFileEffectiveDirective,
153
165
  importedFileEffectiveDirective
154
166
  );
@@ -157,13 +169,13 @@ export const isImportBlocked = (
157
169
 
158
170
  /**
159
171
  * Lists in an message the effective modules incompatible with an effective module based on its effective directive.
160
- * @param {USE_SERVER_LOGICS | USE_SERVER_COMPONENTS | USE_SERVER_FUNCTIONS | USE_CLIENT_LOGICS | USE_CLIENT_COMPONENTS | USE_AGNOSTIC_LOGICS | USE_AGNOSTIC_COMPONENTS} effectiveDirective The effective directive of the effective module.
172
+ * @param {EffectiveDirective} effectiveDirective The effective directive of the effective module.
161
173
  * @returns The message listing the incompatible effective modules.
162
174
  */
163
175
  export const makeMessageFromEffectiveDirective = (effectiveDirective) =>
164
176
  makeMessageFromResolvedDirective(
165
- effectiveDirectives_EffectiveModules,
166
- effectiveDirectives_BlockedImports,
177
+ effectiveDirectives_effectiveModules,
178
+ effectiveDirectives_blockedImports,
167
179
  effectiveDirective
168
180
  );
169
181
 
@@ -171,8 +183,8 @@ export const makeMessageFromEffectiveDirective = (effectiveDirective) =>
171
183
 
172
184
  /**
173
185
  * Finds the `message` for the specific violation of effective directives import rules based on `effectiveDirectives_BlockedImports`.
174
- * @param {USE_SERVER_LOGICS | USE_SERVER_COMPONENTS | USE_SERVER_FUNCTIONS | USE_CLIENT_LOGICS | USE_CLIENT_COMPONENTS | USE_AGNOSTIC_LOGICS | USE_AGNOSTIC_COMPONENTS} currentFileEffectiveDirective The current file's effective directive.
175
- * @param {USE_SERVER_LOGICS | USE_SERVER_COMPONENTS | USE_SERVER_FUNCTIONS | USE_CLIENT_LOGICS | USE_CLIENT_COMPONENTS | USE_AGNOSTIC_LOGICS | USE_AGNOSTIC_COMPONENTS} importedFileEffectiveDirective The imported file's effective directive.
186
+ * @param {EffectiveDirective} currentFileEffectiveDirective The current file's effective directive.
187
+ * @param {EffectiveDirective} importedFileEffectiveDirective The imported file's effective directive.
176
188
  * @returns The corresponding `message`.
177
189
  */
178
190
  export const findSpecificViolationMessage = (
@@ -180,7 +192,7 @@ export const findSpecificViolationMessage = (
180
192
  importedFileEffectiveDirective
181
193
  ) =>
182
194
  commonsFindSpecificViolationMessage(
183
- effectiveDirectives_BlockedImports,
195
+ effectiveDirectives_blockedImports,
184
196
  currentFileEffectiveDirective,
185
197
  importedFileEffectiveDirective
186
198
  );
@@ -7,9 +7,13 @@ import {
7
7
  enforceEffectiveDirectivesRuleName,
8
8
  } from "../_commons/constants/bases.js";
9
9
 
10
+ /**
11
+ * @typedef {import('../../types/agnostic20/_commons/typedefs.js').Plugin} Plugin
12
+ */
13
+
10
14
  /**
11
15
  * Makes the agnostic20 config for the use-agnostic ESLint plugin.
12
- * @param {import('eslint').ESLint.Plugin} plugin The use-agnostic ESLint plugin itself.
16
+ * @param {Plugin} plugin The use-agnostic ESLint plugin itself.
13
17
  * @returns The agnostic20 config's name as a key and its config as its value.
14
18
  */
15
19
  export const makeAgnostic20Config = (plugin) => ({
@@ -9,20 +9,19 @@ import {
9
9
  USE_CLIENT_CONTEXTS as COMMONS_USE_CLIENT_CONTEXTS,
10
10
  USE_AGNOSTIC_CONDITIONS as COMMONS_USE_AGNOSTIC_CONDITIONS,
11
11
  USE_AGNOSTIC_STRATEGIES as COMMONS_USE_AGNOSTIC_STRATEGIES,
12
- SERVER_LOGICS_MODULE as COMMONS_SERVER_LOGICS_MODULE,
13
- CLIENT_LOGICS_MODULE as COMMONS_CLIENT_LOGICS_MODULE,
14
- AGNOSTIC_LOGICS_MODULE as COMMONS_AGNOSTIC_LOGICS_MODULE,
15
- SERVER_COMPONENTS_MODULE as COMMONS_SERVER_COMPONENTS_MODULE,
16
- CLIENT_COMPONENTS_MODULE as COMMONS_CLIENT_COMPONENTS_MODULE,
17
- AGNOSTIC_COMPONENTS_MODULE as COMMONS_AGNOSTIC_COMPONENTS_MODULE,
18
- SERVER_FUNCTIONS_MODULE as COMMONS_SERVER_FUNCTIONS_MODULE,
19
- CLIENT_CONTEXTS_MODULE as COMMONS_CLIENT_CONTEXTS_MODULE,
20
- AGNOSTIC_CONDITIONS_MODULE as COMMONS_AGNOSTIC_CONDITIONS_MODULE,
21
- AGNOSTIC_STRATEGIES_MODULE as COMMONS_AGNOSTIC_STRATEGIES_MODULE,
12
+ commentedDirectives_commentedModules,
22
13
  } from "../../../_commons/constants/bases.js";
23
14
 
24
15
  import { makeIntroForSpecificViolationMessage as commonsMakeIntroForSpecificViolationMessage } from "../../../_commons/utilities/helpers.js";
25
16
 
17
+ /**
18
+ * @typedef {import('../../../../types/directive21/_commons/typedefs.js').CommentedDirective} CommentedDirective
19
+ * @typedef {import('../../../../types/directive21/_commons/typedefs.js').CommentedDirectiveWithoutUseAgnosticStrategies} CommentedDirectiveWithoutUseAgnosticStrategies
20
+ * @typedef {import('../../../../types/directive21/_commons/typedefs.js').CommentedDirectives} CommentedDirectives
21
+ * @typedef {import('../../../../types/directive21/_commons/typedefs.js').CommentedStrategy} CommentedStrategy
22
+ * @typedef {import('../../../../types/directive21/_commons/typedefs.js').CommentedStrategies} CommentedStrategies
23
+ */
24
+
26
25
  // commented directives
27
26
  export const USE_SERVER_LOGICS = COMMONS_USE_SERVER_LOGICS;
28
27
  export const USE_CLIENT_LOGICS = COMMONS_USE_CLIENT_LOGICS;
@@ -36,7 +35,7 @@ export const USE_AGNOSTIC_CONDITIONS = COMMONS_USE_AGNOSTIC_CONDITIONS;
36
35
  export const USE_AGNOSTIC_STRATEGIES = COMMONS_USE_AGNOSTIC_STRATEGIES;
37
36
 
38
37
  // commented directives array
39
- /** @type {readonly [USE_SERVER_LOGICS, USE_CLIENT_LOGICS, USE_AGNOSTIC_LOGICS, USE_SERVER_COMPONENTS, USE_CLIENT_COMPONENTS, USE_AGNOSTIC_COMPONENTS, USE_SERVER_FUNCTIONS, USE_CLIENT_CONTEXTS, USE_AGNOSTIC_CONDITIONS, USE_AGNOSTIC_STRATEGIES]} */
38
+ /** @type {CommentedDirectives} */
40
39
  export const directivesArray = [
41
40
  USE_SERVER_LOGICS,
42
41
  USE_CLIENT_LOGICS,
@@ -51,48 +50,22 @@ export const directivesArray = [
51
50
  ];
52
51
 
53
52
  // commented directives set
54
- /** @type {ReadonlySet<USE_SERVER_LOGICS | USE_CLIENT_LOGICS | USE_AGNOSTIC_LOGICS | USE_SERVER_COMPONENTS | USE_CLIENT_COMPONENTS | USE_AGNOSTIC_COMPONENTS | USE_SERVER_FUNCTIONS | USE_CLIENT_CONTEXTS | USE_AGNOSTIC_CONDITIONS | USE_AGNOSTIC_STRATEGIES>} */
53
+ /** @type {ReadonlySet<CommentedDirective>} */
55
54
  export const directivesSet = new Set(directivesArray); // no longer used exported to satisfy static type inference
56
55
 
57
- // commented modules
58
- const SERVER_LOGICS_MODULE = COMMONS_SERVER_LOGICS_MODULE;
59
- const CLIENT_LOGICS_MODULE = COMMONS_CLIENT_LOGICS_MODULE;
60
- const AGNOSTIC_LOGICS_MODULE = COMMONS_AGNOSTIC_LOGICS_MODULE;
61
- const SERVER_COMPONENTS_MODULE = COMMONS_SERVER_COMPONENTS_MODULE;
62
- const CLIENT_COMPONENTS_MODULE = COMMONS_CLIENT_COMPONENTS_MODULE;
63
- const AGNOSTIC_COMPONENTS_MODULE = COMMONS_AGNOSTIC_COMPONENTS_MODULE;
64
- const SERVER_FUNCTIONS_MODULE = COMMONS_SERVER_FUNCTIONS_MODULE;
65
- const CLIENT_CONTEXTS_MODULE = COMMONS_CLIENT_CONTEXTS_MODULE;
66
- const AGNOSTIC_CONDITIONS_MODULE = COMMONS_AGNOSTIC_CONDITIONS_MODULE;
67
- const AGNOSTIC_STRATEGIES_MODULE = COMMONS_AGNOSTIC_STRATEGIES_MODULE;
68
-
69
- // mapping commented directives with commented modules
70
- export const commentedDirectives_CommentedModules = Object.freeze({
71
- [USE_SERVER_LOGICS]: SERVER_LOGICS_MODULE,
72
- [USE_CLIENT_LOGICS]: CLIENT_LOGICS_MODULE,
73
- [USE_AGNOSTIC_LOGICS]: AGNOSTIC_LOGICS_MODULE,
74
- [USE_SERVER_COMPONENTS]: SERVER_COMPONENTS_MODULE,
75
- [USE_CLIENT_COMPONENTS]: CLIENT_COMPONENTS_MODULE,
76
- [USE_AGNOSTIC_COMPONENTS]: AGNOSTIC_COMPONENTS_MODULE,
77
- [USE_SERVER_FUNCTIONS]: SERVER_FUNCTIONS_MODULE,
78
- [USE_CLIENT_CONTEXTS]: CLIENT_CONTEXTS_MODULE,
79
- [USE_AGNOSTIC_CONDITIONS]: AGNOSTIC_CONDITIONS_MODULE,
80
- [USE_AGNOSTIC_STRATEGIES]: AGNOSTIC_STRATEGIES_MODULE,
81
- });
82
-
83
56
  // commented strategies
84
- const AT_SERVER_LOGICS = "@serverLogics";
85
- const AT_CLIENT_LOGICS = "@clientLogics";
86
- const AT_AGNOSTIC_LOGICS = "@agnosticLogics";
87
- const AT_SERVER_COMPONENTS = "@serverComponents";
88
- const AT_CLIENT_COMPONENTS = "@clientComponents";
89
- const AT_AGNOSTIC_COMPONENTS = "@agnosticComponents";
90
- const AT_SERVER_FUNCTIONS = "@serverFunctions";
91
- const AT_CLIENT_CONTEXTS = "@clientContexts";
92
- const AT_AGNOSTIC_CONDITIONS = "@agnosticConditions";
57
+ export const AT_SERVER_LOGICS = "@serverLogics";
58
+ export const AT_CLIENT_LOGICS = "@clientLogics";
59
+ export const AT_AGNOSTIC_LOGICS = "@agnosticLogics";
60
+ export const AT_SERVER_COMPONENTS = "@serverComponents";
61
+ export const AT_CLIENT_COMPONENTS = "@clientComponents";
62
+ export const AT_AGNOSTIC_COMPONENTS = "@agnosticComponents";
63
+ export const AT_SERVER_FUNCTIONS = "@serverFunctions";
64
+ export const AT_CLIENT_CONTEXTS = "@clientContexts";
65
+ export const AT_AGNOSTIC_CONDITIONS = "@agnosticConditions";
93
66
 
94
67
  // commented strategies array
95
- /** @type {readonly [AT_SERVER_LOGICS, AT_CLIENT_LOGICS, AT_AGNOSTIC_LOGICS, AT_SERVER_COMPONENTS, AT_CLIENT_COMPONENTS, AT_AGNOSTIC_COMPONENTS, AT_SERVER_FUNCTIONS, AT_CLIENT_CONTEXTS, AT_AGNOSTIC_CONDITIONS]} */
68
+ /** @type {CommentedStrategies} */
96
69
  export const strategiesArray = [
97
70
  AT_SERVER_LOGICS,
98
71
  AT_CLIENT_LOGICS,
@@ -106,11 +79,11 @@ export const strategiesArray = [
106
79
  ];
107
80
 
108
81
  // commented strategies set
109
- /** @type {ReadonlySet<AT_SERVER_LOGICS | AT_CLIENT_LOGICS | AT_AGNOSTIC_LOGICS | AT_SERVER_COMPONENTS | AT_CLIENT_COMPONENTS | AT_AGNOSTIC_COMPONENTS | AT_SERVER_FUNCTIONS | AT_CLIENT_CONTEXTS | AT_AGNOSTIC_CONDITIONS>} */
82
+ /** @type {ReadonlySet<CommentedStrategy>} */
110
83
  export const strategiesSet = new Set(strategiesArray); // no longer used exported to satisfy static type inference
111
84
 
112
85
  // mapped commented strategies to their commented directives
113
- export const commentedStrategies_CommentedDirectives = Object.freeze({
86
+ export const commentedStrategies_commentedDirectives = Object.freeze({
114
87
  [AT_SERVER_LOGICS]: USE_SERVER_LOGICS,
115
88
  [AT_CLIENT_LOGICS]: USE_CLIENT_LOGICS,
116
89
  [AT_AGNOSTIC_LOGICS]: USE_AGNOSTIC_LOGICS,
@@ -141,7 +114,7 @@ const commentStyles = [
141
114
 
142
115
  /**
143
116
  * Makes the array of all four accepted commented directive implementations on a directive basis.
144
- * @param {USE_SERVER_LOGICS | USE_CLIENT_LOGICS | USE_AGNOSTIC_LOGICS | USE_SERVER_COMPONENTS | USE_CLIENT_COMPONENTS | USE_AGNOSTIC_COMPONENTS | USE_SERVER_FUNCTIONS | USE_CLIENT_CONTEXTS | USE_AGNOSTIC_CONDITIONS | USE_AGNOSTIC_STRATEGIES} directive The commented directive.
117
+ * @param {CommentedDirective} directive The commented directive.
145
118
  * @returns The array of formatted commented directives.
146
119
  */
147
120
  const make4RawImplementations = (directive) =>
@@ -163,7 +136,7 @@ export const commentedDirectives_4RawImplementations = Object.freeze({
163
136
  [USE_AGNOSTIC_STRATEGIES]: make4RawImplementations(USE_AGNOSTIC_STRATEGIES),
164
137
  });
165
138
 
166
- /* commentedDirectives_VerificationReports */
139
+ /* commentedDirectives_verificationReports */
167
140
 
168
141
  const MODULES_MARKED_WITH_THE_ = "modules marked with the";
169
142
  const _DIRECTIVE_MUST_HAVE_A_NON_JSX_FILE_EXTENSION =
@@ -171,7 +144,7 @@ const _DIRECTIVE_MUST_HAVE_A_NON_JSX_FILE_EXTENSION =
171
144
  const _DIRECTIVE_MUST_HAVE_A_JSX_FILE_EXTENSION =
172
145
  "directive must have a JSX file extension";
173
146
 
174
- export const commentedDirectives_VerificationReports = Object.freeze({
147
+ export const commentedDirectives_verificationReports = Object.freeze({
175
148
  // somehow doing it by hand is better for type inference in raw JS
176
149
  [USE_SERVER_LOGICS]: `${MODULES_MARKED_WITH_THE_} "${USE_SERVER_LOGICS}" ${_DIRECTIVE_MUST_HAVE_A_NON_JSX_FILE_EXTENSION}.`,
177
150
  [USE_CLIENT_LOGICS]: `${MODULES_MARKED_WITH_THE_} "${USE_CLIENT_LOGICS}" ${_DIRECTIVE_MUST_HAVE_A_NON_JSX_FILE_EXTENSION}.`,
@@ -185,12 +158,12 @@ export const commentedDirectives_VerificationReports = Object.freeze({
185
158
  [USE_AGNOSTIC_STRATEGIES]: `${MODULES_MARKED_WITH_THE_} "${USE_AGNOSTIC_STRATEGIES}" directive are free to have the file extension of their choosing. (This is not a problem and should never surface.)`,
186
159
  });
187
160
 
188
- /* commentedDirectives_BlockedImports */
161
+ /* commentedDirectives_blockedImports */
189
162
 
190
163
  /**
191
164
  * Makes the intro for each specific import rule violation messages.
192
- * @param {USE_SERVER_LOGICS | USE_CLIENT_LOGICS | USE_AGNOSTIC_LOGICS | USE_SERVER_COMPONENTS | USE_CLIENT_COMPONENTS | USE_AGNOSTIC_COMPONENTS | USE_SERVER_FUNCTIONS | USE_CLIENT_CONTEXTS | USE_AGNOSTIC_CONDITIONS | USE_AGNOSTIC_STRATEGIES} currentFileCommentedDirective The current file's commented directive.
193
- * @param {USE_SERVER_LOGICS | USE_CLIENT_LOGICS | USE_AGNOSTIC_LOGICS | USE_SERVER_COMPONENTS | USE_CLIENT_COMPONENTS | USE_AGNOSTIC_COMPONENTS | USE_SERVER_FUNCTIONS | USE_CLIENT_CONTEXTS | USE_AGNOSTIC_CONDITIONS} importedFileCommentedDirective The imported file's commented directive.
165
+ * @param {CommentedDirective} currentFileCommentedDirective The current file's commented directive.
166
+ * @param {CommentedDirectiveWithoutUseAgnosticStrategies} importedFileCommentedDirective The imported file's commented directive.
194
167
  * @returns "[Current file commented modules] are not allowed to import [imported file commented modules]."
195
168
  */
196
169
  const makeIntroForSpecificViolationMessage = (
@@ -198,12 +171,12 @@ const makeIntroForSpecificViolationMessage = (
198
171
  importedFileCommentedDirective
199
172
  ) =>
200
173
  commonsMakeIntroForSpecificViolationMessage(
201
- commentedDirectives_CommentedModules,
174
+ commentedDirectives_commentedModules,
202
175
  currentFileCommentedDirective,
203
176
  importedFileCommentedDirective
204
177
  );
205
178
 
206
- export const commentedDirectives_BlockedImports = Object.freeze({
179
+ export const commentedDirectives_blockedImports = Object.freeze({
207
180
  [USE_SERVER_LOGICS]: [
208
181
  // USE_SERVER_LOGICS allowed, because Prime Server Logics can compose with one another.
209
182
  {
@@ -20,7 +20,11 @@ import {
20
20
  allExportsFlow,
21
21
  } from "../utilities/flows.js";
22
22
 
23
- /** @type {import('@typescript-eslint/utils').TSESLint.RuleModule<typeof reExportNotSameMessageId | typeof importBreaksCommentedImportRulesMessageId | typeof noCommentedDirective | typeof commentedDirectiveVerificationFailed | typeof importNotStrategized | typeof exportNotStrategized, []>} */
23
+ /**
24
+ * @typedef {import('../../../../types/directive21/_commons/typedefs.js').Rule} Rule
25
+ */
26
+
27
+ /** @type {Rule} */
24
28
  const rule = {
25
29
  meta: {
26
30
  type: "problem",
@@ -7,20 +7,11 @@ import {
7
7
  noCommentedDirective,
8
8
  commentedDirectiveVerificationFailed,
9
9
  importNotStrategized,
10
- exportNotStrategized,
10
+ skip,
11
11
  } from "../../../_commons/constants/bases.js";
12
12
  import {
13
- USE_SERVER_LOGICS,
14
- USE_CLIENT_LOGICS,
15
- USE_AGNOSTIC_LOGICS,
16
- USE_SERVER_COMPONENTS,
17
- USE_CLIENT_COMPONENTS,
18
- USE_AGNOSTIC_COMPONENTS,
19
- USE_SERVER_FUNCTIONS,
20
- USE_CLIENT_CONTEXTS,
21
- USE_AGNOSTIC_CONDITIONS,
22
13
  USE_AGNOSTIC_STRATEGIES,
23
- commentedDirectives_VerificationReports,
14
+ commentedDirectives_verificationReports,
24
15
  // currentFileCommentedDirective,
25
16
  // importedFileCommentedDirective,
26
17
  commentedDirectiveMessage,
@@ -43,14 +34,25 @@ import {
43
34
  addressDirectiveIfAgnosticStrategies,
44
35
  } from "./helpers.js";
45
36
 
37
+ /**
38
+ * @typedef {import('../../../../types/directive21/_commons/typedefs.js').Context} Context
39
+ * @typedef {import('../../../../types/directive21/_commons/typedefs.js').CommentedDirective} CommentedDirective
40
+ * @typedef {import('../../../../types/directive21/_commons/typedefs.js').ImportDeclaration} ImportDeclaration
41
+ * @typedef {import('../../../../types/directive21/_commons/typedefs.js').ExportNamedDeclaration} ExportNamedDeclaration
42
+ * @typedef {import('../../../../types/directive21/_commons/typedefs.js').ExportAllDeclaration} ExportAllDeclaration
43
+ * @typedef {import('../../../../types/directive21/_commons/typedefs.js').ExportDefaultDeclaration} ExportDefaultDeclaration
44
+ */
45
+
46
46
  /* currentFileFlow */
47
47
 
48
48
  /**
49
49
  * The flow that begins the import rules enforcement rule, retrieving the valid directive of the current file before comparing it to upcoming valid directives of the files it imports.
50
- * @param {Readonly<import('@typescript-eslint/utils').TSESLint.RuleContext<typeof reExportNotSameMessageId | typeof importBreaksCommentedImportRulesMessageId | typeof noCommentedDirective | typeof commentedDirectiveVerificationFailed | typeof importNotStrategized | typeof exportNotStrategized, []>>} context The ESLint rule's `context` object.
51
- * @returns {{skip: true; verifiedCommentedDirective: undefined;} | {skip: undefined; verifiedCommentedDirective: USE_SERVER_LOGICS | USE_CLIENT_LOGICS | USE_AGNOSTIC_LOGICS | USE_SERVER_COMPONENTS | USE_CLIENT_COMPONENTS | USE_AGNOSTIC_COMPONENTS | USE_SERVER_FUNCTIONS | USE_CLIENT_CONTEXTS | USE_AGNOSTIC_CONDITIONS | USE_AGNOSTIC_STRATEGIES;}} Either an object with `skip: true` to disregard or one with the non-null `verifiedCommentedDirective`.
50
+ * @param {Context} context The ESLint rule's `context` object.
51
+ * @returns Either an object with `skip: true` to disregard or one with the non-null `verifiedCommentedDirective`. ()
52
52
  */
53
53
  export const currentFileFlow = (context) => {
54
+ const skipTrue = { ...skip, verifiedCommentedDirective: undefined };
55
+
54
56
  // GETTING THE EXTENSION OF THE CURRENT FILE
55
57
  const currentFileExtension = path.extname(context.filename);
56
58
 
@@ -62,7 +64,7 @@ export const currentFileFlow = (context) => {
62
64
  console.error(
63
65
  "ERROR. Linted files for this rule should only be in JavaScript (TypeScript)."
64
66
  );
65
- return { skip: true };
67
+ return skipTrue;
66
68
  }
67
69
 
68
70
  // gets the commented directive from the current file
@@ -74,7 +76,7 @@ export const currentFileFlow = (context) => {
74
76
  loc: highlightFirstLineOfCode(context),
75
77
  messageId: noCommentedDirective,
76
78
  });
77
- return { skip: true };
79
+ return skipTrue;
78
80
  }
79
81
 
80
82
  const verifiedCommentedDirective = getVerifiedCommentedDirective(
@@ -89,24 +91,26 @@ export const currentFileFlow = (context) => {
89
91
  messageId: commentedDirectiveVerificationFailed,
90
92
  data: {
91
93
  [specificFailure]:
92
- commentedDirectives_VerificationReports[commentedDirective],
94
+ commentedDirectives_verificationReports[commentedDirective],
93
95
  },
94
96
  });
95
- return { skip: true };
97
+ return skipTrue;
96
98
  }
97
99
 
98
- return { verifiedCommentedDirective };
100
+ return { skip: undefined, verifiedCommentedDirective };
99
101
  };
100
102
 
101
103
  /* importedFileFlow */
102
104
 
103
105
  /**
104
106
  * The flow that is shared between import and re-export traversals to obtain the import file's commented directive.
105
- * @param {Readonly<import('@typescript-eslint/utils').TSESLint.RuleContext<typeof reExportNotSameMessageId | typeof importBreaksCommentedImportRulesMessageId | typeof noCommentedDirective | typeof commentedDirectiveVerificationFailed | typeof importNotStrategized | typeof exportNotStrategized, []>>} context The ESLint rule's `context` object.
106
- * @param {import('@typescript-eslint/types').TSESTree.ImportDeclaration} node The ESLint `node` of the rule's current traversal.
107
- * @returns {{skip: true; importedFileCommentedDirective: undefined;} | {skip: undefined; importedFileCommentedDirective: USE_SERVER_LOGICS | USE_CLIENT_LOGICS | USE_AGNOSTIC_LOGICS | USE_SERVER_COMPONENTS | USE_CLIENT_COMPONENTS | USE_AGNOSTIC_COMPONENTS | USE_SERVER_FUNCTIONS | USE_CLIENT_CONTEXTS | USE_AGNOSTIC_CONDITIONS;}} Either an object with `skip: true` to disregard or one with the non-null `importedFileCommentedDirective`.
107
+ * @param {Context} context The ESLint rule's `context` object.
108
+ * @param {ImportDeclaration} node The ESLint `node` of the rule's current traversal.
109
+ * @returns Either an object with `skip: true` to disregard or one with the non-null `importedFileCommentedDirective`.
108
110
  */
109
111
  const importedFileFlow = (context, node) => {
112
+ const skipTrue = { ...skip, importedFileCommentedDirective: undefined };
113
+
110
114
  // finds the full path of the import
111
115
  const resolvedImportPath = resolveImportPath(
112
116
  path.dirname(context.filename),
@@ -115,12 +119,12 @@ const importedFileFlow = (context, node) => {
115
119
  );
116
120
 
117
121
  // does not operate on paths it did not resolve
118
- if (resolvedImportPath === null) return { skip: true };
122
+ if (resolvedImportPath === null) return skipTrue;
119
123
  // does not operate on non-JS files
120
124
  const isImportedFileJS = EXTENSIONS.some((ext) =>
121
125
  resolvedImportPath.endsWith(ext)
122
126
  );
123
- if (!isImportedFileJS) return { skip: true };
127
+ if (!isImportedFileJS) return skipTrue;
124
128
 
125
129
  /* GETTING THE DIRECTIVE (or lack thereof) OF THE IMPORTED FILE */
126
130
  let importedFileCommentedDirective =
@@ -131,7 +135,7 @@ const importedFileFlow = (context, node) => {
131
135
  console.warn(
132
136
  "WARNING. The imported file, whose path has been resolved, has no directive. It is thus ignored since the report on that circumstance is available on the imported file itself."
133
137
  );
134
- return { skip: true };
138
+ return skipTrue;
135
139
  }
136
140
 
137
141
  /* GETTING THE CORRECT DIRECTIVE INTERPRETATION OF STRATEGY FOR AGNOSTIC STRATEGIES MODULES IMPORTS.
@@ -155,20 +159,20 @@ const importedFileFlow = (context, node) => {
155
159
  node,
156
160
  messageId: importNotStrategized,
157
161
  });
158
- return { skip: true };
162
+ return skipTrue;
159
163
  }
160
164
  }
161
165
 
162
- return { importedFileCommentedDirective };
166
+ return { skip: undefined, importedFileCommentedDirective };
163
167
  };
164
168
 
165
169
  /* importsFlow */
166
170
 
167
171
  /**
168
172
  * The full flow for import traversals to enforce effective directives import rules.
169
- * @param {Readonly<import('@typescript-eslint/utils').TSESLint.RuleContext<typeof reExportNotSameMessageId | typeof importBreaksCommentedImportRulesMessageId | typeof noCommentedDirective | typeof commentedDirectiveVerificationFailed | typeof importNotStrategized | typeof exportNotStrategized, []>>} context The ESLint rule's `context` object.
170
- * @param {import('@typescript-eslint/types').TSESTree.ImportDeclaration} node The ESLint `node` of the rule's current traversal.
171
- * @param {USE_SERVER_LOGICS | USE_CLIENT_LOGICS | USE_AGNOSTIC_LOGICS | USE_SERVER_COMPONENTS | USE_CLIENT_COMPONENTS | USE_AGNOSTIC_COMPONENTS | USE_SERVER_FUNCTIONS | USE_CLIENT_CONTEXTS | USE_AGNOSTIC_CONDITIONS | USE_AGNOSTIC_STRATEGIES} currentFileCommentedDirective The current file's commented directive.
173
+ * @param {Context} context The ESLint rule's `context` object.
174
+ * @param {ImportDeclaration} node The ESLint `node` of the rule's current traversal.
175
+ * @param {CommentedDirective} currentFileCommentedDirective The current file's commented directive.
172
176
  * @returns Early if the flow needs to be interrupted.
173
177
  */
174
178
  export const importsFlow = (context, node, currentFileCommentedDirective) => {
@@ -206,9 +210,9 @@ export const importsFlow = (context, node, currentFileCommentedDirective) => {
206
210
 
207
211
  /**
208
212
  * The full flow for export traversals, shared between `ExportNamedDeclaration`, `ExportAllDeclaration`, and `ExportDefaultDeclaration`, to ensure same commented directive re-exports in modules that aren't Agnostic Strategies Modules, and enforce strategized exports specifically in Agnostic Strategies Modules.
209
- * @param {Readonly<import('@typescript-eslint/utils').TSESLint.RuleContext<typeof reExportNotSameMessageId | typeof importBreaksCommentedImportRulesMessageId | typeof noCommentedDirective | typeof commentedDirectiveVerificationFailed | typeof importNotStrategized | typeof exportNotStrategized, []>>} context The ESLint rule's `context` object.
210
- * @param {import('@typescript-eslint/types').TSESTree.ExportNamedDeclaration | import('@typescript-eslint/types').TSESTree.ExportAllDeclaration | import('@typescript-eslint/types').TSESTree.ExportDefaultDeclaration} node The ESLint `node` of the rule's current traversal.
211
- * @param {USE_SERVER_LOGICS | USE_CLIENT_LOGICS | USE_AGNOSTIC_LOGICS | USE_SERVER_COMPONENTS | USE_CLIENT_COMPONENTS | USE_AGNOSTIC_COMPONENTS | USE_SERVER_FUNCTIONS | USE_CLIENT_CONTEXTS | USE_AGNOSTIC_CONDITIONS | USE_AGNOSTIC_STRATEGIES} currentFileCommentedDirective The current file's commented directive.
213
+ * @param {Context} context The ESLint rule's `context` object.
214
+ * @param {ExportNamedDeclaration | ExportAllDeclaration | ExportDefaultDeclaration} node The ESLint `node` of the rule's current traversal.
215
+ * @param {CommentedDirective} currentFileCommentedDirective The current file's commented directive.
212
216
  * @returns Early if the flow needs to be interrupted.
213
217
  */
214
218
  export const allExportsFlow = (