eslint-plugin-use-agnostic 1.7.9 → 1.8.0

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.
@@ -4,8 +4,8 @@ import {
4
4
  noCommentedDirectiveMessageId,
5
5
  commentedDirectiveVerificationFailedMessageId,
6
6
  commentedDirectiveReactDirectiveFailedMessageId,
7
- importNotStrategizedMessageId,
8
- exportNotStrategizedMessageId,
7
+ // importNotStrategizedMessageId,
8
+ // exportNotStrategizedMessageId,
9
9
  cantChainImportAcrossEnvironmentsMessageId,
10
10
  } from "../../../_commons/constants/bases.js";
11
11
  import {
@@ -50,10 +50,10 @@ All targeted modules need to be marked with their respective directives (\`// "u
50
50
  [commentedDirectiveVerificationFailedMessageId]: `The commented directive could not pass verification due to an incompatible combination with its file extension.
51
51
  In this context, {{ ${specificFailure} }} `,
52
52
  [commentedDirectiveReactDirectiveFailedMessageId]: `Commented directive "{{ ${verifiedCommentedDirective} }}" requires {{ ${expectedReactDirectiveAsText} }} directive in order to communicate accordingly with the React architecture at hand. `,
53
- [importNotStrategizedMessageId]: `Imports from Agnostic Strategies Modules must be strategized (\`/* @serverLogics */\`, etc.).
54
- Please include a Strategy that corresponds to the kind of module this import would be mapped to. `,
55
- [exportNotStrategizedMessageId]: `Exports from Agnostic Strategies Modules must be strategized (\`/* @serverLogics */\`, etc.).
56
- Please include a Strategy that corresponds to the kind of module this export would be mapped to. `,
53
+ // [importNotStrategizedMessageId]: `Imports from Agnostic Strategies Modules must be strategized (\`/* @serverLogics */\`, etc.).
54
+ // Please include a Strategy that corresponds to the kind of module this import would be mapped to. `,
55
+ // [exportNotStrategizedMessageId]: `Exports from Agnostic Strategies Modules must be strategized (\`/* @serverLogics */\`, etc.).
56
+ // Please include a Strategy that corresponds to the kind of module this export would be mapped to. `,
57
57
  [cantChainImportAcrossEnvironmentsMessageId]: `Because imports are actually references instead of modules across environments, it is not possible to chain-import between the {{ ${currentFileEnvironment} }} environment and the {{ ${importedFileEnvironment} }} environment. In these cases, only direct imports apply. `,
58
58
  },
59
59
  },
@@ -10,7 +10,7 @@ import {
10
10
  noCommentedDirectiveMessageId,
11
11
  commentedDirectiveVerificationFailedMessageId,
12
12
  commentedDirectiveReactDirectiveFailedMessageId,
13
- importNotStrategizedMessageId,
13
+ // importNotStrategizedMessageId,
14
14
  cantChainImportAcrossEnvironmentsMessageId,
15
15
  skip,
16
16
  } from "../../../_commons/constants/bases.js";
@@ -40,7 +40,7 @@ import {
40
40
  isImportBlocked,
41
41
  makeMessageFromCurrentFileCommentedDirective,
42
42
  findSpecificViolationMessage,
43
- getStrategizedDirective,
43
+ // getStrategizedDirective,
44
44
  addressDirectiveIfAgnosticStrategies,
45
45
  } from "./helpers.js";
46
46
  import { analyzeExportsForReExports } from "./analyze-exports-re.js";
@@ -192,13 +192,12 @@ export const currentFileFlow = (context) => {
192
192
  }
193
193
 
194
194
  // NEW
195
- // do not report if the module is a non-Extra JavaScript Agnostic Strategies Module, in order to allow them the freedom of doing whatever they want so they can behave in any which way they need to as convention files
196
- if (
197
- !(
198
- fileIsRegularJavaScript(context.filename) &&
199
- verifiedCommentedDirective === USE_AGNOSTIC_STRATEGIES
200
- )
201
- )
195
+ const isRegularJavaScriptAgnosticStrategies =
196
+ fileIsRegularJavaScript(context.filename) &&
197
+ verifiedCommentedDirective === USE_AGNOSTIC_STRATEGIES;
198
+
199
+ // do not report if the module is a non-Extra JavaScript Agnostic Strategies Module, in order to allow them the freedom of doing whatever they want so they can behave in any which way they need to as convention files (JSX extension still required though)
200
+ if (!isRegularJavaScriptAgnosticStrategies)
202
201
  context.report({
203
202
  loc: highlightFirstLineOfCode(context),
204
203
  messageId: commentedDirectiveReactDirectiveFailedMessageId,
@@ -271,26 +270,29 @@ const importedFileFlow = (context, node) => {
271
270
  (Consequently, details below are currently at the stage of wishful thinking.)
272
271
  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. */
273
272
 
274
- if (importedFileCommentedDirective === USE_AGNOSTIC_STRATEGIES) {
275
- const importingFileCommentedDirective = getStrategizedDirective(
276
- context,
277
- node
278
- );
279
-
280
- if (
281
- importingFileCommentedDirective === null &&
282
- fileIsExtraJavaScript(context.filename)
283
- ) {
284
- context.report({
285
- node,
286
- messageId: importNotStrategizedMessageId,
287
- });
288
- return skipTrue;
289
- }
290
-
291
- // FOR NOW, we consider the importingFileCommentedDirective (which is strategized) and the importedFileCommentedDirective (which should be strategized on its own imported file) to be same, given the limitation highlighted above.
292
- importedFileCommentedDirective = importingFileCommentedDirective;
293
- }
273
+ // NEW!!
274
+ // No changes anymore. Agnostic Strategies Modules from now on are going to be considered regularly checked module that simply CANNOT be imported anywhere.
275
+
276
+ // if (importedFileCommentedDirective === USE_AGNOSTIC_STRATEGIES) {
277
+ // const importingFileCommentedDirective = getStrategizedDirective(
278
+ // context,
279
+ // node
280
+ // );
281
+
282
+ // if (
283
+ // importingFileCommentedDirective === null &&
284
+ // fileIsExtraJavaScript(context.filename)
285
+ // ) {
286
+ // context.report({
287
+ // node,
288
+ // messageId: importNotStrategizedMessageId,
289
+ // });
290
+ // return skipTrue;
291
+ // }
292
+
293
+ // // FOR NOW, we consider the importingFileCommentedDirective (which is strategized) and the importedFileCommentedDirective (which should be strategized on its own imported file) to be same, given the limitation highlighted above.
294
+ // importedFileCommentedDirective = importingFileCommentedDirective;
295
+ // }
294
296
 
295
297
  // you never know
296
298
  if (!importedFileSourceCode) {
@@ -380,26 +382,26 @@ const importedFileFlowRequire = (context, node) => {
380
382
  (Consequently, details below are currently at the stage of wishful thinking.)
381
383
  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. */
382
384
 
383
- if (importedFileCommentedDirective === USE_AGNOSTIC_STRATEGIES) {
384
- const importingFileCommentedDirective = getStrategizedDirective(
385
- context,
386
- node
387
- );
388
-
389
- if (
390
- importingFileCommentedDirective === null &&
391
- fileIsExtraJavaScript(context.filename)
392
- ) {
393
- context.report({
394
- node,
395
- messageId: importNotStrategizedMessageId,
396
- });
397
- return skipTrue;
398
- }
399
-
400
- // FOR NOW, we consider the importingFileCommentedDirective (which is strategized) and the importedFileCommentedDirective (which should be strategized on its own imported file) to be same, given the limitation highlighted above.
401
- importedFileCommentedDirective = importingFileCommentedDirective;
402
- }
385
+ // if (importedFileCommentedDirective === USE_AGNOSTIC_STRATEGIES) {
386
+ // const importingFileCommentedDirective = getStrategizedDirective(
387
+ // context,
388
+ // node
389
+ // );
390
+
391
+ // if (
392
+ // importingFileCommentedDirective === null &&
393
+ // fileIsExtraJavaScript(context.filename)
394
+ // ) {
395
+ // context.report({
396
+ // node,
397
+ // messageId: importNotStrategizedMessageId,
398
+ // });
399
+ // return skipTrue;
400
+ // }
401
+
402
+ // // FOR NOW, we consider the importingFileCommentedDirective (which is strategized) and the importedFileCommentedDirective (which should be strategized on its own imported file) to be same, given the limitation highlighted above.
403
+ // importedFileCommentedDirective = importingFileCommentedDirective;
404
+ // }
403
405
 
404
406
  // you never know
405
407
  if (!importedFileSourceCode) {
@@ -443,8 +445,8 @@ export const importsFlow = (context, node, currentFileCommentedDirective) => {
443
445
  if (result.skip) return;
444
446
  const { importedFileCommentedDirective } = result;
445
447
 
446
- // returns early is the current file is an Agnostic Strategies Module
447
- if (currentFileCommentedDirective === USE_AGNOSTIC_STRATEGIES) return;
448
+ // returns early is the current file is an Agnostic Strategies Module // not anymore
449
+ // if (currentFileCommentedDirective === USE_AGNOSTIC_STRATEGIES) return;
448
450
 
449
451
  if (
450
452
  isImportBlocked(
@@ -519,8 +521,8 @@ export const importsFlowRequire = (
519
521
  if (result.skip) return;
520
522
  const { importedFileCommentedDirective } = result;
521
523
 
522
- // returns early is the current file is an Agnostic Strategies Module
523
- if (currentFileCommentedDirective === USE_AGNOSTIC_STRATEGIES) return;
524
+ // returns early is the current file is an Agnostic Strategies Module // not anymore
525
+ // if (currentFileCommentedDirective === USE_AGNOSTIC_STRATEGIES) return;
524
526
 
525
527
  if (
526
528
  isImportBlocked(
@@ -1,6 +1,6 @@
1
1
  import { getSourceCodeFromFilePath } from "get-sourcecode-from-file-path";
2
2
 
3
- import { exportNotStrategizedMessageId } from "../../../_commons/constants/bases.js";
3
+ // import { exportNotStrategizedMessageId } from "../../../_commons/constants/bases.js";
4
4
  import {
5
5
  USE_AGNOSTIC_STRATEGIES,
6
6
  commentedDirectivesArray,
@@ -323,15 +323,20 @@ export const addressDirectiveIfAgnosticStrategies = (
323
323
 
324
324
  const exportStrategizedDirective = getStrategizedDirective(context, node);
325
325
 
326
- if (
327
- exportStrategizedDirective === null &&
328
- fileIsExtraJavaScript(context.filename)
329
- ) {
330
- context.report({
331
- node,
332
- messageId: exportNotStrategizedMessageId,
333
- });
334
- }
326
+ // NEW!!
327
+ // Now entirely neutralized. Agnostic Strategies Modules are now going to be vetted module just like the others from now on.
328
+ // BUT!!
329
+ // Still acknowledges ongoing strategies since they are indeed still acknowledged, though in a unreliable way, by the eXtra JSX's TypeScript server plugin.
330
+
331
+ // if (
332
+ // exportStrategizedDirective === null &&
333
+ // fileIsExtraJavaScript(context.filename)
334
+ // ) {
335
+ // context.report({
336
+ // node,
337
+ // messageId: exportNotStrategizedMessageId,
338
+ // });
339
+ // }
335
340
 
336
341
  return exportStrategizedDirective; // null indicates failure
337
342
  };
@@ -340,8 +345,8 @@ export const addressDirectiveIfAgnosticStrategies = (
340
345
 
341
346
  /**
342
347
  * Returns a boolean deciding if an imported file's commented directive is incompatible with the current file's commented directive.
343
- * @param {CommentedDirectiveWithoutUseAgnosticStrategies} currentFileCommentedDirective The current file's commented directive.
344
- * @param {CommentedDirectiveWithoutUseAgnosticStrategies} importedFileCommentedDirective The imported file's commented directive.
348
+ * @param {CommentedDirective} currentFileCommentedDirective The current file's commented directive.
349
+ * @param {CommentedDirective} importedFileCommentedDirective The imported file's commented directive.
345
350
  * @returns `true` if the import is blocked, as established in `commentedDirectives_BlockedImports`.
346
351
  */
347
352
  export const isImportBlocked = (
@@ -373,8 +378,8 @@ export const makeMessageFromCurrentFileCommentedDirective = (
373
378
 
374
379
  /**
375
380
  * Finds the `message` for the specific violation of commented directives import rules based on `commentedDirectives_BlockedImports`.
376
- * @param {CommentedDirectiveWithoutUseAgnosticStrategies} currentFileCommentedDirective The current file's commented directive.
377
- * @param {CommentedDirectiveWithoutUseAgnosticStrategies} importedFileCommentedDirective The imported file's commented directive.
381
+ * @param {CommentedDirective} currentFileCommentedDirective The current file's commented directive.
382
+ * @param {CommentedDirective} importedFileCommentedDirective The imported file's commented directive.
378
383
  * @returns The corresponding `message`.
379
384
  */
380
385
  export const findSpecificViolationMessage = (
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-use-agnostic",
3
- "version": "1.7.9",
3
+ "version": "1.8.0",
4
4
  "description": "Highlights problematic server-client imports in projects made with the Fullstack React Architecture.",
5
5
  "keywords": [
6
6
  "eslint",