eslint-plugin-use-agnostic 1.2.1 → 1.2.2

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.
@@ -1,11 +1,6 @@
1
- import fs from "fs";
2
-
3
- import { Linter } from "eslint";
4
-
5
1
  import {
6
2
  ARE_NOT_ALLOWED_TO_IMPORT,
7
3
  resolvedDirectives_resolvedModules,
8
- typeScriptAndJSXCompatible,
9
4
  } from "../constants/bases.js";
10
5
 
11
6
  /**
@@ -19,27 +14,6 @@ import {
19
14
  * @typedef {import('../../../types/_commons/typedefs').ResolvedDirectives_BlockedImports<T, U>} ResolvedDirectives_BlockedImports
20
15
  */
21
16
 
22
- /* getSourceCodeFromFilePath */
23
-
24
- /**
25
- * Gets the ESLint-generated SourceCode object of a file from its resolved path.
26
- * @param {string} resolvedPath The resolved path of the file.
27
- * @returns The ESLint-generated SourceCode object of the file.
28
- */
29
- export const getSourceCodeFromFilePath = (resolvedPath) => {
30
- // ensures each instance of the function is based on its own linter
31
- // (just in case somehow some linters were running concurrently)
32
- const linter = new Linter();
33
- // the raw code of the file at the end of the resolved path
34
- const text = fs.readFileSync(resolvedPath, "utf8");
35
- // utilizes linter.verify ...
36
- linter.verify(text, { languageOptions: typeScriptAndJSXCompatible });
37
- // ... to retrieve the raw code as a SourceCode object
38
- const code = linter.getSourceCode();
39
-
40
- return code;
41
- };
42
-
43
17
  /* highlightFirstLineOfCode */
44
18
 
45
19
  /**
@@ -1,3 +1,5 @@
1
+ import { getSourceCodeFromFilePath } from "get-sourcecode-from-file-path";
2
+
1
3
  import {
2
4
  USE_SERVER,
3
5
  LOGICS,
@@ -12,7 +14,6 @@ import {
12
14
  isImportBlocked as commonsIsImportBlocked,
13
15
  makeMessageFromCurrentFileResolvedDirective,
14
16
  findSpecificViolationMessage as commonsFindSpecificViolationMessage,
15
- getSourceCodeFromFilePath,
16
17
  } from "../../../_commons/utilities/helpers.js";
17
18
 
18
19
  /**
@@ -1,3 +1,5 @@
1
+ import { getSourceCodeFromFilePath } from "get-sourcecode-from-file-path";
2
+
1
3
  import { exportNotStrategized } from "../../../_commons/constants/bases.js";
2
4
  import {
3
5
  USE_AGNOSTIC_STRATEGIES,
@@ -12,7 +14,6 @@ import {
12
14
  isImportBlocked as commonsIsImportBlocked,
13
15
  makeMessageFromCurrentFileResolvedDirective,
14
16
  findSpecificViolationMessage as commonsFindSpecificViolationMessage,
15
- getSourceCodeFromFilePath,
16
17
  } from "../../../_commons/utilities/helpers.js";
17
18
 
18
19
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-use-agnostic",
3
- "version": "1.2.1",
3
+ "version": "1.2.2",
4
4
  "description": "Highlights problematic server-client imports in projects made with the Fullstack React Architecture.",
5
5
  "keywords": [
6
6
  "eslint",
@@ -41,6 +41,7 @@
41
41
  "test": "node tests/agnostic20/import-rules.test.js && node tests/directive21/import-rules.test.js"
42
42
  },
43
43
  "dependencies": {
44
+ "get-sourcecode-from-file-path": "^1.0.0",
44
45
  "resolve-importing-path": "^1.0.2",
45
46
  "tsconfig-paths": "^4.2.0",
46
47
  "typescript-eslint": "^8.32.0"