eslint-plugin-use-agnostic 1.6.7 → 1.6.9
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.
- package/README.md +1 -1
- package/library/_commons/constants/bases.js +6 -4
- package/library/_commons/utilities/helpers.js +21 -21
- package/library/_commons/utilities/walk-ast.js +46 -0
- package/library/agnostic20/_commons/constants/bases.js +57 -57
- package/library/agnostic20/_commons/utilities/flows.js +17 -17
- package/library/agnostic20/_commons/utilities/helpers.js +43 -43
- package/library/agnostic20/config.js +3 -3
- package/library/directive21/_commons/constants/bases.js +106 -85
- package/library/directive21/_commons/rules/import-rules.js +12 -8
- package/library/directive21/_commons/utilities/analyze-exports-re.js +100 -0
- package/library/directive21/_commons/utilities/flows.js +166 -30
- package/library/directive21/_commons/utilities/helpers.js +88 -88
- package/library/directive21/config.js +3 -3
- package/package.json +2 -2
- package/types/index.d.ts +100 -100
|
@@ -7,9 +7,10 @@ import {
|
|
|
7
7
|
EXTENSIONS,
|
|
8
8
|
reExportNotSameMessageId,
|
|
9
9
|
importBreaksCommentedImportRulesMessageId,
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
noCommentedDirectiveMessageId,
|
|
11
|
+
commentedDirectiveVerificationFailedMessageId,
|
|
12
|
+
importNotStrategizedMessageId,
|
|
13
|
+
cantChainImportAcrossEnvironmentsMessageId,
|
|
13
14
|
skip,
|
|
14
15
|
} from "../../../_commons/constants/bases.js";
|
|
15
16
|
import {
|
|
@@ -17,9 +18,12 @@ import {
|
|
|
17
18
|
commentedDirectives_verificationReports,
|
|
18
19
|
// currentFileCommentedDirective,
|
|
19
20
|
// importedFileCommentedDirective,
|
|
21
|
+
// currentFileEnvironment,
|
|
22
|
+
// importedFileEnvironment,
|
|
20
23
|
commentedDirectiveMessage,
|
|
21
24
|
specificViolationMessage,
|
|
22
25
|
specificFailure,
|
|
26
|
+
environments_allowedChainImportEnvironments,
|
|
23
27
|
} from "../constants/bases.js";
|
|
24
28
|
|
|
25
29
|
import { highlightFirstLineOfCode } from "../../../_commons/utilities/helpers.js";
|
|
@@ -33,6 +37,7 @@ import {
|
|
|
33
37
|
getStrategizedDirective,
|
|
34
38
|
addressDirectiveIfAgnosticStrategies,
|
|
35
39
|
} from "./helpers.js";
|
|
40
|
+
import { analyzeExportsForReExports } from "./analyze-exports-re.js";
|
|
36
41
|
|
|
37
42
|
/**
|
|
38
43
|
* @typedef {import('../../../../types/directive21/_commons/typedefs.js').Context} Context
|
|
@@ -41,14 +46,15 @@ import {
|
|
|
41
46
|
* @typedef {import('../../../../types/directive21/_commons/typedefs.js').ExportNamedDeclaration} ExportNamedDeclaration
|
|
42
47
|
* @typedef {import('../../../../types/directive21/_commons/typedefs.js').ExportAllDeclaration} ExportAllDeclaration
|
|
43
48
|
* @typedef {import('../../../../types/directive21/_commons/typedefs.js').ExportDefaultDeclaration} ExportDefaultDeclaration
|
|
49
|
+
* @typedef {import('../../../../types/directive21/_commons/typedefs.js').Environment} Environment
|
|
44
50
|
*/
|
|
45
51
|
|
|
46
52
|
/* currentFileFlow */
|
|
47
53
|
|
|
48
54
|
/**
|
|
49
|
-
*
|
|
50
|
-
* @param {Context} context
|
|
51
|
-
* @returns
|
|
55
|
+
* $COMMENT#JSDOC#DEFINITIONS#DIRECTIVE21#CURRENTFILEFLOW
|
|
56
|
+
* @param {Context} context $COMMENT#JSDOC#PARAMS#CONTEXTB
|
|
57
|
+
* @returns $COMMENT#JSDOC#RETURNS#DIRECTIVE21#CURRENTFILEFLOW
|
|
52
58
|
*/
|
|
53
59
|
export const currentFileFlow = (context) => {
|
|
54
60
|
const skipTrue = { ...skip, verifiedCommentedDirective: undefined };
|
|
@@ -74,7 +80,7 @@ export const currentFileFlow = (context) => {
|
|
|
74
80
|
if (!commentedDirective) {
|
|
75
81
|
context.report({
|
|
76
82
|
loc: highlightFirstLineOfCode(context),
|
|
77
|
-
messageId:
|
|
83
|
+
messageId: noCommentedDirectiveMessageId,
|
|
78
84
|
});
|
|
79
85
|
return skipTrue;
|
|
80
86
|
}
|
|
@@ -89,7 +95,7 @@ export const currentFileFlow = (context) => {
|
|
|
89
95
|
if (!verifiedCommentedDirective) {
|
|
90
96
|
context.report({
|
|
91
97
|
loc: highlightFirstLineOfCode(context),
|
|
92
|
-
messageId:
|
|
98
|
+
messageId: commentedDirectiveVerificationFailedMessageId,
|
|
93
99
|
data: {
|
|
94
100
|
[specificFailure]:
|
|
95
101
|
commentedDirectives_verificationReports[commentedDirective],
|
|
@@ -104,13 +110,17 @@ export const currentFileFlow = (context) => {
|
|
|
104
110
|
/* importedFileFlow */
|
|
105
111
|
|
|
106
112
|
/**
|
|
107
|
-
*
|
|
108
|
-
* @param {Context} context
|
|
109
|
-
* @param {ImportDeclaration} node
|
|
110
|
-
* @returns
|
|
113
|
+
* $COMMENT#JSDOC#DEFINITIONS#DIRECTIVE21#IMPORTEDFILEFLOW
|
|
114
|
+
* @param {Context} context $COMMENT#JSDOC#PARAMS#CONTEXTB
|
|
115
|
+
* @param {ImportDeclaration} node $COMMENT#JSDOC#PARAMS#NODE
|
|
116
|
+
* @returns $COMMENT#JSDOC#RETURNS#DIRECTIVE21#IMPORTEDFILEFLOW (And now we the added results of `analyzeExportsForReExports`.)
|
|
111
117
|
*/
|
|
112
118
|
const importedFileFlow = (context, node) => {
|
|
113
|
-
const skipTrue = {
|
|
119
|
+
const skipTrue = {
|
|
120
|
+
...skip,
|
|
121
|
+
importedFileCommentedDirective: undefined,
|
|
122
|
+
analyzeExportsForReExportsResults: undefined,
|
|
123
|
+
};
|
|
114
124
|
|
|
115
125
|
// finds the full path of the import
|
|
116
126
|
const resolvedImportPath = resolveImportingPath(
|
|
@@ -130,14 +140,18 @@ const importedFileFlow = (context, node) => {
|
|
|
130
140
|
if (!isImportedFileJS) return skipTrue;
|
|
131
141
|
|
|
132
142
|
// GETTING THE DIRECTIVE (or lack thereof) OF THE IMPORTED FILE
|
|
133
|
-
let
|
|
134
|
-
|
|
143
|
+
let {
|
|
144
|
+
commentedDirective: importedFileCommentedDirective,
|
|
145
|
+
sourceCode: importedFileSourceCode,
|
|
146
|
+
} = getCommentedDirectiveFromImportedModule(resolvedImportPath);
|
|
135
147
|
|
|
136
148
|
// returns early if there is no directive or no valid directive (same, but eventually no directive could have defaults)
|
|
137
149
|
if (!importedFileCommentedDirective) {
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
150
|
+
// 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.
|
|
151
|
+
|
|
152
|
+
// console.warn(
|
|
153
|
+
// `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.`
|
|
154
|
+
// ); // The decision not to report has been taken to not inflate the number of warnings.
|
|
141
155
|
return skipTrue;
|
|
142
156
|
}
|
|
143
157
|
|
|
@@ -158,7 +172,7 @@ const importedFileFlow = (context, node) => {
|
|
|
158
172
|
if (importingFileCommentedDirective === null) {
|
|
159
173
|
context.report({
|
|
160
174
|
node,
|
|
161
|
-
messageId:
|
|
175
|
+
messageId: importNotStrategizedMessageId,
|
|
162
176
|
});
|
|
163
177
|
return skipTrue;
|
|
164
178
|
}
|
|
@@ -167,17 +181,37 @@ const importedFileFlow = (context, node) => {
|
|
|
167
181
|
importedFileCommentedDirective = importingFileCommentedDirective;
|
|
168
182
|
}
|
|
169
183
|
|
|
170
|
-
|
|
184
|
+
// you never know
|
|
185
|
+
if (!importedFileSourceCode) {
|
|
186
|
+
console.warn(
|
|
187
|
+
`Somehow, file "${resolvedImportPath}" does not have a SourceCode object obtainable.`
|
|
188
|
+
);
|
|
189
|
+
return {
|
|
190
|
+
skip: undefined,
|
|
191
|
+
importedFileCommentedDirective,
|
|
192
|
+
analyzeExportsForReExportsResults: undefined,
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
const analyzeExportsForReExportsResults = analyzeExportsForReExports(
|
|
197
|
+
importedFileSourceCode
|
|
198
|
+
);
|
|
199
|
+
|
|
200
|
+
return {
|
|
201
|
+
skip: undefined,
|
|
202
|
+
importedFileCommentedDirective,
|
|
203
|
+
analyzeExportsForReExportsResults,
|
|
204
|
+
};
|
|
171
205
|
};
|
|
172
206
|
|
|
173
207
|
/* importsFlow */
|
|
174
208
|
|
|
175
209
|
/**
|
|
176
|
-
*
|
|
177
|
-
* @param {Context} context
|
|
178
|
-
* @param {ImportDeclaration} node
|
|
179
|
-
* @param {CommentedDirective} currentFileCommentedDirective
|
|
180
|
-
* @returns
|
|
210
|
+
* $COMMENT#JSDOC#FORALIASVARIABLES#IMPORTSFLOW
|
|
211
|
+
* @param {Context} context $COMMENT#JSDOC#PARAMS#CONTEXTB
|
|
212
|
+
* @param {ImportDeclaration} node $COMMENT#JSDOC#PARAMS#NODE
|
|
213
|
+
* @param {CommentedDirective} currentFileCommentedDirective $COMMENT#JSDOC#PARAMS#DIRECTIVE21#CURRENTFILECOMMENTEDDIRECTIVE
|
|
214
|
+
* @returns $COMMENT#JSDOC#FORALIASVARIABLES#FLOWRETURNSEARLY
|
|
181
215
|
*/
|
|
182
216
|
export const importsFlow = (context, node, currentFileCommentedDirective) => {
|
|
183
217
|
// does not operate on `import type`
|
|
@@ -212,22 +246,73 @@ export const importsFlow = (context, node, currentFileCommentedDirective) => {
|
|
|
212
246
|
},
|
|
213
247
|
});
|
|
214
248
|
}
|
|
249
|
+
|
|
250
|
+
// new
|
|
251
|
+
if (result.analyzeExportsForReExportsResults) {
|
|
252
|
+
const { reExportsWithSource, reExportsViaLocal } =
|
|
253
|
+
result.analyzeExportsForReExportsResults;
|
|
254
|
+
// console.debug("reExportsWithSource are:", reExportsWithSource);
|
|
255
|
+
// console.debug("reExportsViaLocal are:", reExportsViaLocal);
|
|
256
|
+
// console.debug(
|
|
257
|
+
// "currentFileCommentedDirective is:",
|
|
258
|
+
// currentFileCommentedDirective
|
|
259
|
+
// );
|
|
260
|
+
// console.debug(
|
|
261
|
+
// "importedFileCommentedDirective is:",
|
|
262
|
+
// importedFileCommentedDirective
|
|
263
|
+
// );
|
|
264
|
+
// console.debug(context.sourceCode.getText(node));
|
|
265
|
+
|
|
266
|
+
// immediately returns if no re-exports are found
|
|
267
|
+
if (reExportsWithSource.length === 0 && reExportsViaLocal.length === 0)
|
|
268
|
+
return;
|
|
269
|
+
|
|
270
|
+
/** @type {Environment} */
|
|
271
|
+
const currentFileEnvironment = currentFileCommentedDirective.split(" ")[1];
|
|
272
|
+
/** @type {Environment} */
|
|
273
|
+
const importedFileEnvironment =
|
|
274
|
+
importedFileCommentedDirective.split(" ")[1];
|
|
275
|
+
// console.debug("currentFileEnvironment is:", currentFileEnvironment);
|
|
276
|
+
// console.debug("importedFileEnvironment is:", importedFileEnvironment);
|
|
277
|
+
|
|
278
|
+
if (
|
|
279
|
+
!environments_allowedChainImportEnvironments[
|
|
280
|
+
currentFileEnvironment
|
|
281
|
+
].includes(importedFileEnvironment)
|
|
282
|
+
) {
|
|
283
|
+
// console.debug(cantChainImportAcrossEnvironmentsMessageId);
|
|
284
|
+
|
|
285
|
+
context.report({
|
|
286
|
+
node,
|
|
287
|
+
messageId: cantChainImportAcrossEnvironmentsMessageId,
|
|
288
|
+
data: {
|
|
289
|
+
// currentFileEnvironment:
|
|
290
|
+
currentFileEnvironment,
|
|
291
|
+
// importedFileEnvironment:
|
|
292
|
+
importedFileEnvironment,
|
|
293
|
+
},
|
|
294
|
+
});
|
|
295
|
+
}
|
|
296
|
+
}
|
|
215
297
|
};
|
|
216
298
|
|
|
217
299
|
/* allExportsFlow */
|
|
218
300
|
|
|
219
301
|
/**
|
|
220
|
-
*
|
|
221
|
-
* @param {Context} context
|
|
222
|
-
* @param {ExportNamedDeclaration | ExportAllDeclaration | ExportDefaultDeclaration} node
|
|
223
|
-
* @param {CommentedDirective} currentFileCommentedDirective
|
|
224
|
-
* @returns
|
|
302
|
+
* $COMMENT#JSDOC#DEFINITIONS#DIRECTIVE21#ALLEXPORTSFLOW
|
|
303
|
+
* @param {Context} context $COMMENT#JSDOC#PARAMS#CONTEXTB
|
|
304
|
+
* @param {ExportNamedDeclaration | ExportAllDeclaration | ExportDefaultDeclaration} node $COMMENT#JSDOC#PARAMS#NODE
|
|
305
|
+
* @param {CommentedDirective} currentFileCommentedDirective $COMMENT#JSDOC#PARAMS#DIRECTIVE21#CURRENTFILECOMMENTEDDIRECTIVE
|
|
306
|
+
* @returns $COMMENT#JSDOC#FORALIASVARIABLES#FLOWRETURNSEARLY
|
|
225
307
|
*/
|
|
226
308
|
export const allExportsFlow = (
|
|
227
309
|
context,
|
|
228
310
|
node,
|
|
229
311
|
currentFileCommentedDirective
|
|
230
312
|
) => {
|
|
313
|
+
// saving the original commented directive (speficially for "use agnostic strategies")
|
|
314
|
+
const originalCurrentFileCommentedDirective = currentFileCommentedDirective;
|
|
315
|
+
|
|
231
316
|
// does not operate on `export type`
|
|
232
317
|
if (node.exportKind === "type") return;
|
|
233
318
|
|
|
@@ -269,5 +354,56 @@ export const allExportsFlow = (
|
|
|
269
354
|
},
|
|
270
355
|
});
|
|
271
356
|
}
|
|
357
|
+
|
|
358
|
+
// new
|
|
359
|
+
if (result.analyzeExportsForReExportsResults) {
|
|
360
|
+
const { reExportsWithSource, reExportsViaLocal } =
|
|
361
|
+
result.analyzeExportsForReExportsResults;
|
|
362
|
+
// console.debug("reExportsWithSource are:", reExportsWithSource);
|
|
363
|
+
// console.debug("reExportsViaLocal are:", reExportsViaLocal);
|
|
364
|
+
// console.debug(
|
|
365
|
+
// "currentFileCommentedDirective is:",
|
|
366
|
+
// currentFileCommentedDirective
|
|
367
|
+
// );
|
|
368
|
+
// console.debug(
|
|
369
|
+
// "importedFileCommentedDirective is:",
|
|
370
|
+
// importedFileCommentedDirective
|
|
371
|
+
// );
|
|
372
|
+
// console.debug(context.sourceCode.getText(node));
|
|
373
|
+
|
|
374
|
+
// immediately returns if no re-exports are found
|
|
375
|
+
if (reExportsWithSource.length === 0 && reExportsViaLocal.length === 0)
|
|
376
|
+
return;
|
|
377
|
+
|
|
378
|
+
if (originalCurrentFileCommentedDirective !== USE_AGNOSTIC_STRATEGIES) {
|
|
379
|
+
/** @type {Environment} */
|
|
380
|
+
const currentFileEnvironment =
|
|
381
|
+
currentFileCommentedDirective.split(" ")[1];
|
|
382
|
+
/** @type {Environment} */
|
|
383
|
+
const importedFileEnvironment =
|
|
384
|
+
importedFileCommentedDirective.split(" ")[1];
|
|
385
|
+
// console.debug("currentFileEnvironment is:", currentFileEnvironment);
|
|
386
|
+
// console.debug("importedFileEnvironment is:", importedFileEnvironment);
|
|
387
|
+
|
|
388
|
+
if (
|
|
389
|
+
!environments_allowedChainImportEnvironments[
|
|
390
|
+
currentFileEnvironment
|
|
391
|
+
].includes(importedFileEnvironment)
|
|
392
|
+
) {
|
|
393
|
+
// console.debug(cantChainImportAcrossEnvironmentsMessageId);
|
|
394
|
+
|
|
395
|
+
context.report({
|
|
396
|
+
node,
|
|
397
|
+
messageId: cantChainImportAcrossEnvironmentsMessageId,
|
|
398
|
+
data: {
|
|
399
|
+
// currentFileEnvironment:
|
|
400
|
+
currentFileEnvironment,
|
|
401
|
+
// importedFileEnvironment:
|
|
402
|
+
importedFileEnvironment,
|
|
403
|
+
},
|
|
404
|
+
});
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
}
|
|
272
408
|
}
|
|
273
409
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getSourceCodeFromFilePath } from "get-sourcecode-from-file-path";
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { exportNotStrategizedMessageId } from "../../../_commons/constants/bases.js";
|
|
4
4
|
import {
|
|
5
5
|
USE_AGNOSTIC_STRATEGIES,
|
|
6
6
|
commentedDirectivesArray,
|
|
@@ -31,9 +31,9 @@ import {
|
|
|
31
31
|
/* getCommentedDirectiveFromSourceCode */
|
|
32
32
|
|
|
33
33
|
/**
|
|
34
|
-
*
|
|
35
|
-
* @param {string} string
|
|
36
|
-
* @returns
|
|
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
|
-
*
|
|
50
|
-
* @param {string} string
|
|
51
|
-
* @returns
|
|
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
|
-
*
|
|
62
|
-
* @param {string} string
|
|
63
|
-
* @returns
|
|
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
|
-
*
|
|
73
|
+
* $COMMENT#JSDOC#DEFINITIONS#DIRECTIVE21#GETCOMMENTEDDIRECTIVEFROMSOURCECODE1
|
|
74
74
|
*
|
|
75
|
-
*
|
|
76
|
-
* -
|
|
77
|
-
* -
|
|
78
|
-
* -
|
|
79
|
-
* -
|
|
80
|
-
* -
|
|
81
|
-
* -
|
|
82
|
-
* -
|
|
83
|
-
* -
|
|
84
|
-
* -
|
|
85
|
-
* -
|
|
86
|
-
* @param {SourceCode} sourceCode
|
|
87
|
-
* @returns
|
|
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 all comments from the source code
|
|
@@ -132,21 +132,21 @@ export const getCommentedDirectiveFromSourceCode = (sourceCode) => {
|
|
|
132
132
|
/* getCommentedDirectiveFromCurrentModule */
|
|
133
133
|
|
|
134
134
|
/**
|
|
135
|
-
*
|
|
135
|
+
* $COMMENT#JSDOC#DEFINITIONS#DIRECTIVE21#GETCOMMENTEDDIRECTIVEFROMCURRENTMODULE1
|
|
136
136
|
*
|
|
137
|
-
*
|
|
138
|
-
* -
|
|
139
|
-
* -
|
|
140
|
-
* -
|
|
141
|
-
* -
|
|
142
|
-
* -
|
|
143
|
-
* -
|
|
144
|
-
* -
|
|
145
|
-
* -
|
|
146
|
-
* -
|
|
147
|
-
* -
|
|
148
|
-
* @param {Context} context
|
|
149
|
-
* @returns
|
|
137
|
+
* $COMMENT#JSDOC#DEFINITIONS#DIRECTIVE21#GETCOMMENTEDDIRECTIVEFROMSOURCECODE2
|
|
138
|
+
* - $COMMENT#JSDOC#DETAILS#DIRECTIVE21#USESERVERLOGICSA
|
|
139
|
+
* - $COMMENT#JSDOC#DETAILS#DIRECTIVE21#USECLIENTLOGICSA
|
|
140
|
+
* - $COMMENT#JSDOC#DETAILS#DIRECTIVE21#USEAGNOSTICLOGICSA
|
|
141
|
+
* - $COMMENT#JSDOC#DETAILS#DIRECTIVE21#USESERVERCOMPONENTSA
|
|
142
|
+
* - $COMMENT#JSDOC#DETAILS#DIRECTIVE21#USECLIENTCOMPONENTSA
|
|
143
|
+
* - $COMMENT#JSDOC#DETAILS#DIRECTIVE21#USEAGNOSTICCOMPONENTSA
|
|
144
|
+
* - $COMMENT#JSDOC#DETAILS#DIRECTIVE21#USESERVERFUNCTIONSA
|
|
145
|
+
* - $COMMENT#JSDOC#DETAILS#DIRECTIVE21#USECLIENTCONTEXTSA
|
|
146
|
+
* - $COMMENT#JSDOC#DETAILS#DIRECTIVE21#USEAGNOSTICCONDITIONSA
|
|
147
|
+
* - $COMMENT#JSDOC#DETAILS#DIRECTIVE21#USEAGNOSTICSTRATEGIESA
|
|
148
|
+
* @param {Context} context $COMMENT#JSDOC#PARAMS#CONTEXTB
|
|
149
|
+
* @returns $COMMENT#JSDOC#RETURNS#DIRECTIVE21#GETCOMMENTEDDIRECTIVEFROMSOURCECODE
|
|
150
150
|
*/
|
|
151
151
|
export const getCommentedDirectiveFromCurrentModule = (context) => {
|
|
152
152
|
const sourceCode = context.sourceCode;
|
|
@@ -158,46 +158,46 @@ export const getCommentedDirectiveFromCurrentModule = (context) => {
|
|
|
158
158
|
/* getCommentedDirectiveFromImportedModule */
|
|
159
159
|
|
|
160
160
|
/**
|
|
161
|
-
*
|
|
161
|
+
* $COMMENT#JSDOC#DEFINITIONS#DIRECTIVE21#GETCOMMENTEDDIRECTIVEFROMIMPORTEDMODULE1
|
|
162
162
|
*
|
|
163
|
-
*
|
|
164
|
-
* -
|
|
165
|
-
* -
|
|
166
|
-
* -
|
|
167
|
-
* -
|
|
168
|
-
* -
|
|
169
|
-
* -
|
|
170
|
-
* -
|
|
171
|
-
* -
|
|
172
|
-
* -
|
|
173
|
-
* -
|
|
174
|
-
* @param {string} resolvedPath
|
|
175
|
-
* @returns
|
|
163
|
+
* $COMMENT#JSDOC#DEFINITIONS#DIRECTIVE21#GETCOMMENTEDDIRECTIVEFROMSOURCECODE2
|
|
164
|
+
* - $COMMENT#JSDOC#DETAILS#DIRECTIVE21#USESERVERLOGICSA
|
|
165
|
+
* - $COMMENT#JSDOC#DETAILS#DIRECTIVE21#USECLIENTLOGICSA
|
|
166
|
+
* - $COMMENT#JSDOC#DETAILS#DIRECTIVE21#USEAGNOSTICLOGICSA
|
|
167
|
+
* - $COMMENT#JSDOC#DETAILS#DIRECTIVE21#USESERVERCOMPONENTSA
|
|
168
|
+
* - $COMMENT#JSDOC#DETAILS#DIRECTIVE21#USECLIENTCOMPONENTSA
|
|
169
|
+
* - $COMMENT#JSDOC#DETAILS#DIRECTIVE21#USEAGNOSTICCOMPONENTSA
|
|
170
|
+
* - $COMMENT#JSDOC#DETAILS#DIRECTIVE21#USESERVERFUNCTIONSA
|
|
171
|
+
* - $COMMENT#JSDOC#DETAILS#DIRECTIVE21#USECLIENTCONTEXTSA
|
|
172
|
+
* - $COMMENT#JSDOC#DETAILS#DIRECTIVE21#USEAGNOSTICCONDITIONSA
|
|
173
|
+
* - $COMMENT#JSDOC#DETAILS#DIRECTIVE21#USEAGNOSTICSTRATEGIESA
|
|
174
|
+
* @param {string} resolvedPath $COMMENT#JSDOC#PARAMS#RESOLVEDPATH
|
|
175
|
+
* @returns $COMMENT#JSDOC#RETURNS#DIRECTIVE21#GETCOMMENTEDDIRECTIVEFROMSOURCECODE Now also provides the obtained SourceCode object.
|
|
176
176
|
*/
|
|
177
177
|
export const getCommentedDirectiveFromImportedModule = (resolvedPath) => {
|
|
178
178
|
const sourceCode = getSourceCodeFromFilePath(resolvedPath);
|
|
179
179
|
const commentedDirective = getCommentedDirectiveFromSourceCode(sourceCode);
|
|
180
180
|
|
|
181
|
-
return commentedDirective;
|
|
181
|
+
return { commentedDirective, sourceCode };
|
|
182
182
|
};
|
|
183
183
|
|
|
184
184
|
/* getVerifiedCommentedDirective */
|
|
185
185
|
|
|
186
186
|
/**
|
|
187
|
-
*
|
|
188
|
-
* -
|
|
189
|
-
* -
|
|
190
|
-
* -
|
|
191
|
-
* -
|
|
192
|
-
* -
|
|
193
|
-
* -
|
|
194
|
-
* -
|
|
195
|
-
* -
|
|
196
|
-
* -
|
|
197
|
-
* -
|
|
198
|
-
* @param {CommentedDirective} directive
|
|
199
|
-
* @param {Extension} extension
|
|
200
|
-
* @returns
|
|
187
|
+
* $COMMENT#JSDOC#DEFINITIONS#DIRECTIVE21#GETVERIFIEDCOMMENTEDDIRECTIVE
|
|
188
|
+
* - $COMMENT#JSDOC#DETAILS#DIRECTIVE21#USESERVERLOGICSB
|
|
189
|
+
* - $COMMENT#JSDOC#DETAILS#DIRECTIVE21#USECLIENTLOGICSB
|
|
190
|
+
* - $COMMENT#JSDOC#DETAILS#DIRECTIVE21#USEAGNOSTICLOGICSB
|
|
191
|
+
* - $COMMENT#JSDOC#DETAILS#DIRECTIVE21#USESERVERCOMPONENTSB
|
|
192
|
+
* - $COMMENT#JSDOC#DETAILS#DIRECTIVE21#USECLIENTCOMPONENTSB
|
|
193
|
+
* - $COMMENT#JSDOC#DETAILS#DIRECTIVE21#USEAGNOSTICCOMPONENTSB
|
|
194
|
+
* - $COMMENT#JSDOC#DETAILS#DIRECTIVE21#USESERVERFUNCTIONSB
|
|
195
|
+
* - $COMMENT#JSDOC#DETAILS#DIRECTIVE21#USECLIENTCONTEXTSB
|
|
196
|
+
* - $COMMENT#JSDOC#DETAILS#DIRECTIVE21#USEAGNOSTICCONDITIONSB
|
|
197
|
+
* - $COMMENT#JSDOC#DETAILS#DIRECTIVE21#USEAGNOSTICSTRATEGIESB
|
|
198
|
+
* @param {CommentedDirective} directive $COMMENT#JSDOC#PARAMS#DIRECTIVE21#DIRECTIVE
|
|
199
|
+
* @param {Extension} extension $COMMENT#JSDOC#PARAMS#EXTENSION
|
|
200
|
+
* @returns $COMMENT#JSDOC#RETURNS#DIRECTIVE21#GETVERIFIEDCOMMENTEDDIRECTIVE
|
|
201
201
|
*/
|
|
202
202
|
export const getVerifiedCommentedDirective = (directive, extension) => {
|
|
203
203
|
const rule = commentedDirectives_extensionRules[directive];
|
|
@@ -214,10 +214,10 @@ export const getVerifiedCommentedDirective = (directive, extension) => {
|
|
|
214
214
|
/* getStrategizedDirective */
|
|
215
215
|
|
|
216
216
|
/**
|
|
217
|
-
*
|
|
218
|
-
* @param {Context} context
|
|
219
|
-
* @param {ImportDeclaration | ExportNamedDeclaration | ExportAllDeclaration | ExportDefaultDeclaration} node
|
|
220
|
-
* @returns
|
|
217
|
+
* $COMMENT#JSDOC#DEFINITIONS#DIRECTIVE21#GETSTRATEGIZEDDIRECTIVE
|
|
218
|
+
* @param {Context} context $COMMENT#JSDOC#PARAMS#CONTEXTB
|
|
219
|
+
* @param {ImportDeclaration | ExportNamedDeclaration | ExportAllDeclaration | ExportDefaultDeclaration} node $COMMENT#JSDOC#PARAMS#NODE
|
|
220
|
+
* @returns $COMMENT#JSDOC#RETURNS#DIRECTIVE21#GETSTRATEGIZEDDIRECTIVE
|
|
221
221
|
*/
|
|
222
222
|
export const getStrategizedDirective = (context, node) => {
|
|
223
223
|
// gets the first nested `/* */` comment inside the node
|
|
@@ -246,11 +246,11 @@ export const getStrategizedDirective = (context, node) => {
|
|
|
246
246
|
/* addressDirectiveIfAgnosticStrategies */
|
|
247
247
|
|
|
248
248
|
/**
|
|
249
|
-
*
|
|
250
|
-
* @param {Context} context
|
|
251
|
-
* @param {ExportNamedDeclaration | ExportAllDeclaration | ExportDefaultDeclaration} node
|
|
252
|
-
* @param {CommentedDirective} currentFileCommentedDirective
|
|
253
|
-
* @returns
|
|
249
|
+
* $COMMENT#JSDOC#DEFINITIONS#DIRECTIVE21#ADDRESSDIRECTIVEIFAGNOSTICSTRATEGIES
|
|
250
|
+
* @param {Context} context $COMMENT#JSDOC#PARAMS#CONTEXTB
|
|
251
|
+
* @param {ExportNamedDeclaration | ExportAllDeclaration | ExportDefaultDeclaration} node $COMMENT#JSDOC#PARAMS#NODE
|
|
252
|
+
* @param {CommentedDirective} currentFileCommentedDirective $COMMENT#JSDOC#PARAMS#DIRECTIVE21#CURRENTFILECOMMENTEDDIRECTIVE
|
|
253
|
+
* @returns $COMMENT#JSDOC#RETURNS#DIRECTIVE21#ADDRESSDIRECTIVEIFAGNOSTICSTRATEGIES
|
|
254
254
|
*/
|
|
255
255
|
export const addressDirectiveIfAgnosticStrategies = (
|
|
256
256
|
context,
|
|
@@ -266,7 +266,7 @@ export const addressDirectiveIfAgnosticStrategies = (
|
|
|
266
266
|
if (exportStrategizedDirective === null) {
|
|
267
267
|
context.report({
|
|
268
268
|
node,
|
|
269
|
-
messageId:
|
|
269
|
+
messageId: exportNotStrategizedMessageId,
|
|
270
270
|
});
|
|
271
271
|
}
|
|
272
272
|
|
|
@@ -276,10 +276,10 @@ export const addressDirectiveIfAgnosticStrategies = (
|
|
|
276
276
|
/* isImportBlocked */
|
|
277
277
|
|
|
278
278
|
/**
|
|
279
|
-
*
|
|
280
|
-
* @param {CommentedDirectiveWithoutUseAgnosticStrategies} currentFileCommentedDirective
|
|
281
|
-
* @param {CommentedDirectiveWithoutUseAgnosticStrategies} importedFileCommentedDirective
|
|
282
|
-
* @returns
|
|
279
|
+
* $COMMENT#JSDOC#DEFINITIONS#DIRECTIVE21#ISIMPORTBLOCKED
|
|
280
|
+
* @param {CommentedDirectiveWithoutUseAgnosticStrategies} currentFileCommentedDirective $COMMENT#JSDOC#PARAMS#DIRECTIVE21#CURRENTFILECOMMENTEDDIRECTIVE
|
|
281
|
+
* @param {CommentedDirectiveWithoutUseAgnosticStrategies} importedFileCommentedDirective $COMMENT#JSDOC#PARAMS#DIRECTIVE21#IMPORTEDFILECOMMENTEDDIRECTIVE
|
|
282
|
+
* @returns $COMMENT#JSDOC#RETURNS#DIRECTIVE21#ISIMPORTBLOCKED
|
|
283
283
|
*/
|
|
284
284
|
export const isImportBlocked = (
|
|
285
285
|
currentFileCommentedDirective,
|
|
@@ -294,9 +294,9 @@ export const isImportBlocked = (
|
|
|
294
294
|
/* makeMessageFromCurrentFileCommentedDirective */
|
|
295
295
|
|
|
296
296
|
/**
|
|
297
|
-
*
|
|
298
|
-
* @param {CommentedDirectiveWithoutUseAgnosticStrategies} commentedDirective
|
|
299
|
-
* @returns
|
|
297
|
+
* $COMMENT#JSDOC#DEFINITIONS#DIRECTIVE21#MAKEMESSAGEFROMCURRENTFILECOMMENTEDDIRECTIVE
|
|
298
|
+
* @param {CommentedDirectiveWithoutUseAgnosticStrategies} commentedDirective $COMMENT#JSDOC#PARAMS#DIRECTIVE21#COMMENTEDDIRECTIVE
|
|
299
|
+
* @returns $COMMENT#JSDOC#RETURNS#DIRECTIVE21#MAKEMESSAGEFROMCURRENTFILECOMMENTEDDIRECTIVE
|
|
300
300
|
*/
|
|
301
301
|
export const makeMessageFromCurrentFileCommentedDirective = (
|
|
302
302
|
commentedDirective
|
|
@@ -309,10 +309,10 @@ export const makeMessageFromCurrentFileCommentedDirective = (
|
|
|
309
309
|
/* findSpecificViolationMessage */
|
|
310
310
|
|
|
311
311
|
/**
|
|
312
|
-
*
|
|
313
|
-
* @param {CommentedDirectiveWithoutUseAgnosticStrategies} currentFileCommentedDirective
|
|
314
|
-
* @param {CommentedDirectiveWithoutUseAgnosticStrategies} importedFileCommentedDirective
|
|
315
|
-
* @returns
|
|
312
|
+
* $COMMENT#JSDOC#DEFINITIONS#DIRECTIVE21#FINDSPECIFICVIOLATIONMESSAGE
|
|
313
|
+
* @param {CommentedDirectiveWithoutUseAgnosticStrategies} currentFileCommentedDirective $COMMENT#JSDOC#PARAMS#DIRECTIVE21#CURRENTFILECOMMENTEDDIRECTIVE
|
|
314
|
+
* @param {CommentedDirectiveWithoutUseAgnosticStrategies} importedFileCommentedDirective $COMMENT#JSDOC#PARAMS#DIRECTIVE21#IMPORTEDFILECOMMENTEDDIRECTIVE
|
|
315
|
+
* @returns $COMMENT#JSDOC#RETURNS#FINDSPECIFICVIOLATIONMESSAGE
|
|
316
316
|
*/
|
|
317
317
|
export const findSpecificViolationMessage = (
|
|
318
318
|
currentFileCommentedDirective,
|
|
@@ -12,9 +12,9 @@ import {
|
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
|
-
*
|
|
16
|
-
* @param {Plugin} plugin
|
|
17
|
-
* @returns
|
|
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.6.
|
|
3
|
+
"version": "1.6.9",
|
|
4
4
|
"description": "Highlights problematic server-client imports in projects made with the Fullstack React Architecture.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"eslint",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
46
|
"find-up": "^8.0.0",
|
|
47
|
-
"get-sourcecode-from-file-path": "^1.1.
|
|
47
|
+
"get-sourcecode-from-file-path": "^1.1.3",
|
|
48
48
|
"resolve-importing-path": "^1.0.3",
|
|
49
49
|
"typescript-eslint": "^8.32.0"
|
|
50
50
|
},
|