eslint-plugin-use-agnostic 0.10.5 → 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.
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import {
|
|
2
|
+
agnostic20ConfigName,
|
|
3
|
+
directive21ConfigName,
|
|
4
|
+
} from "./library/_commons/constants/bases.js";
|
|
5
|
+
|
|
6
|
+
import { agnostic20Comments } from "./jscomments/agnostic20/constants/bases.js";
|
|
7
|
+
import { directive21Comments } from "./jscomments/directive21/constants/bases.js";
|
|
8
|
+
|
|
9
|
+
const config = Object.freeze({
|
|
10
|
+
comment: "comment", // $COMMENT#COMMENT in code, "comment" on hover when resolved by the VSCode extension JSComments
|
|
11
|
+
[agnostic20ConfigName]: agnostic20Comments,
|
|
12
|
+
[directive21ConfigName]: directive21Comments,
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
export default config;
|
|
16
|
+
|
|
17
|
+
/* Notes
|
|
18
|
+
Aims of the VSCode extension JSComments:
|
|
19
|
+
- automatically capitalizes keys, so here:
|
|
20
|
+
- config.comment would return $COMMENT#COMMENT
|
|
21
|
+
- automatically chain keys within keys, so here
|
|
22
|
+
- config["agnostic20"] would return $COMMENT#AGNOSTIC20#*
|
|
23
|
+
- config["directive21"] would return $COMMENT#DIRECTIVE21#*
|
|
24
|
+
- this way, instead doing a find-replace on a big documentation comment, the comment stays within the config and only the config placeholder is found and replaced for the same results
|
|
25
|
+
*/
|
|
@@ -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
|
|
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
|
-
|
|
125
|
-
|
|
126
|
-
[`// `, `
|
|
127
|
-
[
|
|
128
|
-
[
|
|
129
|
-
|
|
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
|
-
* @
|
|
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
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
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: `${
|
|
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
|
|
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.
|
|
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",
|
|
@@ -22,7 +22,8 @@
|
|
|
22
22
|
"files": [
|
|
23
23
|
"library",
|
|
24
24
|
"types/index.d.ts",
|
|
25
|
-
"jscomments"
|
|
25
|
+
"jscomments",
|
|
26
|
+
"comments.config.js"
|
|
26
27
|
],
|
|
27
28
|
"exports": {
|
|
28
29
|
".": {
|