eslint-plugin-use-agnostic 2.0.2 → 2.0.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.
@@ -133,9 +133,9 @@ export const fileIsRegularJavaScript = (filePath) =>
133
133
  //
134
134
 
135
135
  /**
136
- * The flow that begins the import rules enforcement rule, retrieving the verified commented directive of the current file before comparing it to upcoming verified commented directives of the files it imports.
137
- * @param {Context} context The ESLint rule's `context` object.
138
- * @returns Either an object with `skip: true` to disregard or one with the non-null `verifiedCommentedDirective`.
136
+ * $COMMENT#JSDOC#DEFINITIONS#DIRECTIVE21#CURRENTFILEFLOW
137
+ * @param {Context} context $COMMENT#JSDOC#PARAMS#CONTEXTB
138
+ * @returns $COMMENT#JSDOC#RETURNS#DIRECTIVE21#CURRENTFILEFLOW
139
139
  */
140
140
  export const currentFileFlow = (context) => {
141
141
  const skipTrue = { ...skip, verifiedCommentedDirective: undefined };
@@ -231,10 +231,10 @@ export const currentFileFlow = (context) => {
231
231
  /* importedFileFlow */
232
232
 
233
233
  /**
234
- * The flow that is shared between import and re-export traversals to obtain the import file's commented directive.
235
- * @param {Context} context The ESLint rule's `context` object.
236
- * @param {ImportDeclaration} node The ESLint `node` of the rule's current traversal.
237
- * @returns Either an object with `skip: true` to disregard or one with the non-null `importedFileCommentedDirective`. And now with the added results of `analyzeExportsForReExports`.
234
+ * $COMMENT#JSDOC#DEFINITIONS#DIRECTIVE21#IMPORTEDFILEFLOW
235
+ * @param {Context} context $COMMENT#JSDOC#PARAMS#CONTEXTB
236
+ * @param {ImportDeclaration} node $COMMENT#JSDOC#PARAMS#NODE
237
+ * @returns $COMMENT#JSDOC#RETURNS#DIRECTIVE21#IMPORTEDFILEFLOW
238
238
  */
239
239
  const importedFileFlow = (context, node) => {
240
240
  const skipTrue = {
@@ -271,7 +271,7 @@ const importedFileFlow = (context, node) => {
271
271
  // Now silencing the warning as superfluous, in order to not warn on imports of files without a commented directive that are outside of linting range.
272
272
 
273
273
  // console.warn(
274
- // `WARNING. The imported file ${resolvedImportPath}, whose path has been resolved from ${context.filename}, has no commented directive. It is thus ignored since the report on that circumstance would be available on the imported file itself.`
274
+ // `WARNING. The imported file ${resolvedImportPath}, whose path has been resolved from ${context.filename}, has no commented $COMMENT#JSDOC#FORCOMPOSEDVARIABLES#DIRECTIVEPERIOD It is thus ignored since the report on that circumstance would be available on the imported file itself.`
275
275
  // ); // The decision not to report has been taken to not inflate the number of warnings.
276
276
  return skipTrue;
277
277
  }
@@ -333,10 +333,10 @@ const importedFileFlow = (context, node) => {
333
333
 
334
334
  // NEW!! Currently strictly adapted from importedFileFlow
335
335
  /**
336
- * The `importedFileFlow` adapted for `require` calls to obtain the import file's commented directive.
337
- * @param {Context} context The ESLint rule's `context` object.
338
- * @param {CallExpression} node The ESLint `node` of the rule's current traversal.
339
- * @returns Either an object with `skip: true` to disregard or one with the non-null `importedFileCommentedDirective`. And now with the added results of `analyzeExportsForReExports`.
336
+ * $COMMENT#JSDOC#DEFINITIONS#DIRECTIVE21#IMPORTEDFILEFLOWREQUIRE
337
+ * @param {Context} context $COMMENT#JSDOC#PARAMS#CONTEXTB
338
+ * @param {CallExpression} node $COMMENT#JSDOC#PARAMS#NODE
339
+ * @returns $COMMENT#JSDOC#RETURNS#DIRECTIVE21#IMPORTEDFILEFLOW
340
340
  */
341
341
  const importedFileFlowRequire = (context, node) => {
342
342
  const skipTrue = {
@@ -383,7 +383,7 @@ const importedFileFlowRequire = (context, node) => {
383
383
  // Now silencing the warning as superfluous, in order to not warn on imports of files without a commented directive that are outside of linting range.
384
384
 
385
385
  // console.warn(
386
- // `WARNING. The imported file ${resolvedImportPath}, whose path has been resolved from ${context.filename}, has no commented directive. It is thus ignored since the report on that circumstance would be available on the imported file itself.`
386
+ // `WARNING. The imported file ${resolvedImportPath}, whose path has been resolved from ${context.filename}, has no commented $COMMENT#JSDOC#FORCOMPOSEDVARIABLES#DIRECTIVEPERIOD It is thus ignored since the report on that circumstance would be available on the imported file itself.`
387
387
  // ); // The decision not to report has been taken to not inflate the number of warnings.
388
388
  return skipTrue;
389
389
  }
@@ -444,11 +444,11 @@ const importedFileFlowRequire = (context, node) => {
444
444
  /* importsFlow */
445
445
 
446
446
  /**
447
- * The full flow for import traversals to enforce commented directives import rules.
448
- * @param {Context} context The ESLint rule's `context` object.
449
- * @param {ImportDeclaration} node The ESLint `node` of the rule's current traversal.
450
- * @param {CommentedDirective} currentFileCommentedDirective The current file's commented directive.
451
- * @returns Early if the flow needs to be interrupted.
447
+ * $COMMENT#JSDOC#FORALIASVARIABLES#IMPORTSFLOWCOMMENTED
448
+ * @param {Context} context $COMMENT#JSDOC#PARAMS#CONTEXTB
449
+ * @param {ImportDeclaration} node $COMMENT#JSDOC#PARAMS#NODE
450
+ * @param {CommentedDirective} currentFileCommentedDirective $COMMENT#JSDOC#PARAMS#DIRECTIVE21#CURRENTFILECOMMENTEDDIRECTIVE
451
+ * @returns $COMMENT#JSDOC#FORALIASVARIABLES#FLOWRETURNSEARLY
452
452
  */
453
453
  export const importsFlow = (context, node, currentFileCommentedDirective) => {
454
454
  // does not operate on `import type`
@@ -521,11 +521,11 @@ export const importsFlow = (context, node, currentFileCommentedDirective) => {
521
521
 
522
522
  // NEW!! Currently strictly adapted from importsFlow
523
523
  /**
524
- * The `importsFlow` adapted for `require` calls to enforce commented directives import rules.
525
- * @param {Context} context The ESLint rule's `context` object.
526
- * @param {CallExpression} node The ESLint `node` of the rule's current traversal.
527
- * @param {CommentedDirective} currentFileCommentedDirective The current file's commented directive.
528
- * @returns Early if the flow needs to be interrupted.
524
+ * $COMMENT#JSDOC#FORALIASVARIABLES#IMPORTSFLOWCOMMENTEDREQUIRE
525
+ * @param {Context} context $COMMENT#JSDOC#PARAMS#CONTEXTB
526
+ * @param {CallExpression} node $COMMENT#JSDOC#PARAMS#NODE
527
+ * @param {CommentedDirective} currentFileCommentedDirective $COMMENT#JSDOC#PARAMS#DIRECTIVE21#CURRENTFILECOMMENTEDDIRECTIVE
528
+ * @returns $COMMENT#JSDOC#FORALIASVARIABLES#FLOWRETURNSEARLY
529
529
  */
530
530
  export const importsFlowRequire = (
531
531
  context,
@@ -600,11 +600,11 @@ export const importsFlowRequire = (
600
600
  /* allExportsFlow */
601
601
 
602
602
  /**
603
- * 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.
604
- * @param {Context} context The ESLint rule's `context` object.
605
- * @param {ExportNamedDeclaration | ExportAllDeclaration | ExportDefaultDeclaration} node The ESLint `node` of the rule's current traversal.
606
- * @param {CommentedDirective} currentFileCommentedDirective The current file's commented directive.
607
- * @returns Early if the flow needs to be interrupted.
603
+ * $COMMENT#JSDOC#DEFINITIONS#DIRECTIVE21#ALLEXPORTSFLOW
604
+ * @param {Context} context $COMMENT#JSDOC#PARAMS#CONTEXTB
605
+ * @param {ExportNamedDeclaration | ExportAllDeclaration | ExportDefaultDeclaration} node $COMMENT#JSDOC#PARAMS#NODE
606
+ * @param {CommentedDirective} currentFileCommentedDirective $COMMENT#JSDOC#PARAMS#DIRECTIVE21#CURRENTFILECOMMENTEDDIRECTIVE
607
+ * @returns $COMMENT#JSDOC#FORALIASVARIABLES#FLOWRETURNSEARLY
608
608
  */
609
609
  export const allExportsFlow = (
610
610
  context,
@@ -644,12 +644,12 @@ export const allExportsFlow = (
644
644
  // else
645
645
  currentFileCommentedDirective = addressedDirective; // to still keep compatibility with strategies
646
646
 
647
- // Lints imports of Agnostic Strategies Modules beyond strategy resolution, such as to warn imports of Special Agnostic Modules. Does the same with Agnostic Conditions Modules, since they are the only other modules which cannot import themselves.
647
+ // Lints imports of Agnostic Strategies Modules beyond strategy resolution, such as to warn imports of Special Agnostic Modules. Does the same with $COMMENT#DIRECTIVE21#USE_AGNOSTIC_CONDITIONS#KINDSSIMPLE Modules, since they are the only other modules which cannot import themselves.
648
648
  if (
649
649
  currentFileCommentedDirective === USE_AGNOSTIC_STRATEGIES ||
650
650
  currentFileCommentedDirective === USE_AGNOSTIC_CONDITIONS
651
651
  ) {
652
- // Basically, all modules need to do reexports that correspond to their own modules, but not Agnostic Strategies Modules and Agnostic Conditions Modules, the latter which are in fact NOT allowed to do re-exports.
652
+ // Basically, all modules need to do reexports that correspond to their own modules, but not Agnostic Strategies Modules and $COMMENT#DIRECTIVE21#USE_AGNOSTIC_CONDITIONS#KINDSSIMPLE Modules, the latter which are in fact NOT allowed to do re-exports.
653
653
  if (
654
654
  isImportBlocked(
655
655
  currentFileCommentedDirective,
@@ -727,9 +727,9 @@ export const allExportsFlow = (
727
727
  /* functionDeclarationFlow */
728
728
 
729
729
  /**
730
- * Checks if the name of an identifier is in PascalCase, as a cheap way to assess whether or not it is a React component.
731
- * @param {string} name The name of the identifier at hand.
732
- * @returns `true` if the name is recognized as PascalCase, `false` otherwise.
730
+ * $COMMENT#JSDOC#DEFINITIONS#DIRECTIVE21#NAMEISPASCALCASE
731
+ * @param {string} name $COMMENT#JSDOC#PARAMS#DIRECTIVE21#NAME
732
+ * @returns $COMMENT#JSDOC#RETURNS#DIRECTIVE21#NAMEISPASCALCASE
733
733
  */
734
734
  const nameIsPascalCase = (name) => {
735
735
  // PascalCase: starts with capital, no underscores, no hyphens
@@ -737,9 +737,9 @@ const nameIsPascalCase = (name) => {
737
737
  };
738
738
 
739
739
  /**
740
- * Checks whether the parameters of a function (React component) include the `children` property.
741
- * @param {Parameter[]} params The parameters at hand.
742
- * @returns `true` if the parameters include the `children` property, `false` otherwise.
740
+ * $COMMENT#JSDOC#DEFINITIONS#DIRECTIVE21#DECLARESCHILDRENPROP
741
+ * @param {Parameter[]} params $COMMENT#JSDOC#PARAMS#DIRECTIVE21#PARAMS
742
+ * @returns $COMMENT#JSDOC#RETURNS#DIRECTIVE21#DECLARESCHILDRENPROP
743
743
  */
744
744
  const declaresChildrenProp = (params) => {
745
745
  if (params.length === 0) return false;
@@ -760,11 +760,11 @@ const declaresChildrenProp = (params) => {
760
760
  };
761
761
 
762
762
  /**
763
- * The flow for function declarations to ensure that Client Lineals Components are made in Client Components Modules and Client Contexts Components are made in Client Contexts Modules, based on the fact that the former are child-free and the latter are children-bearing.
764
- * @param {Context} context The ESLint rule's `context` object.
765
- * @param {FunctionDeclaration} node The ESLint `node` of the rule's current traversal.
766
- * @param {CommentedDirective} currentFileCommentedDirective The current file's commented directive.
767
- * @returns Early if the flow needs to be interrupted.
763
+ * $COMMENT#JSDOC#DEFINITIONS#DIRECTIVE21#FUNCTIONDECLARATIONFLOW
764
+ * @param {Context} context $COMMENT#JSDOC#PARAMS#CONTEXTB
765
+ * @param {FunctionDeclaration} node $COMMENT#JSDOC#PARAMS#NODE
766
+ * @param {CommentedDirective} currentFileCommentedDirective $COMMENT#JSDOC#PARAMS#DIRECTIVE21#CURRENTFILECOMMENTEDDIRECTIVE
767
+ * @returns $COMMENT#JSDOC#FORALIASVARIABLES#FLOWRETURNSEARLY
768
768
  */
769
769
  export const functionDeclarationFlow = (
770
770
  context,
@@ -806,11 +806,11 @@ export const functionDeclarationFlow = (
806
806
  /* jsxElementFlow */
807
807
 
808
808
  /**
809
- * The flow for JSX elements to ensure that render props are only used isolated inside a Client Components Module, where their execution would safely be happening exclusively on the client.
810
- * @param {Context} context The ESLint rule's `context` object.
811
- * @param {JSXElement} node The ESLint `node` of the rule's current traversal.
812
- * @param {CommentedDirective} currentFileCommentedDirective The current file's commented directive.
813
- * @returns Early if the flow needs to be interrupted.
809
+ * $COMMENT#JSDOC#DEFINITIONS#DIRECTIVE21#JSXELEMENTFLOW
810
+ * @param {Context} context $COMMENT#JSDOC#PARAMS#CONTEXTB
811
+ * @param {JSXElement} node $COMMENT#JSDOC#PARAMS#NODE
812
+ * @param {CommentedDirective} currentFileCommentedDirective $COMMENT#JSDOC#PARAMS#DIRECTIVE21#CURRENTFILECOMMENTEDDIRECTIVE
813
+ * @returns $COMMENT#JSDOC#FORALIASVARIABLES#FLOWRETURNSEARLY
814
814
  */
815
815
  export const jsxElementFlow = (
816
816
  context,
@@ -841,11 +841,11 @@ export const jsxElementFlow = (
841
841
  /* jsxOpeningElementFlow */
842
842
 
843
843
  /**
844
- * The flow for JSX opening elements to ensure that event handler props on intrinsic elements are only used in modules that can safely create Client Components.
845
- * @param {Context} context The ESLint rule's `context` object.
846
- * @param {JSXOpeningElement} node The ESLint `node` of the rule's current traversal.
847
- * @param {CommentedDirective} currentFileCommentedDirective The current file's commented directive.
848
- * @returns Early if the flow needs to be interrupted.
844
+ * $COMMENT#JSDOC#DEFINITIONS#DIRECTIVE21#JSXOPENINGELEMENTFLOW
845
+ * @param {Context} context $COMMENT#JSDOC#PARAMS#CONTEXTB
846
+ * @param {JSXOpeningElement} node $COMMENT#JSDOC#PARAMS#NODE
847
+ * @param {CommentedDirective} currentFileCommentedDirective $COMMENT#JSDOC#PARAMS#DIRECTIVE21#CURRENTFILECOMMENTEDDIRECTIVE
848
+ * @returns $COMMENT#JSDOC#FORALIASVARIABLES#FLOWRETURNSEARLY
849
849
  */
850
850
  export const jsxOpeningElementFlow = (
851
851
  context,
@@ -30,9 +30,9 @@ import {
30
30
  /* getCommentedDirectiveFromSourceCode */
31
31
 
32
32
  /**
33
- * Detects whether a string is single- or double-quoted.
34
- * @param {string} string The original string.
35
- * @returns `true` if single-quoted, `false` if double-quoted, `null` if neither.
33
+ * $COMMENT#JSDOC#DEFINITIONS#DIRECTIVE21#DETECTQUOTETYPE
34
+ * @param {string} string $COMMENT#JSDOC#PARAMS#DIRECTIVE21#STRING
35
+ * @returns $COMMENT#JSDOC#RETURNS#DIRECTIVE21#DETECTQUOTETYPE
36
36
  */
37
37
  const detectQuoteType = (string) => {
38
38
  if (string.startsWith("'") && string.endsWith("'")) {
@@ -45,9 +45,9 @@ const detectQuoteType = (string) => {
45
45
  };
46
46
 
47
47
  /**
48
- * Removes single quotes from a string known to be single-quoted.
49
- * @param {string} string The original string.
50
- * @returns The string with quotes removed.
48
+ * $COMMENT#JSDOC#DEFINITIONS#DIRECTIVE21#STRIPSINGLEQUOTES
49
+ * @param {string} string $COMMENT#JSDOC#PARAMS#DIRECTIVE21#STRING
50
+ * @returns $COMMENT#JSDOC#RETURNS#DIRECTIVE21#STRIPSINGLEQUOTES
51
51
  */
52
52
  const stripSingleQuotes = (string) => {
53
53
  if (string.startsWith("'") && string.endsWith("'")) {
@@ -57,9 +57,9 @@ const stripSingleQuotes = (string) => {
57
57
  };
58
58
 
59
59
  /**
60
- * Removes double quotes from a string known to be double-quoted.
61
- * @param {string} string The original string.
62
- * @returns The string with quotes removed.
60
+ * $COMMENT#JSDOC#DEFINITIONS#DIRECTIVE21#STRIPDOUBLEQUOTES
61
+ * @param {string} string $COMMENT#JSDOC#PARAMS#DIRECTIVE21#STRING
62
+ * @returns $COMMENT#JSDOC#RETURNS#DIRECTIVE21#STRIPSINGLEQUOTES
63
63
  */
64
64
  const stripDoubleQuotes = (string) => {
65
65
  if (string.startsWith('"') && string.endsWith('"')) {
@@ -69,21 +69,21 @@ const stripDoubleQuotes = (string) => {
69
69
  };
70
70
 
71
71
  /**
72
- * Gets the commented directive of a module from its ESLint `SourceCode` object.
72
+ * $COMMENT#JSDOC#DEFINITIONS#DIRECTIVE21#GETCOMMENTEDDIRECTIVEFROMSOURCECODE1
73
73
  *
74
- * Accepted directives for the default Directive-First Architecture are (single or double quotes included):
75
- * - `'use server logics'`, `"use server logics"` denoting a Server Logics Module.
76
- * - `'use client logics'`, `"use client logics"` denoting a Client Logics Module.
77
- * - `'use agnostic logics'`, `"use agnostic logics"` denoting an Agnostic Logics Module.
78
- * - `'use server components'`, `"use server components"` denoting a Server Components Module.
79
- * - `'use client components'`, `"use client components"` denoting a Client Components Module.
80
- * - `'use agnostic components'`, `"use agnostic components"` denoting an Agnostic Components Module.
81
- * - `'use server functions'`, `"use server functions"` denoting a Server Functions Module.
82
- * - `'use client contexts'`, `"use client contexts"` denoting a Client Contexts Module.
83
- * - `'use agnostic conditions'`, `"use agnostic conditions"` denoting an Agnostic Conditions Module.
84
- * - `'use agnostic strategies'`, `"use agnostic strategies"` denoting an Agnostic Strategies Module.
85
- * @param {SourceCode} sourceCode The ESLint SourceCode object.
86
- * @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.)
74
+ * $COMMENT#JSDOC#DEFINITIONS#DIRECTIVE21#GETCOMMENTEDDIRECTIVEFROMSOURCECODE2
75
+ * - $COMMENT#JSDOC#DETAILS#DIRECTIVE21#USESERVERLOGICSA
76
+ * - $COMMENT#JSDOC#DETAILS#DIRECTIVE21#USECLIENTLOGICSA
77
+ * - $COMMENT#JSDOC#DETAILS#DIRECTIVE21#USEAGNOSTICLOGICSA
78
+ * - $COMMENT#JSDOC#DETAILS#DIRECTIVE21#USESERVERCOMPONENTSA
79
+ * - $COMMENT#JSDOC#DETAILS#DIRECTIVE21#USECLIENTCOMPONENTSA
80
+ * - $COMMENT#JSDOC#DETAILS#DIRECTIVE21#USEAGNOSTICCOMPONENTSA
81
+ * - $COMMENT#JSDOC#DETAILS#DIRECTIVE21#USESERVERFUNCTIONSA
82
+ * - $COMMENT#JSDOC#DETAILS#DIRECTIVE21#USECLIENTCONTEXTSA
83
+ * - $COMMENT#JSDOC#DETAILS#DIRECTIVE21#USEAGNOSTICCONDITIONSA
84
+ * - $COMMENT#JSDOC#DETAILS#DIRECTIVE21#USEAGNOSTICSTRATEGIESA
85
+ * @param {SourceCode} sourceCode $COMMENT#JSDOC#PARAMS#DIRECTIVE21#SOURCECODE
86
+ * @returns $COMMENT#JSDOC#RETURNS#DIRECTIVE21#GETCOMMENTEDDIRECTIVEFROMSOURCECODE
87
87
  */
88
88
  export const getCommentedDirectiveFromSourceCode = (sourceCode) => {
89
89
  // returns null IMMEDIATELY if the SourceCode is faulty (inexistent)
@@ -134,21 +134,21 @@ export const getCommentedDirectiveFromSourceCode = (sourceCode) => {
134
134
  /* getCommentedDirectiveFromCurrentModule */
135
135
 
136
136
  /**
137
- * Gets the commented directive of the current module.
137
+ * $COMMENT#JSDOC#DEFINITIONS#DIRECTIVE21#GETCOMMENTEDDIRECTIVEFROMCURRENTMODULE1
138
138
  *
139
- * Accepted directives for the default Directive-First Architecture are (single or double quotes included):
140
- * - `'use server logics'`, `"use server logics"` denoting a Server Logics Module.
141
- * - `'use client logics'`, `"use client logics"` denoting a Client Logics Module.
142
- * - `'use agnostic logics'`, `"use agnostic logics"` denoting an Agnostic Logics Module.
143
- * - `'use server components'`, `"use server components"` denoting a Server Components Module.
144
- * - `'use client components'`, `"use client components"` denoting a Client Components Module.
145
- * - `'use agnostic components'`, `"use agnostic components"` denoting an Agnostic Components Module.
146
- * - `'use server functions'`, `"use server functions"` denoting a Server Functions Module.
147
- * - `'use client contexts'`, `"use client contexts"` denoting a Client Contexts Module.
148
- * - `'use agnostic conditions'`, `"use agnostic conditions"` denoting an Agnostic Conditions Module.
149
- * - `'use agnostic strategies'`, `"use agnostic strategies"` denoting an Agnostic Strategies Module.
150
- * @param {Context} context The ESLint rule's `context` object.
151
- * @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.)
139
+ * $COMMENT#JSDOC#DEFINITIONS#DIRECTIVE21#GETCOMMENTEDDIRECTIVEFROMSOURCECODE2
140
+ * - $COMMENT#JSDOC#DETAILS#DIRECTIVE21#USESERVERLOGICSA
141
+ * - $COMMENT#JSDOC#DETAILS#DIRECTIVE21#USECLIENTLOGICSA
142
+ * - $COMMENT#JSDOC#DETAILS#DIRECTIVE21#USEAGNOSTICLOGICSA
143
+ * - $COMMENT#JSDOC#DETAILS#DIRECTIVE21#USESERVERCOMPONENTSA
144
+ * - $COMMENT#JSDOC#DETAILS#DIRECTIVE21#USECLIENTCOMPONENTSA
145
+ * - $COMMENT#JSDOC#DETAILS#DIRECTIVE21#USEAGNOSTICCOMPONENTSA
146
+ * - $COMMENT#JSDOC#DETAILS#DIRECTIVE21#USESERVERFUNCTIONSA
147
+ * - $COMMENT#JSDOC#DETAILS#DIRECTIVE21#USECLIENTCONTEXTSA
148
+ * - $COMMENT#JSDOC#DETAILS#DIRECTIVE21#USEAGNOSTICCONDITIONSA
149
+ * - $COMMENT#JSDOC#DETAILS#DIRECTIVE21#USEAGNOSTICSTRATEGIESA
150
+ * @param {Context} context $COMMENT#JSDOC#PARAMS#CONTEXTB
151
+ * @returns $COMMENT#JSDOC#RETURNS#DIRECTIVE21#GETCOMMENTEDDIRECTIVEFROMSOURCECODE
152
152
  */
153
153
  export const getCommentedDirectiveFromCurrentModule = (context) => {
154
154
  const sourceCode = context.sourceCode;
@@ -163,21 +163,21 @@ export const getCommentedDirectiveFromCurrentModule = (context) => {
163
163
  /* getCommentedDirectiveFromImportedModule */
164
164
 
165
165
  /**
166
- * Gets the commented directive of the imported module.
166
+ * $COMMENT#JSDOC#DEFINITIONS#DIRECTIVE21#GETCOMMENTEDDIRECTIVEFROMIMPORTEDMODULE1
167
167
  *
168
- * Accepted directives for the default Directive-First Architecture are (single or double quotes included):
169
- * - `'use server logics'`, `"use server logics"` denoting a Server Logics Module.
170
- * - `'use client logics'`, `"use client logics"` denoting a Client Logics Module.
171
- * - `'use agnostic logics'`, `"use agnostic logics"` denoting an Agnostic Logics Module.
172
- * - `'use server components'`, `"use server components"` denoting a Server Components Module.
173
- * - `'use client components'`, `"use client components"` denoting a Client Components Module.
174
- * - `'use agnostic components'`, `"use agnostic components"` denoting an Agnostic Components Module.
175
- * - `'use server functions'`, `"use server functions"` denoting a Server Functions Module.
176
- * - `'use client contexts'`, `"use client contexts"` denoting a Client Contexts Module.
177
- * - `'use agnostic conditions'`, `"use agnostic conditions"` denoting an Agnostic Conditions Module.
178
- * - `'use agnostic strategies'`, `"use agnostic strategies"` denoting an Agnostic Strategies Module.
179
- * @param {string} resolvedPath The resolved path of the imported module.
180
- * @returns The commented directive, or lack thereof via `null`. Now also provides the obtained `SourceCode` object. 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.)
168
+ * $COMMENT#JSDOC#DEFINITIONS#DIRECTIVE21#GETCOMMENTEDDIRECTIVEFROMSOURCECODE2
169
+ * - $COMMENT#JSDOC#DETAILS#DIRECTIVE21#USESERVERLOGICSA
170
+ * - $COMMENT#JSDOC#DETAILS#DIRECTIVE21#USECLIENTLOGICSA
171
+ * - $COMMENT#JSDOC#DETAILS#DIRECTIVE21#USEAGNOSTICLOGICSA
172
+ * - $COMMENT#JSDOC#DETAILS#DIRECTIVE21#USESERVERCOMPONENTSA
173
+ * - $COMMENT#JSDOC#DETAILS#DIRECTIVE21#USECLIENTCOMPONENTSA
174
+ * - $COMMENT#JSDOC#DETAILS#DIRECTIVE21#USEAGNOSTICCOMPONENTSA
175
+ * - $COMMENT#JSDOC#DETAILS#DIRECTIVE21#USESERVERFUNCTIONSA
176
+ * - $COMMENT#JSDOC#DETAILS#DIRECTIVE21#USECLIENTCONTEXTSA
177
+ * - $COMMENT#JSDOC#DETAILS#DIRECTIVE21#USEAGNOSTICCONDITIONSA
178
+ * - $COMMENT#JSDOC#DETAILS#DIRECTIVE21#USEAGNOSTICSTRATEGIESA
179
+ * @param {string} resolvedPath $COMMENT#JSDOC#PARAMS#RESOLVEDPATH
180
+ * @returns $COMMENT#JSDOC#RETURNS#DIRECTIVE21#GETCOMMENTEDDIRECTIVEFROMIMPORTEDMODULE
181
181
  */
182
182
  export const getCommentedDirectiveFromImportedModule = (resolvedPath) => {
183
183
  const sourceCode = getSourceCodeFromFilePath(resolvedPath);
@@ -192,20 +192,20 @@ export const getCommentedDirectiveFromImportedModule = (resolvedPath) => {
192
192
  /* getVerifiedCommentedDirective */
193
193
 
194
194
  /**
195
- * Ensures that a module's commented directive is consistent with its file extension (depending on whether it ends with 'x' for JSX).
196
- * - `'use server logics'`: Server Logics Modules do NOT export JSX.
197
- * - `'use client logics'`: Client Logics Modules do NOT export JSX.
198
- * - `'use agnostic logics'`: Agnostic Logics Modules do NOT export JSX.
199
- * - `'use server components'`: Server Components Modules ONLY export JSX.
200
- * - `'use client components'`: Client Components Modules ONLY export JSX.
201
- * - `'use agnostic components'`: Agnostic Components Modules ONLY export JSX.
202
- * - `'use server functions'`: Server Functions Modules do NOT export JSX.
203
- * - `'use client contexts'`: Client Contexts Modules ONLY export JSX.
204
- * - `'use agnostic conditions'`: Agnostic Conditions Modules ONLY export JSX.
205
- * - `'use agnostic strategies'`: Agnostic Strategies Modules may export JSX.
206
- * @param {CommentedDirective} directive The commented directive as written on top of the file (cannot be `null` at that stage).
207
- * @param {Extension} extension The JavaScript (TypeScript) extension of the file.
208
- * @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.
195
+ * $COMMENT#JSDOC#DEFINITIONS#DIRECTIVE21#GETVERIFIEDCOMMENTEDDIRECTIVE
196
+ * - $COMMENT#JSDOC#DETAILS#DIRECTIVE21#USESERVERLOGICSB
197
+ * - $COMMENT#JSDOC#DETAILS#DIRECTIVE21#USECLIENTLOGICSB
198
+ * - $COMMENT#JSDOC#DETAILS#DIRECTIVE21#USEAGNOSTICLOGICSB
199
+ * - $COMMENT#JSDOC#DETAILS#DIRECTIVE21#USESERVERCOMPONENTSB
200
+ * - $COMMENT#JSDOC#DETAILS#DIRECTIVE21#USECLIENTCOMPONENTSB
201
+ * - $COMMENT#JSDOC#DETAILS#DIRECTIVE21#USEAGNOSTICCOMPONENTSB
202
+ * - $COMMENT#JSDOC#DETAILS#DIRECTIVE21#USESERVERFUNCTIONSB
203
+ * - $COMMENT#JSDOC#DETAILS#DIRECTIVE21#USECLIENTCONTEXTSB
204
+ * - $COMMENT#JSDOC#DETAILS#DIRECTIVE21#USEAGNOSTICCONDITIONSB
205
+ * - $COMMENT#JSDOC#DETAILS#DIRECTIVE21#USEAGNOSTICSTRATEGIESB
206
+ * @param {CommentedDirective} directive $COMMENT#JSDOC#PARAMS#DIRECTIVE21#DIRECTIVE
207
+ * @param {Extension} extension $COMMENT#JSDOC#PARAMS#EXTENSION
208
+ * @returns $COMMENT#JSDOC#RETURNS#DIRECTIVE21#GETVERIFIEDCOMMENTEDDIRECTIVE
209
209
  */
210
210
  export const getVerifiedCommentedDirective = (directive, extension) => {
211
211
  const rule = commentedDirectives_extensionRules[directive];
@@ -222,10 +222,10 @@ export const getVerifiedCommentedDirective = (directive, extension) => {
222
222
  /* getStrategizedDirective */
223
223
 
224
224
  /**
225
- * Gets the interpreted directive from a specified commented Strategy (such as `@serverLogics`) nested inside the import (or export) declaration for an import (or export) from an Agnostic Strategies Module.
226
- * @param {Context} context The ESLint rule's `context` object.
227
- * @param {ImportDeclaration | ExportNamedDeclaration | ExportAllDeclaration | ExportDefaultDeclaration} node The ESLint `node` of the rule's current traversal.
228
- * @returns The interpreted directive, a.k.a. strategized directive, or lack thereof via `null`.
225
+ * $COMMENT#JSDOC#DEFINITIONS#DIRECTIVE21#GETSTRATEGIZEDDIRECTIVE
226
+ * @param {Context} context $COMMENT#JSDOC#PARAMS#CONTEXTB
227
+ * @param {ImportDeclaration | ExportNamedDeclaration | ExportAllDeclaration | ExportDefaultDeclaration} node $COMMENT#JSDOC#PARAMS#NODE
228
+ * @returns $COMMENT#JSDOC#RETURNS#DIRECTIVE21#GETSTRATEGIZEDDIRECTIVE
229
229
  */
230
230
  export const getStrategizedDirective = (context, node) => {
231
231
  // gets the first nested `/* */` comment inside the node
@@ -314,11 +314,11 @@ export const fileIsRegularJavaScript = (filePath) =>
314
314
  //
315
315
 
316
316
  /**
317
- * 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.
318
- * @param {Context} context The ESLint rule's `context` object.
319
- * @param {ExportNamedDeclaration | ExportAllDeclaration | ExportDefaultDeclaration} node The ESLint `node` of the rule's current traversal.
320
- * @param {CommentedDirective} currentFileCommentedDirective The current file's commented directive.
321
- * @returns The commented directive, the addressed strategy (as a commented directive) or `null` in case of failure.
317
+ * $COMMENT#JSDOC#DEFINITIONS#DIRECTIVE21#ADDRESSDIRECTIVEIFAGNOSTICSTRATEGIES
318
+ * @param {Context} context $COMMENT#JSDOC#PARAMS#CONTEXTB
319
+ * @param {ExportNamedDeclaration | ExportAllDeclaration | ExportDefaultDeclaration} node $COMMENT#JSDOC#PARAMS#NODE
320
+ * @param {CommentedDirective} currentFileCommentedDirective $COMMENT#JSDOC#PARAMS#DIRECTIVE21#CURRENTFILECOMMENTEDDIRECTIVE
321
+ * @returns $COMMENT#JSDOC#RETURNS#DIRECTIVE21#ADDRESSDIRECTIVEIFAGNOSTICSTRATEGIES
322
322
  */
323
323
  export const addressDirectiveIfAgnosticStrategies = (
324
324
  context,
@@ -352,10 +352,10 @@ export const addressDirectiveIfAgnosticStrategies = (
352
352
  /* isImportBlocked */
353
353
 
354
354
  /**
355
- * Returns a boolean deciding if an imported file's commented directive is incompatible with the current file's commented directive.
356
- * @param {CommentedDirective} currentFileCommentedDirective The current file's commented directive.
357
- * @param {CommentedDirective} importedFileCommentedDirective The imported file's commented directive.
358
- * @returns `true` if the import is blocked, as established in `commentedDirectives_BlockedImports`.
355
+ * $COMMENT#JSDOC#DEFINITIONS#DIRECTIVE21#ISIMPORTBLOCKED
356
+ * @param {CommentedDirective} currentFileCommentedDirective $COMMENT#JSDOC#PARAMS#DIRECTIVE21#CURRENTFILECOMMENTEDDIRECTIVE
357
+ * @param {CommentedDirective} importedFileCommentedDirective $COMMENT#JSDOC#PARAMS#DIRECTIVE21#IMPORTEDFILECOMMENTEDDIRECTIVE
358
+ * @returns $COMMENT#JSDOC#RETURNS#DIRECTIVE21#ISIMPORTBLOCKED
359
359
  */
360
360
  export const isImportBlocked = (
361
361
  currentFileCommentedDirective,
@@ -370,9 +370,9 @@ export const isImportBlocked = (
370
370
  /* makeMessageFromCurrentFileCommentedDirective */
371
371
 
372
372
  /**
373
- * Lists in an message the commented modules incompatible with a commented module based on its commented directive.
374
- * @param {CommentedDirective} commentedDirective The commented directive of the commented module.
375
- * @returns The message listing the incompatible commented modules.
373
+ * $COMMENT#JSDOC#DEFINITIONS#DIRECTIVE21#MAKEMESSAGEFROMCURRENTFILECOMMENTEDDIRECTIVE
374
+ * @param {CommentedDirective} commentedDirective $COMMENT#JSDOC#PARAMS#DIRECTIVE21#COMMENTEDDIRECTIVE
375
+ * @returns $COMMENT#JSDOC#RETURNS#DIRECTIVE21#MAKEMESSAGEFROMCURRENTFILECOMMENTEDDIRECTIVE
376
376
  */
377
377
  export const makeMessageFromCurrentFileCommentedDirective = (
378
378
  commentedDirective,
@@ -385,10 +385,10 @@ export const makeMessageFromCurrentFileCommentedDirective = (
385
385
  /* findSpecificViolationMessage */
386
386
 
387
387
  /**
388
- * Finds the `message` for the specific violation of commented directives import rules based on `commentedDirectives_BlockedImports`.
389
- * @param {CommentedDirective} currentFileCommentedDirective The current file's commented directive.
390
- * @param {CommentedDirective} importedFileCommentedDirective The imported file's commented directive.
391
- * @returns The corresponding `message`.
388
+ * $COMMENT#JSDOC#DEFINITIONS#DIRECTIVE21#FINDSPECIFICVIOLATIONMESSAGE
389
+ * @param {CommentedDirective} currentFileCommentedDirective $COMMENT#JSDOC#PARAMS#DIRECTIVE21#CURRENTFILECOMMENTEDDIRECTIVE
390
+ * @param {CommentedDirective} importedFileCommentedDirective $COMMENT#JSDOC#PARAMS#DIRECTIVE21#IMPORTEDFILECOMMENTEDDIRECTIVE
391
+ * @returns $COMMENT#JSDOC#RETURNS#FINDSPECIFICVIOLATIONMESSAGE
392
392
  */
393
393
  export const findSpecificViolationMessage = (
394
394
  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/library/index.js CHANGED
@@ -165,10 +165,10 @@ export {
165
165
  export { directive21Data } from "../jscomments/_commons/constants/data.js";
166
166
 
167
167
  /**
168
- * Creates the ESLint config object required as the basis for the Directive-First Architecture, linting server-client-agnostic imports based on their commented directives. (Defaults to `"warn"`. You can import and use ```[`${useAgnosticPluginName}/${directive21ConfigName}`]``` later in a further ESLint config object to modify that value.)
168
+ * $COMMENT#JSDOC#DEFINITIONS#DEFINEDIRECTIVE21
169
169
  * @template {string} T
170
- * @param {T} reactFolder The path of the project's React folder where everything React lives, relative to the root of the project. This is, for example, the app directory when using the Next.js App Router, as `"app"`.
171
- * @returns An ESLint config object that applies `eslint-plugin-use-agnostic`'s `directive21` config by using the provided `reactFolder` as the basis for JavaScript/TypeScript glob patterns.
170
+ * @param {T} reactFolder $COMMENT#JSDOC#PARAMS#REACTFOLDER
171
+ * @returns $COMMENT#JSDOC#RETURNS#DEFINEDIRECTIVE21
172
172
  */
173
173
  export const defineDirective21 = (reactFolder) => {
174
174
  /** @type {[`${T}/*\*\/*.tsx`, `${T}/*\*\/*.ts`, `${T}/*\*\/*.jsx`, `${T}/*\*\/*.js`, `${T}/*\*\/*.mjs`, `${T}/*\*\/*.cjs`]} */
@@ -195,13 +195,13 @@ export const defineDirective21 = (reactFolder) => {
195
195
  };
196
196
 
197
197
  /**
198
- * Defines the config settings for the eXtra JSX VS Code extension as a means to configure `eXtra JSX` directly from ESLint, given the fact that `eslint-plugin-use-agnostic` and `eXtra JSX` have to work together in making the Directive-First Architecture.
198
+ * $COMMENT#JSDOC#DEFINITIONS#DEFINECONFIGSETTINGS
199
199
  * @template {string} T
200
200
  * @template {string} U
201
- * @param {Object} settings The settings as follows:
202
- * @param {T} settings.reactFolder The path of the project's React folder where everything React lives, relative to the root of the project. This is, for example, the app directory when using the Next.js App Router, as `"app"`.
203
- * @param {U} settings.rootPath The absolute path of the root of the project, from which the absolute path of the React folder can be easily obtained.
204
- * @returns The config object responsible for the settings retrieved by the eXtra JSX VS Code extension.
201
+ * @param {Object} settings $COMMENT#JSDOC#PARAMS#SETTINGS
202
+ * @param {T} settings.reactFolder $COMMENT#JSDOC#PARAMS#REACTFOLDER
203
+ * @param {U} settings.rootPath $COMMENT#JSDOC#PARAMS#ROOTPATH
204
+ * @returns $COMMENT#JSDOC#RETURNS#DEFINECONFIGSETTINGS
205
205
  */
206
206
  export const defineConfigSettings = ({ reactFolder, rootPath }) => {
207
207
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-use-agnostic",
3
- "version": "2.0.2",
3
+ "version": "2.0.4",
4
4
  "description": "Highlights problematic server-client imports in projects made with the Fullstack React Architecture.",
5
5
  "keywords": [
6
6
  "eslint",
@@ -45,14 +45,15 @@
45
45
  "dependencies": {
46
46
  "find-up": "^8.0.0",
47
47
  "get-sourcecode-from-file-path": "^1.2.0",
48
+ "oxc-resolver": "^11.19.1",
48
49
  "resolve-importing-path": "^1.0.4",
50
+ "typescript": "^5.9.3",
49
51
  "typescript-eslint": "^8.32.0"
50
52
  },
51
53
  "devDependencies": {
52
54
  "@typescript-eslint/utils": "^8.31.1",
53
55
  "eslint": ">=9.0.0",
54
- "tsconfig-paths": "^4.2.0",
55
- "typescript": "^5.8.3"
56
+ "tsconfig-paths": "^4.2.0"
56
57
  },
57
58
  "peerDependencies": {
58
59
  "eslint": ">=9.0.0"