eslint-plugin-use-agnostic 0.10.6 → 0.10.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.
@@ -9,15 +9,8 @@ import {
9
9
  resolvedDirectives_resolvedModules,
10
10
  } from "../constants/bases.js";
11
11
 
12
- import jscommentsConfig from "../../../comments.config.js";
13
-
14
12
  /**
15
- * @typedef {import('../../../types/_commons/typedefs').EffectiveDirective} EffectiveDirective
16
- * @typedef {import('../../../types/_commons/typedefs').CommentedDirective} CommentedDirective
17
13
  * @typedef {import('../../../types/_commons/typedefs').ResolvedDirectiveWithoutUseAgnosticStrategies} ResolvedDirectiveWithoutUseAgnosticStrategies
18
- * @typedef {import('../../../types/_commons/typedefs').Agnostic20ConfigName} Agnostic20ConfigName
19
- * @typedef {import('../../../types/_commons/typedefs').Directive21ConfigName} Directive21ConfigName
20
- * @typedef {import('../../../types/_commons/typedefs').UseAgnosticConfigName} UseAgnosticConfigName
21
14
  * @typedef {import('../../../types/_commons/typedefs').Context<string, readonly unknown[]>} Context
22
15
  */
23
16
 
@@ -12,7 +12,7 @@ import {
12
12
  USE_AGNOSTIC_STRATEGIES as COMMONS_USE_AGNOSTIC_STRATEGIES,
13
13
  } from "../../../_commons/constants/bases.js";
14
14
 
15
- import { makeIntroForSpecificViolationMessage as commonsMakeIntroForSpecificViolationMessage } from "../../../_commons/utilities/helpers.js";
15
+ import { makeIntroForSpecificViolationMessage } from "../../../_commons/utilities/helpers.js";
16
16
 
17
17
  import jscommentsConfig from "../../../../comments.config.js";
18
18
 
@@ -22,6 +22,7 @@ import jscommentsConfig from "../../../../comments.config.js";
22
22
  * @typedef {import('../../../../types/directive21/_commons/typedefs.js').CommentedDirectives} CommentedDirectives
23
23
  * @typedef {import('../../../../types/directive21/_commons/typedefs.js').CommentedStrategy} CommentedStrategy
24
24
  * @typedef {import('../../../../types/directive21/_commons/typedefs.js').CommentedStrategies} CommentedStrategies
25
+ * @typedef {import('../../../../types/directive21/_commons/typedefs.js').CommentStyles} CommentStyles
25
26
  */
26
27
 
27
28
  // commented directives
