eslint-plugin-react-x 1.40.1-next.0 → 1.40.1
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 +46 -12
- package/dist/index.mjs +47 -13
- package/package.json +8 -8
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.1
|
|
144
|
+
var version = "1.40.1";
|
|
145
145
|
var createRule = utils.ESLintUtils.RuleCreator(shared.getDocsUrl("x"));
|
|
146
146
|
|
|
147
147
|
// src/rules/avoid-shorthand-boolean.ts
|
|
@@ -299,7 +299,7 @@ var jsx_uses_react_default = createRule({
|
|
|
299
299
|
[Symbol.for("rule_features")]: RULE_FEATURES5
|
|
300
300
|
},
|
|
301
301
|
messages: {
|
|
302
|
-
jsxUsesReact: ""
|
|
302
|
+
jsxUsesReact: "Marked {{name}} as used."
|
|
303
303
|
},
|
|
304
304
|
schema: []
|
|
305
305
|
},
|
|
@@ -309,21 +309,55 @@ var jsx_uses_react_default = createRule({
|
|
|
309
309
|
});
|
|
310
310
|
function create5(context) {
|
|
311
311
|
const { jsx, jsxFactory, jsxFragmentFactory, reactNamespace } = kit.JsxRuntime.getJsxRuntimeOptionsFromContext(context);
|
|
312
|
-
|
|
313
|
-
return {
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
},
|
|
317
|
-
JSXOpeningElement(node) {
|
|
318
|
-
context.sourceCode.markVariableAsUsed(reactNamespace, node);
|
|
319
|
-
context.sourceCode.markVariableAsUsed(jsxFactory, node);
|
|
320
|
-
},
|
|
321
|
-
JSXOpeningFragment(node) {
|
|
312
|
+
const jsxAnnotation = getJsxAnnotation(context);
|
|
313
|
+
if (jsx === ts.JsxEmit.ReactJSX || jsx === ts.JsxEmit.ReactJSXDev || jsx === ts.JsxEmit.Preserve) return {};
|
|
314
|
+
function handleJsxElement(node) {
|
|
315
|
+
if (jsxAnnotation == null) {
|
|
322
316
|
context.sourceCode.markVariableAsUsed(reactNamespace, node);
|
|
323
317
|
context.sourceCode.markVariableAsUsed(jsxFactory, node);
|
|
318
|
+
debugReport(context, node, reactNamespace);
|
|
319
|
+
debugReport(context, node, jsxFactory);
|
|
324
320
|
}
|
|
321
|
+
if (jsxAnnotation?.jsx != null) {
|
|
322
|
+
context.sourceCode.markVariableAsUsed(jsxAnnotation.jsx, node);
|
|
323
|
+
debugReport(context, node, jsxAnnotation.jsx);
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
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
|
+
}
|
|
335
|
+
}
|
|
336
|
+
return {
|
|
337
|
+
JSXFragment: handleJsxFragment,
|
|
338
|
+
JSXOpeningElement: handleJsxElement,
|
|
339
|
+
JSXOpeningFragment: handleJsxElement
|
|
325
340
|
};
|
|
326
341
|
}
|
|
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
|
+
}
|
|
327
361
|
var RULE_NAME6 = "jsx-uses-vars";
|
|
328
362
|
var RULE_FEATURES6 = [];
|
|
329
363
|
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, createReport } from '@eslint-react/kit';
|
|
8
|
+
import { JsxRuntime, RE_JSX_ANNOTATION, RE_JSX_FRAG_ANNOTATION, createReport } from '@eslint-react/kit';
|
|
9
9
|
import ts, { JsxEmit } from 'typescript';
|
|
10
10
|
import * as AST11 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.1
|
|
116
|
+
var version = "1.40.1";
|
|
117
117
|
var createRule = ESLintUtils.RuleCreator(getDocsUrl("x"));
|
|
118
118
|
|
|
119
119
|
// src/rules/avoid-shorthand-boolean.ts
|
|
@@ -271,7 +271,7 @@ var jsx_uses_react_default = createRule({
|
|
|
271
271
|
[Symbol.for("rule_features")]: RULE_FEATURES5
|
|
272
272
|
},
|
|
273
273
|
messages: {
|
|
274
|
-
jsxUsesReact: ""
|
|
274
|
+
jsxUsesReact: "Marked {{name}} as used."
|
|
275
275
|
},
|
|
276
276
|
schema: []
|
|
277
277
|
},
|
|
@@ -281,21 +281,55 @@ var jsx_uses_react_default = createRule({
|
|
|
281
281
|
});
|
|
282
282
|
function create5(context) {
|
|
283
283
|
const { jsx, jsxFactory, jsxFragmentFactory, reactNamespace } = JsxRuntime.getJsxRuntimeOptionsFromContext(context);
|
|
284
|
-
|
|
285
|
-
return {
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
},
|
|
289
|
-
JSXOpeningElement(node) {
|
|
290
|
-
context.sourceCode.markVariableAsUsed(reactNamespace, node);
|
|
291
|
-
context.sourceCode.markVariableAsUsed(jsxFactory, node);
|
|
292
|
-
},
|
|
293
|
-
JSXOpeningFragment(node) {
|
|
284
|
+
const jsxAnnotation = getJsxAnnotation(context);
|
|
285
|
+
if (jsx === JsxEmit.ReactJSX || jsx === JsxEmit.ReactJSXDev || jsx === JsxEmit.Preserve) return {};
|
|
286
|
+
function handleJsxElement(node) {
|
|
287
|
+
if (jsxAnnotation == null) {
|
|
294
288
|
context.sourceCode.markVariableAsUsed(reactNamespace, node);
|
|
295
289
|
context.sourceCode.markVariableAsUsed(jsxFactory, node);
|
|
290
|
+
debugReport(context, node, reactNamespace);
|
|
291
|
+
debugReport(context, node, jsxFactory);
|
|
296
292
|
}
|
|
293
|
+
if (jsxAnnotation?.jsx != null) {
|
|
294
|
+
context.sourceCode.markVariableAsUsed(jsxAnnotation.jsx, node);
|
|
295
|
+
debugReport(context, node, jsxAnnotation.jsx);
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
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
|
+
}
|
|
307
|
+
}
|
|
308
|
+
return {
|
|
309
|
+
JSXFragment: handleJsxFragment,
|
|
310
|
+
JSXOpeningElement: handleJsxElement,
|
|
311
|
+
JSXOpeningFragment: handleJsxElement
|
|
297
312
|
};
|
|
298
313
|
}
|
|
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
|
+
}
|
|
299
333
|
var RULE_NAME6 = "jsx-uses-vars";
|
|
300
334
|
var RULE_FEATURES6 = [];
|
|
301
335
|
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.1
|
|
3
|
+
"version": "1.40.1",
|
|
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/
|
|
54
|
-
"@eslint-react/
|
|
55
|
-
"@eslint-react/
|
|
56
|
-
"@eslint-react/
|
|
57
|
-
"@eslint-react/
|
|
58
|
-
"@eslint-react/var": "1.40.1
|
|
59
|
-
"@eslint-react/
|
|
53
|
+
"@eslint-react/eff": "1.40.1",
|
|
54
|
+
"@eslint-react/jsx": "1.40.1",
|
|
55
|
+
"@eslint-react/shared": "1.40.1",
|
|
56
|
+
"@eslint-react/core": "1.40.1",
|
|
57
|
+
"@eslint-react/kit": "1.40.1",
|
|
58
|
+
"@eslint-react/var": "1.40.1",
|
|
59
|
+
"@eslint-react/ast": "1.40.1"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
62
|
"@types/react": "^19.0.12",
|