eslint-plugin-use-agnostic 2.0.7 → 2.0.8
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.
|
@@ -101,6 +101,7 @@ In this context, {{ ${specificFailure} }} `,
|
|
|
101
101
|
rootPath,
|
|
102
102
|
tsConfigPaths,
|
|
103
103
|
);
|
|
104
|
+
console.debug("absoluteTsConfigPaths is:", absoluteTsConfigPaths);
|
|
104
105
|
const resolver = makeResolverFromAbsoluteTsConfigPaths(
|
|
105
106
|
absoluteTsConfigPaths,
|
|
106
107
|
);
|
|
@@ -111,17 +112,17 @@ In this context, {{ ${specificFailure} }} `,
|
|
|
111
112
|
|
|
112
113
|
return {
|
|
113
114
|
ImportDeclaration: (node) =>
|
|
114
|
-
importsFlow(context, node, verifiedCommentedDirective),
|
|
115
|
+
importsFlow(context, node, verifiedCommentedDirective, resolver),
|
|
115
116
|
ImportExpression: (node) =>
|
|
116
|
-
importsFlow(context, node, verifiedCommentedDirective),
|
|
117
|
+
importsFlow(context, node, verifiedCommentedDirective, resolver),
|
|
117
118
|
ExportNamedDeclaration: (node) =>
|
|
118
|
-
allExportsFlow(context, node, verifiedCommentedDirective),
|
|
119
|
+
allExportsFlow(context, node, verifiedCommentedDirective, resolver),
|
|
119
120
|
ExportAllDeclaration: (node) =>
|
|
120
|
-
allExportsFlow(context, node, verifiedCommentedDirective),
|
|
121
|
+
allExportsFlow(context, node, verifiedCommentedDirective, resolver),
|
|
121
122
|
ExportDefaultDeclaration: (node) =>
|
|
122
|
-
allExportsFlow(context, node, verifiedCommentedDirective),
|
|
123
|
+
allExportsFlow(context, node, verifiedCommentedDirective, resolver),
|
|
123
124
|
CallExpression: (node) =>
|
|
124
|
-
importsFlowRequire(context, node, verifiedCommentedDirective),
|
|
125
|
+
importsFlowRequire(context, node, verifiedCommentedDirective, resolver),
|
|
125
126
|
|
|
126
127
|
FunctionDeclaration: (node) =>
|
|
127
128
|
functionDeclarationFlow(context, node, verifiedCommentedDirective),
|
|
@@ -135,14 +136,11 @@ In this context, {{ ${specificFailure} }} `,
|
|
|
135
136
|
|
|
136
137
|
const getTsConfigPaths = (rootPath) => {
|
|
137
138
|
const tsConfigJsonPath = path.join(rootPath, "tsconfig.json");
|
|
138
|
-
console.debug("tsConfigJsonPath is:", tsConfigJsonPath);
|
|
139
|
-
|
|
140
139
|
const parsed = ts.getParsedCommandLineOfConfigFile(
|
|
141
140
|
tsConfigJsonPath,
|
|
142
141
|
{},
|
|
143
142
|
ts.sys,
|
|
144
143
|
);
|
|
145
|
-
console.debug(tsConfigJsonPath);
|
|
146
144
|
|
|
147
145
|
if (!parsed) return {};
|
|
148
146
|
|
|
@@ -68,6 +68,7 @@ import { analyzeExportsForReExports } from "./analyze-exports-re.js";
|
|
|
68
68
|
* @typedef {import('../../../../types/directive21/_commons/typedefs.js').JSXOpeningElement} JSXOpeningElement
|
|
69
69
|
* @typedef {import('../../../../types/directive21/_commons/typedefs.js').Parameter} Parameter
|
|
70
70
|
* @typedef {import('../../../../types/directive21/_commons/typedefs.js').Environment} Environment
|
|
71
|
+
* @typedef {import('../../../../types/directive21/_commons/typedefs.js').ResolverFactory} ResolverFactory
|
|
71
72
|
*/
|
|
72
73
|
|
|
73
74
|
/* currentFileFlow */
|
|
@@ -234,9 +235,10 @@ export const currentFileFlow = (context) => {
|
|
|
234
235
|
* $COMMENT#JSDOC#DEFINITIONS#DIRECTIVE21#IMPORTEDFILEFLOW
|
|
235
236
|
* @param {Context} context $COMMENT#JSDOC#PARAMS#CONTEXTB
|
|
236
237
|
* @param {ImportDeclaration} node $COMMENT#JSDOC#PARAMS#NODE
|
|
238
|
+
* @param {ResolverFactory} resolver
|
|
237
239
|
* @returns $COMMENT#JSDOC#RETURNS#DIRECTIVE21#IMPORTEDFILEFLOW
|
|
238
240
|
*/
|
|
239
|
-
const importedFileFlow = (context, node) => {
|
|
241
|
+
const importedFileFlow = (context, node, resolver) => {
|
|
240
242
|
const skipTrue = {
|
|
241
243
|
...skip,
|
|
242
244
|
importedFileCommentedDirective: undefined,
|
|
@@ -244,13 +246,18 @@ const importedFileFlow = (context, node) => {
|
|
|
244
246
|
};
|
|
245
247
|
|
|
246
248
|
// finds the full path of the import
|
|
247
|
-
const resolvedImportPath = resolveImportingPath(
|
|
248
|
-
|
|
249
|
+
// const resolvedImportPath = resolveImportingPath(
|
|
250
|
+
// path.dirname(context.filename),
|
|
251
|
+
// node.source.value,
|
|
252
|
+
// findUpSync("tsconfig.json", {
|
|
253
|
+
// cwd: path.dirname(context.filename),
|
|
254
|
+
// }) ?? context.cwd,
|
|
255
|
+
// );
|
|
256
|
+
const resolvedImportPath = resolver.resolveFileSync(
|
|
257
|
+
context.filename,
|
|
249
258
|
node.source.value,
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
}) ?? context.cwd,
|
|
253
|
-
);
|
|
259
|
+
).path;
|
|
260
|
+
console.debug("resolvedImportPath is:", resolvedImportPath);
|
|
254
261
|
|
|
255
262
|
// does not operate on paths it did not resolve
|
|
256
263
|
if (resolvedImportPath === null) return skipTrue;
|
|
@@ -336,9 +343,10 @@ const importedFileFlow = (context, node) => {
|
|
|
336
343
|
* $COMMENT#JSDOC#DEFINITIONS#DIRECTIVE21#IMPORTEDFILEFLOWREQUIRE
|
|
337
344
|
* @param {Context} context $COMMENT#JSDOC#PARAMS#CONTEXTB
|
|
338
345
|
* @param {CallExpression} node $COMMENT#JSDOC#PARAMS#NODE
|
|
346
|
+
* @param {ResolverFactory} resolver
|
|
339
347
|
* @returns $COMMENT#JSDOC#RETURNS#DIRECTIVE21#IMPORTEDFILEFLOW
|
|
340
348
|
*/
|
|
341
|
-
const importedFileFlowRequire = (context, node) => {
|
|
349
|
+
const importedFileFlowRequire = (context, node, resolver) => {
|
|
342
350
|
const skipTrue = {
|
|
343
351
|
...skip,
|
|
344
352
|
importedFileCommentedDirective: undefined,
|
|
@@ -356,13 +364,18 @@ const importedFileFlowRequire = (context, node) => {
|
|
|
356
364
|
if (typeof importPath !== "string") return skipTrue;
|
|
357
365
|
|
|
358
366
|
// finds the full path of the import
|
|
359
|
-
const resolvedImportPath = resolveImportingPath(
|
|
360
|
-
|
|
367
|
+
// const resolvedImportPath = resolveImportingPath(
|
|
368
|
+
// path.dirname(context.filename),
|
|
369
|
+
// importPath,
|
|
370
|
+
// findUpSync("tsconfig.json", {
|
|
371
|
+
// cwd: path.dirname(context.filename),
|
|
372
|
+
// }) ?? context.cwd,
|
|
373
|
+
// );
|
|
374
|
+
const resolvedImportPath = resolver.resolveFileSync(
|
|
375
|
+
context.filename,
|
|
361
376
|
importPath,
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
}) ?? context.cwd,
|
|
365
|
-
);
|
|
377
|
+
).path;
|
|
378
|
+
console.debug("resolvedImportPath (require) is:", resolvedImportPath);
|
|
366
379
|
|
|
367
380
|
// does not operate on paths it did not resolve
|
|
368
381
|
if (resolvedImportPath === null) return skipTrue;
|
|
@@ -448,13 +461,19 @@ const importedFileFlowRequire = (context, node) => {
|
|
|
448
461
|
* @param {Context} context $COMMENT#JSDOC#PARAMS#CONTEXTB
|
|
449
462
|
* @param {ImportDeclaration} node $COMMENT#JSDOC#PARAMS#NODE
|
|
450
463
|
* @param {CommentedDirective} currentFileCommentedDirective $COMMENT#JSDOC#PARAMS#DIRECTIVE21#CURRENTFILECOMMENTEDDIRECTIVE
|
|
464
|
+
* @param {ResolverFactory} resolver
|
|
451
465
|
* @returns $COMMENT#JSDOC#FORALIASVARIABLES#FLOWRETURNSEARLY
|
|
452
466
|
*/
|
|
453
|
-
export const importsFlow = (
|
|
467
|
+
export const importsFlow = (
|
|
468
|
+
context,
|
|
469
|
+
node,
|
|
470
|
+
currentFileCommentedDirective,
|
|
471
|
+
resolver,
|
|
472
|
+
) => {
|
|
454
473
|
// does not operate on `import type`
|
|
455
474
|
if (node.importKind === "type") return;
|
|
456
475
|
|
|
457
|
-
const result = importedFileFlow(context, node);
|
|
476
|
+
const result = importedFileFlow(context, node, resolver);
|
|
458
477
|
|
|
459
478
|
if (result.skip) return;
|
|
460
479
|
const { importedFileCommentedDirective } = result;
|
|
@@ -525,14 +544,16 @@ export const importsFlow = (context, node, currentFileCommentedDirective) => {
|
|
|
525
544
|
* @param {Context} context $COMMENT#JSDOC#PARAMS#CONTEXTB
|
|
526
545
|
* @param {CallExpression} node $COMMENT#JSDOC#PARAMS#NODE
|
|
527
546
|
* @param {CommentedDirective} currentFileCommentedDirective $COMMENT#JSDOC#PARAMS#DIRECTIVE21#CURRENTFILECOMMENTEDDIRECTIVE
|
|
547
|
+
* @param {ResolverFactory} resolver
|
|
528
548
|
* @returns $COMMENT#JSDOC#FORALIASVARIABLES#FLOWRETURNSEARLY
|
|
529
549
|
*/
|
|
530
550
|
export const importsFlowRequire = (
|
|
531
551
|
context,
|
|
532
552
|
node,
|
|
533
553
|
currentFileCommentedDirective,
|
|
554
|
+
resolver,
|
|
534
555
|
) => {
|
|
535
|
-
const result = importedFileFlowRequire(context, node);
|
|
556
|
+
const result = importedFileFlowRequire(context, node, resolver);
|
|
536
557
|
|
|
537
558
|
if (result.skip) return;
|
|
538
559
|
const { importedFileCommentedDirective } = result;
|
|
@@ -604,12 +625,14 @@ export const importsFlowRequire = (
|
|
|
604
625
|
* @param {Context} context $COMMENT#JSDOC#PARAMS#CONTEXTB
|
|
605
626
|
* @param {ExportNamedDeclaration | ExportAllDeclaration | ExportDefaultDeclaration} node $COMMENT#JSDOC#PARAMS#NODE
|
|
606
627
|
* @param {CommentedDirective} currentFileCommentedDirective $COMMENT#JSDOC#PARAMS#DIRECTIVE21#CURRENTFILECOMMENTEDDIRECTIVE
|
|
628
|
+
* @param {ResolverFactory} resolver
|
|
607
629
|
* @returns $COMMENT#JSDOC#FORALIASVARIABLES#FLOWRETURNSEARLY
|
|
608
630
|
*/
|
|
609
631
|
export const allExportsFlow = (
|
|
610
632
|
context,
|
|
611
633
|
node,
|
|
612
634
|
currentFileCommentedDirective,
|
|
635
|
+
resolver,
|
|
613
636
|
) => {
|
|
614
637
|
// saving the original commented directive (speficially for "use agnostic strategies")
|
|
615
638
|
const originalCurrentFileCommentedDirective = currentFileCommentedDirective;
|
|
@@ -627,7 +650,7 @@ export const allExportsFlow = (
|
|
|
627
650
|
}
|
|
628
651
|
// re-exports scenarios
|
|
629
652
|
else {
|
|
630
|
-
const result = importedFileFlow(context, node);
|
|
653
|
+
const result = importedFileFlow(context, node, resolver);
|
|
631
654
|
|
|
632
655
|
if (result.skip) return;
|
|
633
656
|
const { importedFileCommentedDirective } = result;
|