@fjall/eslint-plugin 2.18.1 → 2.18.3

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.
@@ -30,20 +30,32 @@
30
30
  * Codifies typescript-standards.md § "Zod-Derived Type Guards (MANDATORY)".
31
31
  */
32
32
 
33
- import { readFileSync } from "node:fs";
33
+ import { existsSync, readFileSync } from "node:fs";
34
34
  import { dirname, join } from "node:path";
35
35
  import { fileURLToPath } from "node:url";
36
36
 
37
37
  const __dirname = dirname(fileURLToPath(import.meta.url));
38
38
 
39
- const REGISTRY = buildRegistry();
39
+ let registryCache;
40
+
41
+ // Built lazily (not at import) so loading from the published plugin — where the
42
+ // generator source tree is absent — does not warn on every lint run.
43
+ function getRegistry() {
44
+ if (registryCache === undefined) registryCache = buildRegistry();
45
+ return registryCache;
46
+ }
40
47
 
41
48
  function buildRegistry() {
49
+ const schemasDir = join(__dirname, "..", "..", "generator", "src", "schemas");
50
+ const registry = new Map();
51
+ // Source tree absent → published-package context, no-op silently; the warning
52
+ // below is reserved for the dir present but a file unreadable.
53
+ if (!existsSync(schemasDir)) return registry;
54
+
42
55
  const sources = [
43
- join(__dirname, "..", "..", "generator", "src", "schemas", "constants.ts"),
44
- join(__dirname, "..", "..", "generator", "src", "schemas", "sharedTypes.ts")
56
+ join(schemasDir, "constants.ts"),
57
+ join(schemasDir, "sharedTypes.ts")
45
58
  ];
46
- const registry = new Map();
47
59
  const failures = [];
48
60
  for (const path of sources) {
49
61
  let text;
@@ -108,7 +120,8 @@ export default {
108
120
  },
109
121
 
110
122
  create(context) {
111
- if (REGISTRY.size === 0) return {};
123
+ const registry = getRegistry();
124
+ if (registry.size === 0) return {};
112
125
 
113
126
  return {
114
127
  CallExpression(node) {
@@ -132,7 +145,7 @@ export default {
132
145
  if (literals.length === 0) return;
133
146
 
134
147
  const key = canonicalKey(literals);
135
- const constantName = REGISTRY.get(key);
148
+ const constantName = registry.get(key);
136
149
  if (constantName === undefined) return;
137
150
 
138
151
  context.report({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fjall/eslint-plugin",
3
- "version": "2.18.1",
3
+ "version": "2.18.3",
4
4
  "description": "ESLint plugin with Fjall-specific coding standard rules",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -22,8 +22,15 @@
22
22
  "clean:node": "rm -rf ./node_modules",
23
23
  "build": "echo \"@fjall/eslint-plugin: no build step (plain JS, published as source)\"",
24
24
  "watch": "echo \"@fjall/eslint-plugin: no watch (no build step)\"",
25
- "format": "prettier --write \"*.js\" \"__tests__/**/*.js\" README.md",
26
- "format:check": "prettier --check \"*.js\" \"__tests__/**/*.js\" README.md"
25
+ "lint": "eslint .",
26
+ "lint:fix": "eslint . --fix",
27
+ "test": "vitest run",
28
+ "format": "prettier --write \"*.{js,mjs}\" \"__tests__/**/*.js\" \"vitest.config.ts\" \"package.json\" README.md",
29
+ "format:check": "prettier --check \"*.{js,mjs}\" \"__tests__/**/*.js\" \"vitest.config.ts\" \"package.json\" README.md"
27
30
  },
28
- "license": "SEE LICENSE IN LICENSE"
31
+ "devDependencies": {
32
+ "vitest": "^4.1.5"
33
+ },
34
+ "license": "SEE LICENSE IN LICENSE",
35
+ "gitHead": "50f45ba44cd32824ee560d3e77078d000fa64302"
29
36
  }
@@ -53,7 +53,6 @@ const PATTERNS_LAYER_FILENAME_SUFFIX =
53
53
  const RESOURCES_LAYER_RELATIVE_PATH =
54
54
  "../../resources/aws/compute/ecsValidation.ts";
55
55
  const PATTERNS_LAYER_FUNCTION_NAME = "validateEcsProps";
56
- const RESOURCES_LAYER_FUNCTION_NAME = "validateEcsClusterProps";
57
56
 
58
57
  /** Cache the resources-layer file content per process — invalidated only on
59
58
  * ESLint restart. The lint session reads `ecsValidation.ts` once even if
@@ -75,7 +74,7 @@ function readResourcesLayer(patternsFilePath) {
75
74
  if (resourcesFileCache.has(resourcesPath)) {
76
75
  return resourcesFileCache.get(resourcesPath);
77
76
  }
78
- let content = "";
77
+ let content;
79
78
  try {
80
79
  content = readFileSync(resourcesPath, "utf8");
81
80
  } catch (err) {