@@ -56,7 +57,7 @@ export const commentedDirectivesArray = Object.freeze([
56
57
  export const commentedDirectivesSet = new Set(commentedDirectivesArray); // no longer used exported to satisfy static type inference
57
58
 
58
59
  // mapped commented directives to their extension rules
59
- export const commentedDirectives_extensionRules = {
60
+ export const commentedDirectives_extensionRules = Object.freeze({
60
61
  [USE_SERVER_LOGICS]: false, // Must not end with 'x'
61
62
  [USE_CLIENT_LOGICS]: false,
62
63
  [USE_AGNOSTIC_LOGICS]: false,
@@ -67,7 +68,7 @@ export const commentedDirectives_extensionRules = {
67
68
  [USE_CLIENT_CONTEXTS]: true,
68
69
  [USE_AGNOSTIC_CONDITIONS]: true,
69
70
  [USE_AGNOSTIC_STRATEGIES]: null, // Any extension allowed
70
- };
71
+ });
71
72
 
72
73
  // commented strategies
73
74
  export const AT_SERVER_LOGICS = "@serverLogics";
@@ -121,23 +122,31 @@ export const specificFailure = "specificFailure";
121
122
  /* commentedDirectives_4RawImplementations */
122
123
 
123
124
  // all formatting styles as an array of [prefix, quote, suffix]
124
- const commentStyles = [
125
- [`// `, `'`, ``], // V1: `// 'directive'`
126
- [`// `, `"`, ``], // V2: `// "directive"`
127
- [`/* `, `'`, ` */`], // V3: `/* 'directive' */`
128
- [`/* `, `"`, ` */`], // V4: `/* "directive" */`
129
- ]; // further inference optimation can be made but is overkill...
125
+ /** @type {CommentStyles} */
126
+ const commentStyles = Object.freeze([
127
+ Object.freeze([`// `, `'`, ``]), // V1: `// 'directive'`
128
+ Object.freeze([`// `, `"`, ``]), // V2: `// "directive"`
129
+ Object.freeze([`\/\* `, `'`, ` \*\/`]), // V3: `/* 'directive' */`
130
+ Object.freeze([`\/\* `, `"`, ` \*\/`]), // V4: `/* "directive" */`
131
+ ]);
130
132
 
131
133
  /**
132
134
  * Makes the array of all four accepted commented directive implementations on a directive basis.
133
- * @param {CommentedDirective} directive The commented directive.
135
+ * @template {CommentedDirective} T
136
+ * @param {T} directive The commented directive.
134
137
  * @returns The array of formatted commented directives.
135
138
  */
136
- const make4RawImplementations = (directive) =>
137
- commentStyles.map(
138
- ([prefix, quote, suffix]) =>
139
- `${prefix}${quote}${directive}${quote}${suffix}`
140
- ); // ...further inference optimation could be an extra challenge but would probably require TypeScript for comfort
139
+ const make4RawImplementations = (directive) => {
140
+ /** @type {readonly [`// '${T}'`, `// "${T}""`, `\/\* '${T}' \*\/`, `\/\* "${T}"" \*\/`]} */
141
+ const rawImplementations = Object.freeze(
142
+ commentStyles.map(
143
+ ([prefix, quote, suffix]) =>
144
+ `${prefix}${quote}${directive}${quote}${suffix}`
145
+ )
146
+ );
147
+
148
+ return rawImplementations;
149
+ };
141
150
 
142
151
  export const commentedDirectives_4RawImplementations = Object.freeze({
143
152
  [USE_SERVER_LOGICS]: make4RawImplementations(USE_SERVER_LOGICS),
@@ -189,7 +198,7 @@ export const makeBlockedImport = (
189
198
  ) => {
190
199
  return Object.freeze({
191
200
  blockedImport: importedFileCommentedDirective,
192
- message: `${commonsMakeIntroForSpecificViolationMessage(
201
+ message: `${makeIntroForSpecificViolationMessage(
193
202
  currentFileCommentedDirective,
194
203
  importedFileCommentedDirective
195
204
  )} ${
@@ -142,7 +142,7 @@ const importedFileFlow = (context, node) => {
142
142
  /* GETTING THE CORRECT DIRECTIVE INTERPRETATION OF STRATEGY FOR AGNOSTIC STRATEGIES MODULES IMPORTS.
143
143
  The Directive-First Architecture does not check whether the export and import Strategies are the same at this time, meaning an @clientLogics strategy could be wrongly imported and interpreted as an @serverLogics strategy.
144
144
 
145
- After a short attempt, the feature to address this (crossingStrategies) is currently canceled, mainly since the amount of work it will require will not be able to be transferred in a future where commented strategies will actually be real syntax.
145
+ After a short attempt, the feature to address this (crossingStrategies) is currently canceled, mainly due to the exponential complexity provided by the different ways in which exports can be made in JavaScript.
146
146
 
147
147
  (Consequently, details below are currently at the stage of wishful thinking.)
148
148
  Strategy exports are planned to be linting in the future within their own Agnostic Strategies Modules to ensure they respect import rules within their own scopes. It may also become possible to check whether the export and import Strategies are the same in the future when identifiers are defined and the same, especially for components modules where a convention could be for all non-type exports to be named and PascalCase. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-use-agnostic",
3
- "version": "0.10.6",
3
+ "version": "0.10.7",
4
4
  "description": "Highlights problematic server-client imports in projects made with the Fullstack React Architecture.",
5
5
  "keywords": [
6
6
  "eslint",