eslint-plugin-use-agnostic 1.2.2 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -31,9 +31,9 @@ import {
31
31
  /* getCommentedDirectiveFromSourceCode */
32
32
 
33
33
  /**
34
- * Detects whether a string is single- or double-quoted.
35
- * @param {string} string The original string.
36
- * @returns `true` if single-quoted, `false` if double-quoted, `null` if neither.
34
+ * $COMMENT#JSDOC#DEFINITIONS#DIRECTIVE21#DETECTQUOTETYPE
35
+ * @param {string} string $COMMENT#JSDOC#PARAMS#DIRECTIVE21#STRING
36
+ * @returns $COMMENT#JSDOC#RETURNS#DIRECTIVE21#DETECTQUOTETYPE
37
37
  */
38
38
  const detectQuoteType = (string) => {
39
39
  if (string.startsWith("'") && string.endsWith("'")) {
@@ -46,9 +46,9 @@ const detectQuoteType = (string) => {
46
46
  };
47
47
 
48
48
  /**
49
- * Removes single quotes from a string known to be single-quoted.
50
- * @param {string} string The original string.
51
- * @returns The string with quotes removed.
49
+ * $COMMENT#JSDOC#DEFINITIONS#DIRECTIVE21#STRIPSINGLEQUOTES
50
+ * @param {string} string $COMMENT#JSDOC#PARAMS#DIRECTIVE21#STRING
51
+ * @returns $COMMENT#JSDOC#RETURNS#DIRECTIVE21#STRIPSINGLEQUOTES
52
52
  */
53
53
  const stripSingleQuotes = (string) => {
54
54
  if (string.startsWith("'") && string.endsWith("'")) {
@@ -58,9 +58,9 @@ const stripSingleQuotes = (string) => {
58
58
  };
59
59
 
60
60
  /**
61
- * Removes double quotes from a string known to be double-quoted.
62
- * @param {string} string The original string.
63
- * @returns The string with quotes removed.
61
+ * $COMMENT#JSDOC#DEFINITIONS#DIRECTIVE21#STRIPDOUBLEQUOTES
62
+ * @param {string} string $COMMENT#JSDOC#PARAMS#DIRECTIVE21#STRING
63
+ * @returns $COMMENT#JSDOC#RETURNS#DIRECTIVE21#STRIPSINGLEQUOTES
64
64
  */
65
65
  const stripDoubleQuotes = (string) => {
66
66
  if (string.startsWith('"') && string.endsWith('"')) {
@@ -70,21 +70,21 @@ const stripDoubleQuotes = (string) => {
70
70
  };
71
71
 
72
72
  /**
73
- * Gets the commented directive of a module from its ESLint SourceCode object.
73
+ * $COMMENT#JSDOC#DEFINITIONS#DIRECTIVE21#GETCOMMENTEDDIRECTIVEFROMSOURCECODE1
74
74
  *
75
- * Accepted directives for the default Directive-First Architecture are (single or double quotes included):
76
- * - `'use server logics'`, `"use server logics"` denoting a Server Logics Module.
77
- * - `'use client logics'`, `"use client logics"` denoting a Client Logics Module.
78
- * - `'use agnostic logics'`, `"use agnostic logics"` denoting an Agnostic Logics Module.
79
- * - `'use server components'`, `"use server components"` denoting a Server Components Module.
80
- * - `'use client components'`, `"use client components"` denoting a Client Components Module.
81
- * - `'use agnostic components'`, `"use agnostic components"` denoting an Agnostic Components Module.
82
- * - `'use server functions'`, `"use server functions"` denoting a Server Functions Module.
83
- * - `'use client contexts'`, `"use client contexts"` denoting a Client Contexts Module.
84
- * - `'use agnostic conditions'`, `"use agnostic conditions"` denoting an Agnostic Conditions Module.
85
- * - `'use agnostic strategies'`, `"use agnostic strategies"` denoting an Agnostic Strategies Module.
86
- * @param {SourceCode} sourceCode The ESLint SourceCode object.
87
- * @returns The commented directive, or lack thereof via `null`. Given the strictness of this architecture, the lack of a directive is considered a mistake. (Though rules may provide the opportunity to declare a default, and configs with preset defaults may become provided.)
75
+ * $COMMENT#JSDOC#DEFINITIONS#DIRECTIVE21#GETCOMMENTEDDIRECTIVEFROMSOURCECODE2
76
+ * - $COMMENT#JSDOC#DETAILS#DIRECTIVE21#USESERVERLOGICSA
77
+ * - $COMMENT#JSDOC#DETAILS#DIRECTIVE21#USECLIENTLOGICSA
78
+ * - $COMMENT#JSDOC#DETAILS#DIRECTIVE21#USEAGNOSTICLOGICSA
79
+ * - $COMMENT#JSDOC#DETAILS#DIRECTIVE21#USESERVERCOMPONENTSA
80
+ * - $COMMENT#JSDOC#DETAILS#DIRECTIVE21#USECLIENTCOMPONENTSA
81
+ * - $COMMENT#JSDOC#DETAILS#DIRECTIVE21#USEAGNOSTICCOMPONENTSA
82
+ * - $COMMENT#JSDOC#DETAILS#DIRECTIVE21#USESERVERFUNCTIONSA
83
+ * - $COMMENT#JSDOC#DETAILS#DIRECTIVE21#USECLIENTCONTEXTSA
84
+ * - $COMMENT#JSDOC#DETAILS#DIRECTIVE21#USEAGNOSTICCONDITIONSA
85
+ * - $COMMENT#JSDOC#DETAILS#DIRECTIVE21#USEAGNOSTICSTRATEGIESA
86
+ * @param {SourceCode} sourceCode $COMMENT#JSDOC#PARAMS#DIRECTIVE21#SOURCECODE
87
+ * @returns $COMMENT#JSDOC#RETURNS#DIRECTIVE21#GETCOMMENTEDDIRECTIVEFROMSOURCECODE
88
88
  */
89
89
  export const getCommentedDirectiveFromSourceCode = (sourceCode) => {
90
90
  // gets the first comment from the source code
@@ -128,21 +128,21 @@ export const getCommentedDirectiveFromSourceCode = (sourceCode) => {
128
128
  /* getCommentedDirectiveFromCurrentModule */
129
129
 
130
130
  /**
131
- * Gets the commented directive of the current module.
131
+ * $COMMENT#JSDOC#DEFINITIONS#DIRECTIVE21#GETCOMMENTEDDIRECTIVEFROMCURRENTMODULE1
132
132
  *
133
- * Accepted directives for the default Directive-First Architecture are (single or double quotes included):
134
- * - `'use server logics'`, `"use server logics"` denoting a Server Logics Module.
135
- * - `'use client logics'`, `"use client logics"` denoting a Client Logics Module.
136
- * - `'use agnostic logics'`, `"use agnostic logics"` denoting an Agnostic Logics Module.
137
- * - `'use server components'`, `"use server components"` denoting a Server Components Module.
138
- * - `'use client components'`, `"use client components"` denoting a Client Components Module.
139
- * - `'use agnostic components'`, `"use agnostic components"` denoting an Agnostic Components Module.
140
- * - `'use server functions'`, `"use server functions"` denoting a Server Functions Module.
141
- * - `'use client contexts'`, `"use client contexts"` denoting a Client Contexts Module.
142
- * - `'use agnostic conditions'`, `"use agnostic conditions"` denoting an Agnostic Conditions Module.
143
- * - `'use agnostic strategies'`, `"use agnostic strategies"` denoting an Agnostic Strategies Module.
144
- * @param {Context} context The ESLint rule's `context` object.
145
- * @returns The commented directive, or lack thereof via `null`. Given the strictness of this architecture, the lack of a directive is considered a mistake. (Though rules may provide the opportunity to declare a default, and configs with preset defaults may become provided.)
133
+ * $COMMENT#JSDOC#DEFINITIONS#DIRECTIVE21#GETCOMMENTEDDIRECTIVEFROMSOURCECODE2
134
+ * - $COMMENT#JSDOC#DETAILS#DIRECTIVE21#USESERVERLOGICSA
135
+ * - $COMMENT#JSDOC#DETAILS#DIRECTIVE21#USECLIENTLOGICSA
136
+ * - $COMMENT#JSDOC#DETAILS#DIRECTIVE21#USEAGNOSTICLOGICSA
137
+ * - $COMMENT#JSDOC#DETAILS#DIRECTIVE21#USESERVERCOMPONENTSA
138
+ * - $COMMENT#JSDOC#DETAILS#DIRECTIVE21#USECLIENTCOMPONENTSA
139
+ * - $COMMENT#JSDOC#DETAILS#DIRECTIVE21#USEAGNOSTICCOMPONENTSA
140
+ * - $COMMENT#JSDOC#DETAILS#DIRECTIVE21#USESERVERFUNCTIONSA
141
+ * - $COMMENT#JSDOC#DETAILS#DIRECTIVE21#USECLIENTCONTEXTSA
142
+ * - $COMMENT#JSDOC#DETAILS#DIRECTIVE21#USEAGNOSTICCONDITIONSA
143
+ * - $COMMENT#JSDOC#DETAILS#DIRECTIVE21#USEAGNOSTICSTRATEGIESA
144
+ * @param {Context} context $COMMENT#JSDOC#PARAMS#CONTEXTB
145
+ * @returns $COMMENT#JSDOC#RETURNS#DIRECTIVE21#GETCOMMENTEDDIRECTIVEFROMSOURCECODE
146
146
  */
147
147
  export const getCommentedDirectiveFromCurrentModule = (context) => {
148
148
  const sourceCode = context.sourceCode;
@@ -154,21 +154,21 @@ export const getCommentedDirectiveFromCurrentModule = (context) => {
154
154
  /* getCommentedDirectiveFromImportedModule */
155
155
 
156
156
  /**
157
- * Gets the commented directive of the imported module.
157
+ * $COMMENT#JSDOC#DEFINITIONS#DIRECTIVE21#GETCOMMENTEDDIRECTIVEFROMIMPORTEDMODULE1
158
158
  *
159
- * Accepted directives for the default Directive-First Architecture are (single or double quotes included):
160
- * - `'use server logics'`, `"use server logics"` denoting a Server Logics Module.
161
- * - `'use client logics'`, `"use client logics"` denoting a Client Logics Module.
162
- * - `'use agnostic logics'`, `"use agnostic logics"` denoting an Agnostic Logics Module.
163
- * - `'use server components'`, `"use server components"` denoting a Server Components Module.
164
- * - `'use client components'`, `"use client components"` denoting a Client Components Module.
165
- * - `'use agnostic components'`, `"use agnostic components"` denoting an Agnostic Components Module.
166
- * - `'use server functions'`, `"use server functions"` denoting a Server Functions Module.
167
- * - `'use client contexts'`, `"use client contexts"` denoting a Client Contexts Module.
168
- * - `'use agnostic conditions'`, `"use agnostic conditions"` denoting an Agnostic Conditions Module.
169
- * - `'use agnostic strategies'`, `"use agnostic strategies"` denoting an Agnostic Strategies Module.
170
- * @param {string} resolvedPath The resolved path of the imported module.
171
- * @returns The commented directive, or lack thereof via `null`. Given the strictness of this architecture, the lack of a directive is considered a mistake. (Though rules may provide the opportunity to declare a default, and configs with preset defaults may become provided.)
159
+ * $COMMENT#JSDOC#DEFINITIONS#DIRECTIVE21#GETCOMMENTEDDIRECTIVEFROMSOURCECODE2
160
+ * - $COMMENT#JSDOC#DETAILS#DIRECTIVE21#USESERVERLOGICSA
161
+ * - $COMMENT#JSDOC#DETAILS#DIRECTIVE21#USECLIENTLOGICSA
162
+ * - $COMMENT#JSDOC#DETAILS#DIRECTIVE21#USEAGNOSTICLOGICSA
163
+ * - $COMMENT#JSDOC#DETAILS#DIRECTIVE21#USESERVERCOMPONENTSA
164
+ * - $COMMENT#JSDOC#DETAILS#DIRECTIVE21#USECLIENTCOMPONENTSA
165
+ * - $COMMENT#JSDOC#DETAILS#DIRECTIVE21#USEAGNOSTICCOMPONENTSA
166
+ * - $COMMENT#JSDOC#DETAILS#DIRECTIVE21#USESERVERFUNCTIONSA
167
+ * - $COMMENT#JSDOC#DETAILS#DIRECTIVE21#USECLIENTCONTEXTSA
168
+ * - $COMMENT#JSDOC#DETAILS#DIRECTIVE21#USEAGNOSTICCONDITIONSA
169
+ * - $COMMENT#JSDOC#DETAILS#DIRECTIVE21#USEAGNOSTICSTRATEGIESA
170
+ * @param {string} resolvedPath $COMMENT#JSDOC#PARAMS#RESOLVEDPATH
171
+ * @returns $COMMENT#JSDOC#RETURNS#DIRECTIVE21#GETCOMMENTEDDIRECTIVEFROMSOURCECODE
172
172
  */
173
173
  export const getCommentedDirectiveFromImportedModule = (resolvedPath) => {
174
174
  const sourceCode = getSourceCodeFromFilePath(resolvedPath);
@@ -180,20 +180,20 @@ export const getCommentedDirectiveFromImportedModule = (resolvedPath) => {
180
180
  /* getVerifiedCommentedDirective */
181
181
 
182
182
  /**
183
- * Ensures that a module's commented directive is consistent with its file extension (depending on whether it ends with 'x' for JSX).
184
- * - `'use server logics'`: Server Logics Modules do NOT export JSX.
185
- * - `'use client logics'`: Client Logics Modules do NOT export JSX.
186
- * - `'use agnostic logics'`: Agnostic Logics Modules do NOT export JSX.
187
- * - `'use server components'`: Server Components Modules ONLY export JSX.
188
- * - `'use client components'`: Client Components Modules ONLY export JSX.
189
- * - `'use agnostic components'`: Agnostic Components Modules ONLY export JSX.
190
- * - `'use server functions'`: Server Functions Modules do NOT export JSX.
191
- * - `'use client contexts'`: Client Contexts Modules ONLY export JSX.
192
- * - `'use agnostic conditions'`: Agnostic Conditions Modules ONLY export JSX.
193
- * - `'use agnostic strategies'`: Agnostic Strategies Modules may export JSX.
194
- * @param {CommentedDirective} directive The commented directive as written on top of the file (cannot be `null` at that stage).
195
- * @param {Extension} extension The JavaScript (TypeScript) extension of the file.
196
- * @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.
183
+ * $COMMENT#JSDOC#DEFINITIONS#DIRECTIVE21#GETVERIFIEDCOMMENTEDDIRECTIVE
184
+ * - $COMMENT#JSDOC#DETAILS#DIRECTIVE21#USESERVERLOGICSB
185
+ * - $COMMENT#JSDOC#DETAILS#DIRECTIVE21#USECLIENTLOGICSB
186
+ * - $COMMENT#JSDOC#DETAILS#DIRECTIVE21#USEAGNOSTICLOGICSB
187
+ * - $COMMENT#JSDOC#DETAILS#DIRECTIVE21#USESERVERCOMPONENTSB
188
+ * - $COMMENT#JSDOC#DETAILS#DIRECTIVE21#USECLIENTCOMPONENTSB
189
+ * - $COMMENT#JSDOC#DETAILS#DIRECTIVE21#USEAGNOSTICCOMPONENTSB
190
+ * - $COMMENT#JSDOC#DETAILS#DIRECTIVE21#USESERVERFUNCTIONSB
191
+ * - $COMMENT#JSDOC#DETAILS#DIRECTIVE21#USECLIENTCONTEXTSB
192
+ * - $COMMENT#JSDOC#DETAILS#DIRECTIVE21#USEAGNOSTICCONDITIONSB
193
+ * - $COMMENT#JSDOC#DETAILS#DIRECTIVE21#USEAGNOSTICSTRATEGIESB
194
+ * @param {CommentedDirective} directive $COMMENT#JSDOC#PARAMS#DIRECTIVE21#DIRECTIVE
195
+ * @param {Extension} extension $COMMENT#JSDOC#PARAMS#EXTENSION
196
+ * @returns $COMMENT#JSDOC#RETURNS#DIRECTIVE21#GETVERIFIEDCOMMENTEDDIRECTIVE
197
197
  */
198
198
  export const getVerifiedCommentedDirective = (directive, extension) => {
199
199
  const rule = commentedDirectives_extensionRules[directive];
@@ -209,10 +209,10 @@ export const getVerifiedCommentedDirective = (directive, extension) => {
209
209
  /* getStrategizedDirective */
210
210
 
211
211
  /**
212
- * Gets the interpreted directive from a specified commented Strategy (such as `@serverLogics`) nested inside the import declaration for an import from an Agnostic Strategies Module.
213
- * @param {Context} context The ESLint rule's `context` object.
214
- * @param {ImportDeclaration} node The ESLint `node` of the rule's current traversal.
215
- * @returns The interpreted directive, a.k.a. strategized directive, or lack thereof via `null`.
212
+ * $COMMENT#JSDOC#DEFINITIONS#DIRECTIVE21#GETSTRATEGIZEDDIRECTIVE
213
+ * @param {Context} context $COMMENT#JSDOC#PARAMS#CONTEXTB
214
+ * @param {ImportDeclaration} node $COMMENT#JSDOC#PARAMS#NODE
215
+ * @returns $COMMENT#JSDOC#RETURNS#DIRECTIVE21#GETSTRATEGIZEDDIRECTIVE
216
216
  */
217
217
  export const getStrategizedDirective = (context, node) => {
218
218
  // gets the first nested `/* */` comment inside the node
@@ -240,18 +240,18 @@ export const getStrategizedDirective = (context, node) => {
240
240
  /* addressDirectiveIfAgnosticStrategies */
241
241
 
242
242
  /**
243
- * Verifies the current node's export strategy if the current commented directive is `"use agnostic strategies"` by reporting `exportNotStrategized` in case an export is not strategized in an Agnostic Strategies Module.
244
- * @param {Context} context The ESLint rule's `context` object.
245
- * @param {ExportNamedDeclaration | ExportAllDeclaration | ExportDefaultDeclaration} node The ESLint `node` of the rule's current traversal.
246
- * @param {CommentedDirective} currentFileCommentedDirective The current file's commented directive.
247
- * @returns The commented directive, the addressed strategy (as a commented directive) or `null` in case of failure.
243
+ * $COMMENT#JSDOC#DEFINITIONS#DIRECTIVE21#ADDRESSDIRECTIVEIFAGNOSTICSTRATEGIES
244
+ * @param {Context} context $COMMENT#JSDOC#PARAMS#CONTEXTB
245
+ * @param {ExportNamedDeclaration | ExportAllDeclaration | ExportDefaultDeclaration} node $COMMENT#JSDOC#PARAMS#NODE
246
+ * @param {CommentedDirective} currentFileCommentedDirective $COMMENT#JSDOC#PARAMS#DIRECTIVE21#CURRENTFILECOMMENTEDDIRECTIVE
247
+ * @returns $COMMENT#JSDOC#RETURNS#DIRECTIVE21#ADDRESSDIRECTIVEIFAGNOSTICSTRATEGIES
248
248
  */
249
249
  export const addressDirectiveIfAgnosticStrategies = (
250
250
  context,
251
251
  node,
252
252
  currentFileCommentedDirective
253
253
  ) => {
254
- // ignores if not addressing an Agnostic Strategies Module
254
+ // ignores if not addressing an Agnostic Strategies $COMMENT#TESTS#FORCOMPOSEDVARIABLES#MODULE
255
255
  if (currentFileCommentedDirective !== USE_AGNOSTIC_STRATEGIES)
256
256
  return currentFileCommentedDirective;
257
257
 
@@ -270,10 +270,10 @@ export const addressDirectiveIfAgnosticStrategies = (
270
270
  /* isImportBlocked */
271
271
 
272
272
  /**
273
- * Returns a boolean deciding if an imported file's commented directive is incompatible with the current file's commented directive.
274
- * @param {CommentedDirectiveWithoutUseAgnosticStrategies} currentFileCommentedDirective The current file's commented directive.
275
- * @param {CommentedDirectiveWithoutUseAgnosticStrategies} importedFileCommentedDirective The imported file's commented directive.
276
- * @returns `true` if the import is blocked, as established in `commentedDirectives_BlockedImports`.
273
+ * $COMMENT#JSDOC#DEFINITIONS#DIRECTIVE21#ISIMPORTBLOCKED
274
+ * @param {CommentedDirectiveWithoutUseAgnosticStrategies} currentFileCommentedDirective $COMMENT#JSDOC#PARAMS#DIRECTIVE21#CURRENTFILECOMMENTEDDIRECTIVE
275
+ * @param {CommentedDirectiveWithoutUseAgnosticStrategies} importedFileCommentedDirective $COMMENT#JSDOC#PARAMS#DIRECTIVE21#IMPORTEDFILECOMMENTEDDIRECTIVE
276
+ * @returns $COMMENT#JSDOC#RETURNS#DIRECTIVE21#ISIMPORTBLOCKED
277
277
  */
278
278
  export const isImportBlocked = (
279
279
  currentFileCommentedDirective,
@@ -288,9 +288,9 @@ export const isImportBlocked = (
288
288
  /* makeMessageFromCurrentFileCommentedDirective */
289
289
 
290
290
  /**
291
- * Lists in an message the commented modules incompatible with a commented module based on its commented directive.
292
- * @param {CommentedDirectiveWithoutUseAgnosticStrategies} commentedDirective The commented directive of the commented module.
293
- * @returns The message listing the incompatible commented modules.
291
+ * $COMMENT#JSDOC#DEFINITIONS#DIRECTIVE21#MAKEMESSAGEFROMCURRENTFILECOMMENTEDDIRECTIVE
292
+ * @param {CommentedDirectiveWithoutUseAgnosticStrategies} commentedDirective $COMMENT#JSDOC#PARAMS#DIRECTIVE21#COMMENTEDDIRECTIVE
293
+ * @returns $COMMENT#JSDOC#RETURNS#DIRECTIVE21#MAKEMESSAGEFROMCURRENTFILECOMMENTEDDIRECTIVE
294
294
  */
295
295
  export const makeMessageFromCurrentFileCommentedDirective = (
296
296
  commentedDirective
@@ -303,10 +303,10 @@ export const makeMessageFromCurrentFileCommentedDirective = (
303
303
  /* findSpecificViolationMessage */
304
304
 
305
305
  /**
306
- * Finds the `message` for the specific violation of commented directives import rules based on `commentedDirectives_BlockedImports`.
307
- * @param {CommentedDirectiveWithoutUseAgnosticStrategies} currentFileCommentedDirective The current file's commented directive.
308
- * @param {CommentedDirectiveWithoutUseAgnosticStrategies} importedFileCommentedDirective The imported file's commented directive.
309
- * @returns The corresponding `message`.
306
+ * $COMMENT#JSDOC#DEFINITIONS#DIRECTIVE21#FINDSPECIFICVIOLATIONMESSAGE
307
+ * @param {CommentedDirectiveWithoutUseAgnosticStrategies} currentFileCommentedDirective $COMMENT#JSDOC#PARAMS#DIRECTIVE21#CURRENTFILECOMMENTEDDIRECTIVE
308
+ * @param {CommentedDirectiveWithoutUseAgnosticStrategies} importedFileCommentedDirective $COMMENT#JSDOC#PARAMS#DIRECTIVE21#IMPORTEDFILECOMMENTEDDIRECTIVE
309
+ * @returns $COMMENT#JSDOC#RETURNS#FINDSPECIFICVIOLATIONMESSAGE
310
310
  */
311
311
  export const findSpecificViolationMessage = (
312
312
  currentFileCommentedDirective,
@@ -12,9 +12,9 @@ import {
12
12
  */
13
13
 
14
14
  /**
15
- * Makes the directive21 config for the use-agnostic ESLint plugin.
16
- * @param {Plugin} plugin The use-agnostic ESLint plugin itself.
17
- * @returns The directive21 config's name as a key and its config as its value.
15
+ * $COMMENT#JSDOC#DEFINITIONS#DIRECTIVE21#MAKEDIRECTIVE21CONFIG
16
+ * @param {Plugin} plugin $COMMENT#JSDOC#PARAMS#PLUGIN
17
+ * @returns $COMMENT#JSDOC#RETURNS#DIRECTIVE21#MAKEDIRECTIVE21CONFIG
18
18
  */
19
19
  export const makeDirective21Config = (plugin) => ({
20
20
  [directive21ConfigName]: defineConfig([
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-use-agnostic",
3
- "version": "1.2.2",
3
+ "version": "1.3.0",
4
4
  "description": "Highlights problematic server-client imports in projects made with the Fullstack React Architecture.",
5
5
  "keywords": [
6
6
  "eslint",
@@ -41,8 +41,9 @@
41
41
  "test": "node tests/agnostic20/import-rules.test.js && node tests/directive21/import-rules.test.js"
42
42
  },
43
43
  "dependencies": {
44
- "get-sourcecode-from-file-path": "^1.0.0",
45
- "resolve-importing-path": "^1.0.2",
44
+ "comment-variables-resolve-config": "^1.9.0",
45
+ "get-sourcecode-from-file-path": "^1.1.2",
46
+ "resolve-importing-path": "^1.0.3",
46
47
  "tsconfig-paths": "^4.2.0",
47
48
  "typescript-eslint": "^8.32.0"
48
49
  },
@@ -1,29 +0,0 @@
1
- import {
2
- serverLogicsComments,
3
- serverComponentsComments,
4
- serverFunctionsComments,
5
- clientLogicsComments,
6
- clientComponentsComments,
7
- agnosticLogicsComments,
8
- agnosticComponentsComments,
9
- } from "./modules-comments.js";
10
-
11
- import {
12
- USE_SERVER_LOGICS,
13
- USE_CLIENT_LOGICS,
14
- USE_AGNOSTIC_LOGICS,
15
- USE_SERVER_COMPONENTS,
16
- USE_CLIENT_COMPONENTS,
17
- USE_AGNOSTIC_COMPONENTS,
18
- USE_SERVER_FUNCTIONS,
19
- } from "../../../library/_commons/constants/bases.js";
20
-
21
- export const agnostic20Comments = Object.freeze({
22
- [USE_SERVER_LOGICS]: serverLogicsComments,
23
- [USE_SERVER_COMPONENTS]: serverComponentsComments,
24
- [USE_SERVER_FUNCTIONS]: serverFunctionsComments,
25
- [USE_CLIENT_LOGICS]: clientLogicsComments,
26
- [USE_CLIENT_COMPONENTS]: clientComponentsComments,
27
- [USE_AGNOSTIC_LOGICS]: agnosticLogicsComments,
28
- [USE_AGNOSTIC_COMPONENTS]: agnosticComponentsComments,
29
- });
@@ -1,143 +0,0 @@
1
- import {
2
- USE_SERVER_LOGICS,
3
- USE_CLIENT_LOGICS,
4
- USE_AGNOSTIC_LOGICS,
5
- USE_SERVER_COMPONENTS,
6
- USE_CLIENT_COMPONENTS,
7
- USE_AGNOSTIC_COMPONENTS,
8
- USE_SERVER_FUNCTIONS,
9
- } from "../../../library/_commons/constants/bases.js";
10
-
11
- export const serverLogicsComments = Object.freeze({
12
- // $COMMENT#AGNOSTIC20#USE_SERVER_LOGICS#USE_SERVER_LOGICS
13
- [USE_SERVER_LOGICS]:
14
- /* valid */ "Server Logics can compose with one another.",
15
- [USE_SERVER_COMPONENTS]:
16
- /* valid */ "Server Components are OK to be composed with Server Logics as long as the Server Logics Module, by convention, does not export React components.",
17
- [USE_SERVER_FUNCTIONS]:
18
- /* valid */ "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.)",
19
- [USE_CLIENT_LOGICS]:
20
- /* invalid */ "Client Logics should never leak to the server, such as would be the case here in a Server Logics Module.",
21
- [USE_CLIENT_COMPONENTS]:
22
- /* invalid */ "Client Components cannot be tinkered with on the server.",
23
- [USE_AGNOSTIC_LOGICS]:
24
- /* valid */ "Agnostic Logics can run safely on the server just like they can on the client, such as is the case here in a Server Logics Module.",
25
- [USE_AGNOSTIC_COMPONENTS]:
26
- /* valid */ "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.",
27
- module: "Server Logics Module",
28
- modulePeriod: "Server Logics Module.",
29
- });
30
-
31
- export const serverComponentsComments = Object.freeze({
32
- [USE_SERVER_LOGICS]:
33
- /* valid */ "Server Logics, being logic from the server, can safely support Server Components.",
34
- [USE_SERVER_COMPONENTS]:
35
- /* valid */ "Server Components can compose with one another, assuming thanks to the inclusion of the 'use agnostic' directive that they are actual Server Components.",
36
- [USE_SERVER_FUNCTIONS]:
37
- /* valid */ "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.",
38
- [USE_CLIENT_LOGICS]:
39
- /* invalid */ "Client Logics should never leak to the server, such as would be the case here in a Server Components Module.",
40
- [USE_CLIENT_COMPONENTS]:
41
- /* valid */ "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.",
42
- [USE_AGNOSTIC_LOGICS]:
43
- /* valid */ "Agnostic Logics can run safely on the server just like they can on the client, such as is the case here in a Server Components Module.",
44
- [USE_AGNOSTIC_COMPONENTS]:
45
- /* valid */ "Agnostic Components can render safely on the server just like they can on the client.",
46
- module: "Server Components Module",
47
- modulePeriod: "Server Components Module.",
48
- });
49
-
50
- export const serverFunctionsComments = Object.freeze({
51
- [USE_SERVER_LOGICS]:
52
- /* valid */ "Server Logics, being logic from the server, can safely support Server Functions.",
53
- [USE_SERVER_COMPONENTS]:
54
- /* invalid */ "Server Components aren't allowed because Server Functions have no business working with React Components.",
55
- [USE_SERVER_FUNCTIONS]:
56
- /* valid */ "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.)",
57
- [USE_CLIENT_LOGICS]:
58
- /* invalid */ "Client Logics should never leak to the server, such as would be the case here in a Server Functions Module.",
59
- [USE_CLIENT_COMPONENTS]:
60
- /* invalid */ "Client Components aren't allowed because Server Functions have no business working with React Components.",
61
- [USE_AGNOSTIC_LOGICS]:
62
- /* valid */ "Agnostic Logics can run safely on the server just like they can on the client, such as is the case here in a Server Functions Module.",
63
- [USE_AGNOSTIC_COMPONENTS]:
64
- /* invalid */ "Agnostic Components aren't allowed because Server Functions have no business working with React Components.",
65
- module: "Server Functions Module",
66
- modulePeriod: "Server Functions Module.",
67
- });
68
-
69
- export const clientLogicsComments = Object.freeze({
70
- [USE_SERVER_LOGICS]:
71
- /* invalid */ "Server Logics should never leak to the client, such as would be the case here in a Client Logics Module.",
72
- [USE_SERVER_COMPONENTS]:
73
- /* invalid */ "Server Components cannot be thinkered with on the client.",
74
- [USE_SERVER_FUNCTIONS]:
75
- /* valid */ "Server Functions can technically be attached to Client Components that are being tinkered with within Client Logics Modules.",
76
- [USE_CLIENT_LOGICS]:
77
- /* valid */ "Client Logics can compose with one another.",
78
- [USE_CLIENT_COMPONENTS]:
79
- /* valid */ "Client Components are OK to be composed with Client Logics as long as the Client Logics Module, by convention, does not export React components.",
80
- [USE_AGNOSTIC_LOGICS]:
81
- /* valid */ "Agnostic Logics can run safely on the client just like they can on the server, such as is the case here in a Client Logics Module.",
82
- [USE_AGNOSTIC_COMPONENTS]:
83
- /* valid */ "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.",
84
- module: "Client Logics Module",
85
- modulePeriod: "Client Logics Module.",
86
- });
87
-
88
- export const clientComponentsComments = Object.freeze({
89
- [USE_SERVER_LOGICS]:
90
- /* invalid */ "Server Logics should never leak to the client, such as would be the case here in a Client Components Module.",
91
- [USE_SERVER_COMPONENTS]:
92
- /* invalid */ "Server Components may only pass through Client Components via the children prop within Server Components Modules.",
93
- [USE_SERVER_FUNCTIONS]:
94
- /* valid */ "Server Functions are specifically triggered by Client Components.",
95
- [USE_CLIENT_LOGICS]:
96
- /* valid */ "Client Logics, being logic from the client, can safely support Client Components.",
97
- [USE_CLIENT_COMPONENTS]:
98
- /* valid */ "Client Components can compose with one another.",
99
- [USE_AGNOSTIC_LOGICS]:
100
- /* valid */ "Agnostic Logics can run safely on the client just like they can on the server, such as is the case here in a Client Components Module.",
101
- [USE_AGNOSTIC_COMPONENTS]:
102
- /* valid */ "Agnostic Components can render safely on the client just like they can on the server.",
103
- module: "Client Components Module",
104
- modulePeriod: "Client Components Module.",
105
- });
106
-
107
- export const agnosticLogicsComments = Object.freeze({
108
- [USE_SERVER_LOGICS]:
109
- /* invalid */ "Server Logics cannot run on both the server and the client, such as would be the case here in an Agnostic Logics Module.",
110
- [USE_SERVER_COMPONENTS]:
111
- /* invalid */ "Server Components cannot be tinkered with on both the server and the client.",
112
- [USE_SERVER_FUNCTIONS]:
113
- /* invalid */ "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.",
114
- [USE_CLIENT_LOGICS]:
115
- /* invalid */ "Client Logics cannot run on both the server and the client, such as would be the case here in an Agnostic Logics Module.",
116
- [USE_CLIENT_COMPONENTS]:
117
- /* invalid */ "Client Components cannot be tinkered with on both the server and the client.",
118
- [USE_AGNOSTIC_LOGICS]:
119
- /* valid */ "Agnostic Logics can compose with one another.",
120
- [USE_AGNOSTIC_COMPONENTS]:
121
- /* valid */ "Agnostic Components can be composed with Logics agnostically as long as the Agnostic Logics Module, by convention, does not export React components.",
122
- module: "Agnostic Logics Module",
123
- modulePeriod: "Agnostic Logics Module.",
124
- });
125
-
126
- export const agnosticComponentsComments = Object.freeze({
127
- [USE_SERVER_LOGICS]:
128
- /* invalid */ "Server Logics cannot run on both the server and the client, such as would be the case here in an Agnostic Components Module.",
129
- [USE_SERVER_COMPONENTS]:
130
- /* invalid */ "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.",
131
- [USE_SERVER_FUNCTIONS]:
132
- /* valid */ "Server Functions can be passed to Client Components as props when Client Components are also legally imported into Agnostic Components Modules.",
133
- [USE_CLIENT_LOGICS]:
134
- /* invalid */ "Client Logics cannot run on both the server and the client, such as would be the case here in an Agnostic Components Module.",
135
- [USE_CLIENT_COMPONENTS]:
136
- /* valid */ "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.",
137
- [USE_AGNOSTIC_LOGICS]:
138
- /* valid */ "Agnostic Logics, being environment-agnostic logic, can safely support Agnostic Components.",
139
- [USE_AGNOSTIC_COMPONENTS]:
140
- /* valid */ "Agnostic Components can compose with one another.",
141
- module: "Agnostic Components Module",
142
- modulePeriod: "Agnostic Components Module.",
143
- });
@@ -1,38 +0,0 @@
1
- import {
2
- serverLogicsComments,
3
- clientLogicsComments,
4
- agnosticLogicsComments,
5
- serverComponentsComments,
6
- clientComponentsComments,
7
- agnosticComponentsComments,
8
- serverFunctionsComments,
9
- clientContextsComments,
10
- agnosticConditionsComments,
11
- } from "./modules-comments.js";
12
-
13
- import {
14
- USE_SERVER_LOGICS,
15
- USE_CLIENT_LOGICS,
16
- USE_AGNOSTIC_LOGICS,
17
- USE_SERVER_COMPONENTS,
18
- USE_CLIENT_COMPONENTS,
19
- USE_AGNOSTIC_COMPONENTS,
20
- USE_SERVER_FUNCTIONS,
21
- USE_CLIENT_CONTEXTS,
22
- USE_AGNOSTIC_CONDITIONS,
23
- USE_AGNOSTIC_STRATEGIES,
24
- } from "../../../library/_commons/constants/bases.js";
25
-
26
- export const directive21Comments = Object.freeze({
27
- [USE_SERVER_LOGICS]: serverLogicsComments,
28
- [USE_CLIENT_LOGICS]: clientLogicsComments,
29
- [USE_AGNOSTIC_LOGICS]: agnosticLogicsComments,
30
- [USE_SERVER_COMPONENTS]: serverComponentsComments,
31
- [USE_CLIENT_COMPONENTS]: clientComponentsComments,
32
- [USE_AGNOSTIC_COMPONENTS]: agnosticComponentsComments,
33
- [USE_SERVER_FUNCTIONS]: serverFunctionsComments,
34
- [USE_CLIENT_CONTEXTS]: clientContextsComments,
35
- [USE_AGNOSTIC_CONDITIONS]: agnosticConditionsComments,
36
- [USE_AGNOSTIC_STRATEGIES]:
37
- /* valid */ "(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.)",
38
- });