eslint-plugin-react-x 1.40.4-next.6 → 1.40.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
@@ -141,7 +141,7 @@ var settings3 = {
141
141
 
142
142
  // package.json
143
143
  var name4 = "eslint-plugin-react-x";
144
- var version = "1.40.4-next.6";
144
+ var version = "1.40.4";
145
145
  var createRule = utils.ESLintUtils.RuleCreator(shared.getDocsUrl("x"));
146
146
 
147
147
  // src/rules/avoid-shorthand-boolean.ts
@@ -295,7 +295,7 @@ var jsx_uses_react_default = createRule({
295
295
  meta: {
296
296
  type: "problem",
297
297
  docs: {
298
- description: "Marks React variables as used when JSX is used in the file.",
298
+ description: "Marks React variables as used when JSX is used.",
299
299
  [Symbol.for("rule_features")]: RULE_FEATURES5
300
300
  },
301
301
  messages: {
@@ -308,30 +308,17 @@ var jsx_uses_react_default = createRule({
308
308
  defaultOptions: []
309
309
  });
310
310
  function create5(context) {
311
- const { jsx, jsxFactory, jsxFragmentFactory, reactNamespace } = kit.JsxRuntime.getJsxRuntimeOptionsFromContext(context);
312
- const jsxAnnotation = getJsxAnnotation(context);
311
+ const jsxOptions = kit.JsxRuntime.getJsxRuntimeOptions(context);
312
+ const jsxAnnotation = kit.JsxRuntime.getJsxRuntimeAnnotation(context);
313
+ const jsx = jsxAnnotation.jsxRuntime === "classic" ? ts.JsxEmit.React : jsxOptions.jsx;
313
314
  if (jsx === ts.JsxEmit.ReactJSX || jsx === ts.JsxEmit.ReactJSXDev) return {};
315
+ const jsxFactory = jsxAnnotation.jsx ?? jsxOptions.jsxFactory;
316
+ const jsxFragmentFactory = jsxAnnotation.jsxFrag ?? jsxOptions.jsxFragmentFactory;
314
317
  function handleJsxElement(node) {
315
- if (jsxAnnotation == null) {
316
- context.sourceCode.markVariableAsUsed(reactNamespace, node);
317
- context.sourceCode.markVariableAsUsed(jsxFactory, node);
318
- debugReport(context, node, reactNamespace);
319
- debugReport(context, node, jsxFactory);
320
- }
321
- if (jsxAnnotation?.jsx != null) {
322
- context.sourceCode.markVariableAsUsed(jsxAnnotation.jsx, node);
323
- debugReport(context, node, jsxAnnotation.jsx);
324
- }
318
+ context.sourceCode.markVariableAsUsed(jsxFactory, node);
325
319
  }
326
320
  function handleJsxFragment(node) {
327
- if (jsxAnnotation == null) {
328
- context.sourceCode.markVariableAsUsed(jsxFragmentFactory, node);
329
- debugReport(context, node, jsxFragmentFactory);
330
- }
331
- if (jsxAnnotation?.jsxFrag != null) {
332
- context.sourceCode.markVariableAsUsed(jsxAnnotation.jsxFrag, node);
333
- debugReport(context, node, jsxAnnotation.jsxFrag);
334
- }
321
+ context.sourceCode.markVariableAsUsed(jsxFragmentFactory, node);
335
322
  }
336
323
  return {
337
324
  JSXFragment: handleJsxFragment,
@@ -339,25 +326,6 @@ function create5(context) {
339
326
  JSXOpeningFragment: handleJsxElement
340
327
  };
341
328
  }
342
- function getJsxAnnotation(context) {
343
- if (!context.sourceCode.text.includes("@jsx")) return;
344
- const allComments = context.sourceCode.getAllComments();
345
- const jsxComment = allComments.find((n) => kit.RE_JSX_ANNOTATION.test(n.value));
346
- const jsxFragComment = allComments.find((n) => kit.RE_JSX_FRAG_ANNOTATION.test(n.value));
347
- const jsx = jsxComment?.value.match(kit.RE_JSX_ANNOTATION)?.[1];
348
- const jsxFrag = jsxFragComment?.value.match(kit.RE_JSX_FRAG_ANNOTATION)?.[1];
349
- return {
350
- jsx,
351
- jsxFrag
352
- };
353
- }
354
- function debugReport(context, node, name5) {
355
- context.report({
356
- messageId: "jsxUsesReact",
357
- node,
358
- data: { name: name5 }
359
- });
360
- }
361
329
  var RULE_NAME6 = "jsx-uses-vars";
362
330
  var RULE_FEATURES6 = [];
363
331
  var jsx_uses_vars_default = createRule({
package/dist/index.mjs CHANGED
@@ -5,7 +5,7 @@ import { AST_NODE_TYPES } from '@typescript-eslint/types';
5
5
  import { _, flow, getOrUpdate, constTrue, constFalse } from '@eslint-react/eff';
6
6
  import * as VAR2 from '@eslint-react/var';
7
7
  import { match, isMatching, P } from 'ts-pattern';
8
- import { JsxRuntime, RE_JSX_ANNOTATION, RE_JSX_FRAG_ANNOTATION, createReport } from '@eslint-react/kit';
8
+ import { JsxRuntime, createReport } from '@eslint-react/kit';
9
9
  import ts, { JsxEmit } from 'typescript';
10
10
  import * as AST8 from '@eslint-react/ast';
11
11
  import * as ER21 from '@eslint-react/core';
@@ -113,7 +113,7 @@ var settings3 = {
113
113
 
114
114
  // package.json
115
115
  var name4 = "eslint-plugin-react-x";
116
- var version = "1.40.4-next.6";
116
+ var version = "1.40.4";
117
117
  var createRule = ESLintUtils.RuleCreator(getDocsUrl("x"));
118
118
 
119
119
  // src/rules/avoid-shorthand-boolean.ts
@@ -267,7 +267,7 @@ var jsx_uses_react_default = createRule({
267
267
  meta: {
268
268
  type: "problem",
269
269
  docs: {
270
- description: "Marks React variables as used when JSX is used in the file.",
270
+ description: "Marks React variables as used when JSX is used.",
271
271
  [Symbol.for("rule_features")]: RULE_FEATURES5
272
272
  },
273
273
  messages: {
@@ -280,30 +280,17 @@ var jsx_uses_react_default = createRule({
280
280
  defaultOptions: []
281
281
  });
282
282
  function create5(context) {
283
- const { jsx, jsxFactory, jsxFragmentFactory, reactNamespace } = JsxRuntime.getJsxRuntimeOptionsFromContext(context);
284
- const jsxAnnotation = getJsxAnnotation(context);
283
+ const jsxOptions = JsxRuntime.getJsxRuntimeOptions(context);
284
+ const jsxAnnotation = JsxRuntime.getJsxRuntimeAnnotation(context);
285
+ const jsx = jsxAnnotation.jsxRuntime === "classic" ? JsxEmit.React : jsxOptions.jsx;
285
286
  if (jsx === JsxEmit.ReactJSX || jsx === JsxEmit.ReactJSXDev) return {};
287
+ const jsxFactory = jsxAnnotation.jsx ?? jsxOptions.jsxFactory;
288
+ const jsxFragmentFactory = jsxAnnotation.jsxFrag ?? jsxOptions.jsxFragmentFactory;
286
289
  function handleJsxElement(node) {
287
- if (jsxAnnotation == null) {
288
- context.sourceCode.markVariableAsUsed(reactNamespace, node);
289
- context.sourceCode.markVariableAsUsed(jsxFactory, node);
290
- debugReport(context, node, reactNamespace);
291
- debugReport(context, node, jsxFactory);
292
- }
293
- if (jsxAnnotation?.jsx != null) {
294
- context.sourceCode.markVariableAsUsed(jsxAnnotation.jsx, node);
295
- debugReport(context, node, jsxAnnotation.jsx);
296
- }
290
+ context.sourceCode.markVariableAsUsed(jsxFactory, node);
297
291
  }
298
292
  function handleJsxFragment(node) {
299
- if (jsxAnnotation == null) {
300
- context.sourceCode.markVariableAsUsed(jsxFragmentFactory, node);
301
- debugReport(context, node, jsxFragmentFactory);
302
- }
303
- if (jsxAnnotation?.jsxFrag != null) {
304
- context.sourceCode.markVariableAsUsed(jsxAnnotation.jsxFrag, node);
305
- debugReport(context, node, jsxAnnotation.jsxFrag);
306
- }
293
+ context.sourceCode.markVariableAsUsed(jsxFragmentFactory, node);
307
294
  }
308
295
  return {
309
296
  JSXFragment: handleJsxFragment,
@@ -311,25 +298,6 @@ function create5(context) {
311
298
  JSXOpeningFragment: handleJsxElement
312
299
  };
313
300
  }
314
- function getJsxAnnotation(context) {
315
- if (!context.sourceCode.text.includes("@jsx")) return;
316
- const allComments = context.sourceCode.getAllComments();
317
- const jsxComment = allComments.find((n) => RE_JSX_ANNOTATION.test(n.value));
318
- const jsxFragComment = allComments.find((n) => RE_JSX_FRAG_ANNOTATION.test(n.value));
319
- const jsx = jsxComment?.value.match(RE_JSX_ANNOTATION)?.[1];
320
- const jsxFrag = jsxFragComment?.value.match(RE_JSX_FRAG_ANNOTATION)?.[1];
321
- return {
322
- jsx,
323
- jsxFrag
324
- };
325
- }
326
- function debugReport(context, node, name5) {
327
- context.report({
328
- messageId: "jsxUsesReact",
329
- node,
330
- data: { name: name5 }
331
- });
332
- }
333
301
  var RULE_NAME6 = "jsx-uses-vars";
334
302
  var RULE_FEATURES6 = [];
335
303
  var jsx_uses_vars_default = createRule({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-react-x",
3
- "version": "1.40.4-next.6",
3
+ "version": "1.40.4",
4
4
  "description": "A set of composable linting rules for libraries and frameworks that use React as a UI runtime.",
5
5
  "keywords": [
6
6
  "react",
@@ -50,13 +50,13 @@
50
50
  "is-immutable-type": "^5.0.1",
51
51
  "string-ts": "^2.2.1",
52
52
  "ts-pattern": "^5.7.0",
53
- "@eslint-react/ast": "1.40.4-next.6",
54
- "@eslint-react/kit": "1.40.4-next.6",
55
- "@eslint-react/core": "1.40.4-next.6",
56
- "@eslint-react/eff": "1.40.4-next.6",
57
- "@eslint-react/var": "1.40.4-next.6",
58
- "@eslint-react/jsx": "1.40.4-next.6",
59
- "@eslint-react/shared": "1.40.4-next.6"
53
+ "@eslint-react/ast": "1.40.4",
54
+ "@eslint-react/core": "1.40.4",
55
+ "@eslint-react/eff": "1.40.4",
56
+ "@eslint-react/jsx": "1.40.4",
57
+ "@eslint-react/var": "1.40.4",
58
+ "@eslint-react/kit": "1.40.4",
59
+ "@eslint-react/shared": "1.40.4"
60
60
  },
61
61
  "devDependencies": {
62
62
  "@types/react": "^19.1.0",