@eslint-react/kit 1.45.4-next.2 → 1.45.4-next.4

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/dist/index.js CHANGED
@@ -1,8 +1,8 @@
1
1
  'use strict';
2
2
 
3
+ var eff = require('@eslint-react/eff');
3
4
  var typescript = require('typescript');
4
5
  var valibot = require('valibot');
5
- require('@eslint-react/eff');
6
6
 
7
7
  var __defProp = Object.defineProperty;
8
8
  var __export = (target, all) => {
@@ -81,22 +81,29 @@ function getFromContext(context) {
81
81
  reactNamespace: options.reactNamespace ?? "React"
82
82
  };
83
83
  }
84
+ var cache = /* @__PURE__ */ new WeakMap();
84
85
  function getFromAnnotation(context) {
85
- if (!context.sourceCode.text.includes("@jsx")) return {};
86
- let jsx, jsxFrag, jsxRuntime, jsxImportSource;
87
- for (const comment of context.sourceCode.getAllComments().reverse()) {
88
- const value = comment.value;
89
- jsx ??= value.match(ANNOTATION_JSX)?.[1];
90
- jsxFrag ??= value.match(ANNOTATION_JSX_FRAG)?.[1];
91
- jsxRuntime ??= value.match(ANNOTATION_JSX_RUNTIME)?.[1];
92
- jsxImportSource ??= value.match(ANNOTATION_JSX_IMPORT_SOURCE)?.[1];
93
- }
94
- const options = make();
95
- if (jsx != null) options.jsxFactory = jsx;
96
- if (jsxFrag != null) options.jsxFragmentFactory = jsxFrag;
97
- if (jsxRuntime != null) options.jsx = jsxRuntime === "classic" ? typescript.JsxEmit.React : typescript.JsxEmit.ReactJSX;
98
- if (jsxImportSource != null) options.jsxImportSource = jsxImportSource;
99
- return options;
86
+ return eff.getOrElseUpdate(
87
+ cache,
88
+ context.sourceCode,
89
+ () => {
90
+ const options = make();
91
+ if (!context.sourceCode.text.includes("@jsx")) return options;
92
+ let jsx, jsxFrag, jsxRuntime, jsxImportSource;
93
+ for (const comment of context.sourceCode.getAllComments().reverse()) {
94
+ const value = comment.value;
95
+ jsx ??= value.match(ANNOTATION_JSX)?.[1];
96
+ jsxFrag ??= value.match(ANNOTATION_JSX_FRAG)?.[1];
97
+ jsxRuntime ??= value.match(ANNOTATION_JSX_RUNTIME)?.[1];
98
+ jsxImportSource ??= value.match(ANNOTATION_JSX_IMPORT_SOURCE)?.[1];
99
+ }
100
+ if (jsx != null) options.jsxFactory = jsx;
101
+ if (jsxFrag != null) options.jsxFragmentFactory = jsxFrag;
102
+ if (jsxRuntime != null) options.jsx = jsxRuntime === "classic" ? typescript.JsxEmit.React : typescript.JsxEmit.ReactJSX;
103
+ if (jsxImportSource != null) options.jsxImportSource = jsxImportSource;
104
+ return options;
105
+ }
106
+ );
100
107
  }
101
108
 
102
109
  // src/LanguagePreference/index.ts
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
+ import { getOrElseUpdate } from '@eslint-react/eff';
1
2
  import { JsxEmit } from 'typescript';
2
3
  import { object, optional, union, literal, number } from 'valibot';
3
- import '@eslint-react/eff';
4
4
 
5
5
  var __defProp = Object.defineProperty;
6
6
  var __export = (target, all) => {
@@ -79,22 +79,29 @@ function getFromContext(context) {
79
79
  reactNamespace: options.reactNamespace ?? "React"
80
80
  };
81
81
  }
82
+ var cache = /* @__PURE__ */ new WeakMap();
82
83
  function getFromAnnotation(context) {
83
- if (!context.sourceCode.text.includes("@jsx")) return {};
84
- let jsx, jsxFrag, jsxRuntime, jsxImportSource;
85
- for (const comment of context.sourceCode.getAllComments().reverse()) {
86
- const value = comment.value;
87
- jsx ??= value.match(ANNOTATION_JSX)?.[1];
88
- jsxFrag ??= value.match(ANNOTATION_JSX_FRAG)?.[1];
89
- jsxRuntime ??= value.match(ANNOTATION_JSX_RUNTIME)?.[1];
90
- jsxImportSource ??= value.match(ANNOTATION_JSX_IMPORT_SOURCE)?.[1];
91
- }
92
- const options = make();
93
- if (jsx != null) options.jsxFactory = jsx;
94
- if (jsxFrag != null) options.jsxFragmentFactory = jsxFrag;
95
- if (jsxRuntime != null) options.jsx = jsxRuntime === "classic" ? JsxEmit.React : JsxEmit.ReactJSX;
96
- if (jsxImportSource != null) options.jsxImportSource = jsxImportSource;
97
- return options;
84
+ return getOrElseUpdate(
85
+ cache,
86
+ context.sourceCode,
87
+ () => {
88
+ const options = make();
89
+ if (!context.sourceCode.text.includes("@jsx")) return options;
90
+ let jsx, jsxFrag, jsxRuntime, jsxImportSource;
91
+ for (const comment of context.sourceCode.getAllComments().reverse()) {
92
+ const value = comment.value;
93
+ jsx ??= value.match(ANNOTATION_JSX)?.[1];
94
+ jsxFrag ??= value.match(ANNOTATION_JSX_FRAG)?.[1];
95
+ jsxRuntime ??= value.match(ANNOTATION_JSX_RUNTIME)?.[1];
96
+ jsxImportSource ??= value.match(ANNOTATION_JSX_IMPORT_SOURCE)?.[1];
97
+ }
98
+ if (jsx != null) options.jsxFactory = jsx;
99
+ if (jsxFrag != null) options.jsxFragmentFactory = jsxFrag;
100
+ if (jsxRuntime != null) options.jsx = jsxRuntime === "classic" ? JsxEmit.React : JsxEmit.ReactJSX;
101
+ if (jsxImportSource != null) options.jsxImportSource = jsxImportSource;
102
+ return options;
103
+ }
104
+ );
98
105
  }
99
106
 
100
107
  // src/LanguagePreference/index.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eslint-react/kit",
3
- "version": "1.45.4-next.2",
3
+ "version": "1.45.4-next.4",
4
4
  "description": "ESLint React's plugin kit for building plugins and rules.",
5
5
  "homepage": "https://github.com/Rel1cx/eslint-react",
6
6
  "bugs": {
@@ -38,7 +38,7 @@
38
38
  "@typescript-eslint/utils": "^8.29.1",
39
39
  "ts-pattern": "^5.7.0",
40
40
  "valibot": "^1.0.0",
41
- "@eslint-react/eff": "1.45.4-next.2"
41
+ "@eslint-react/eff": "1.45.4-next.4"
42
42
  },
43
43
  "devDependencies": {
44
44
  "@tsconfig/node22": "^22.0.1",