@eslint-react/jsx 0.9.0-beta.0 → 0.9.0-beta.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.
- package/dist/index.cjs +6 -26
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +6 -26
- package/dist/index.mjs +7 -27
- package/package.json +5 -5
package/dist/index.cjs
CHANGED
|
@@ -33,26 +33,6 @@ function resolveMemberExpressions(object, property) {
|
|
|
33
33
|
return name.name;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
/**
|
|
37
|
-
* @since 2.0.0
|
|
38
|
-
*/
|
|
39
|
-
/**
|
|
40
|
-
* Tests if a value is a `string`.
|
|
41
|
-
*
|
|
42
|
-
* @param input - The value to test.
|
|
43
|
-
*
|
|
44
|
-
* @example
|
|
45
|
-
* import { isString } from "effect/Predicate"
|
|
46
|
-
*
|
|
47
|
-
* assert.deepStrictEqual(isString("a"), true)
|
|
48
|
-
*
|
|
49
|
-
* assert.deepStrictEqual(isString(1), false)
|
|
50
|
-
*
|
|
51
|
-
* @category guards
|
|
52
|
-
* @since 2.0.0
|
|
53
|
-
*/
|
|
54
|
-
const isString = input => typeof input === "string";
|
|
55
|
-
|
|
56
36
|
const RE_JSX_ANNOTATION_REGEX = /@jsx\s+(\S+)/u;
|
|
57
37
|
// Does not check for reserved keywords or unicode characters
|
|
58
38
|
const RE_JS_IDENTIFIER_REGEX = /^[$A-Z_a-z][\w$]*$/u;
|
|
@@ -60,7 +40,7 @@ function getFragmentFromContext(context) {
|
|
|
60
40
|
// eslint-disable-next-line prefer-destructuring
|
|
61
41
|
const settings = context.settings;
|
|
62
42
|
const fragment = settings.react?.fragment;
|
|
63
|
-
if (isString(fragment) && RE_JS_IDENTIFIER_REGEX.test(fragment)) {
|
|
43
|
+
if (tools.Pred.isString(fragment) && RE_JS_IDENTIFIER_REGEX.test(fragment)) {
|
|
64
44
|
return fragment;
|
|
65
45
|
}
|
|
66
46
|
return "Fragment";
|
|
@@ -397,14 +377,14 @@ const isFragment = (node, pragma, fragment)=>{
|
|
|
397
377
|
StrictLogical: 1n << 7n,
|
|
398
378
|
StrictConditional: 1n << 8n
|
|
399
379
|
};
|
|
400
|
-
/* eslint-enable perfectionist/sort-objects */ const
|
|
380
|
+
/* eslint-enable perfectionist/sort-objects */ const DEFAULT_JSX_VALUE_CHECK_HINT = JSXValueCheckHint.SkipUndefinedLiteral | JSXValueCheckHint.SkipBooleanLiteral;
|
|
401
381
|
/**
|
|
402
382
|
* Check if a node is a JSX value
|
|
403
383
|
* @param node The AST node to check
|
|
404
384
|
* @param context The rule context
|
|
405
385
|
* @param hint The `JSXValueCheckHint` to use
|
|
406
386
|
* @returns boolean
|
|
407
|
-
*/ function isJSXValue(node, context, hint =
|
|
387
|
+
*/ function isJSXValue(node, context, hint = DEFAULT_JSX_VALUE_CHECK_HINT) {
|
|
408
388
|
if (!node) {
|
|
409
389
|
return false;
|
|
410
390
|
}
|
|
@@ -487,7 +467,7 @@ const isFragment = (node, pragma, fragment)=>{
|
|
|
487
467
|
* @param context The rule context
|
|
488
468
|
* @param hint The `JSXValueCheckHint` to use
|
|
489
469
|
* @returns boolean
|
|
490
|
-
*/ function isFunctionReturningJSXValue(node, context, hint =
|
|
470
|
+
*/ function isFunctionReturningJSXValue(node, context, hint = DEFAULT_JSX_VALUE_CHECK_HINT) {
|
|
491
471
|
if (node.body.type !== ast.NodeType.BlockStatement) {
|
|
492
472
|
return isJSXValue(node.body, context, hint);
|
|
493
473
|
}
|
|
@@ -679,7 +659,7 @@ function getProp(props, propName, context) {
|
|
|
679
659
|
* @param node The AST node to check
|
|
680
660
|
* @returns boolean `true` if the node is whitespace
|
|
681
661
|
*/ function isWhiteSpace(node) {
|
|
682
|
-
return isString(node.value) && node.value.trim() === "";
|
|
662
|
+
return tools.Pred.isString(node.value) && node.value.trim() === "";
|
|
683
663
|
}
|
|
684
664
|
/**
|
|
685
665
|
* Check if a Literal or JSXText node is a line break
|
|
@@ -696,8 +676,8 @@ function getProp(props, propName, context) {
|
|
|
696
676
|
return isLiteral(node) && isWhiteSpace(node) && node.raw.includes("\n");
|
|
697
677
|
}
|
|
698
678
|
|
|
679
|
+
exports.DEFAULT_JSX_VALUE_CHECK_HINT = DEFAULT_JSX_VALUE_CHECK_HINT;
|
|
699
680
|
exports.JSXValueCheckHint = JSXValueCheckHint;
|
|
700
|
-
exports.defaultJSXValueCheckHint = defaultJSXValueCheckHint;
|
|
701
681
|
exports.elementType = elementType;
|
|
702
682
|
exports.findPropInAttributes = findPropInAttributes;
|
|
703
683
|
exports.findPropInProperties = findPropInProperties;
|
package/dist/index.d.mts
CHANGED
|
@@ -222,7 +222,7 @@ declare const JSXValueCheckHint: {
|
|
|
222
222
|
readonly StrictLogical: bigint;
|
|
223
223
|
readonly StrictConditional: bigint;
|
|
224
224
|
};
|
|
225
|
-
declare const
|
|
225
|
+
declare const DEFAULT_JSX_VALUE_CHECK_HINT: bigint;
|
|
226
226
|
/**
|
|
227
227
|
* Check if a node is a JSX value
|
|
228
228
|
* @param node The AST node to check
|
|
@@ -232,4 +232,4 @@ declare const defaultJSXValueCheckHint: bigint;
|
|
|
232
232
|
*/
|
|
233
233
|
declare function isJSXValue(node: TSESTree$1.Node | null | undefined, context: RuleContext, hint?: bigint): boolean;
|
|
234
234
|
|
|
235
|
-
export { type CallFromPragmaPredicate,
|
|
235
|
+
export { type CallFromPragmaPredicate, DEFAULT_JSX_VALUE_CHECK_HINT, JSXValueCheckHint, elementType, findPropInAttributes, findPropInProperties, getFragmentFromContext, getPragmaFromContext, getProp, getPropName, getPropValue, hasAnyProp, hasChildren, hasEveryProp, hasProp, hdlAnimation, hdlClipboard, hdlComposition, hdlFocus, hdlForm, hdlImage, hdlKeyboard, hdlMedia, hdlMouse, hdlScroll, hdlSelection, hdlTouch, hdlTransition, hdlWheel, isCallFromPragma, isChildOfJSXElement, isChildrenOfCreateElement, isCloneElementCall, isCreateElementCall, isFragment, isFragmentElement, isFragmentSyntax, isFunctionReturningJSXValue, isInitializedFromPragma, isInsideCreateElementProps, isInsidePropValue, isJSXElementOfBuiltinComponent, isJSXElementOfUserDefinedComponent, isJSXValue, isLineBreak, isLiteral, isPaddingSpaces, isPropertyOfPragma, isWhiteSpace, traverseUpProp };
|
package/dist/index.d.ts
CHANGED
|
@@ -222,7 +222,7 @@ declare const JSXValueCheckHint: {
|
|
|
222
222
|
readonly StrictLogical: bigint;
|
|
223
223
|
readonly StrictConditional: bigint;
|
|
224
224
|
};
|
|
225
|
-
declare const
|
|
225
|
+
declare const DEFAULT_JSX_VALUE_CHECK_HINT: bigint;
|
|
226
226
|
/**
|
|
227
227
|
* Check if a node is a JSX value
|
|
228
228
|
* @param node The AST node to check
|
|
@@ -232,4 +232,4 @@ declare const defaultJSXValueCheckHint: bigint;
|
|
|
232
232
|
*/
|
|
233
233
|
declare function isJSXValue(node: TSESTree$1.Node | null | undefined, context: RuleContext, hint?: bigint): boolean;
|
|
234
234
|
|
|
235
|
-
export { type CallFromPragmaPredicate,
|
|
235
|
+
export { type CallFromPragmaPredicate, DEFAULT_JSX_VALUE_CHECK_HINT, JSXValueCheckHint, elementType, findPropInAttributes, findPropInProperties, getFragmentFromContext, getPragmaFromContext, getProp, getPropName, getPropValue, hasAnyProp, hasChildren, hasEveryProp, hasProp, hdlAnimation, hdlClipboard, hdlComposition, hdlFocus, hdlForm, hdlImage, hdlKeyboard, hdlMedia, hdlMouse, hdlScroll, hdlSelection, hdlTouch, hdlTransition, hdlWheel, isCallFromPragma, isChildOfJSXElement, isChildrenOfCreateElement, isCloneElementCall, isCreateElementCall, isFragment, isFragmentElement, isFragmentSyntax, isFunctionReturningJSXValue, isInitializedFromPragma, isInsideCreateElementProps, isInsidePropValue, isJSXElementOfBuiltinComponent, isJSXElementOfUserDefinedComponent, isJSXValue, isLineBreak, isLiteral, isPaddingSpaces, isPropertyOfPragma, isWhiteSpace, traverseUpProp };
|
package/dist/index.js
CHANGED
|
@@ -33,26 +33,6 @@ function resolveMemberExpressions(object, property) {
|
|
|
33
33
|
return name.name;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
/**
|
|
37
|
-
* @since 2.0.0
|
|
38
|
-
*/
|
|
39
|
-
/**
|
|
40
|
-
* Tests if a value is a `string`.
|
|
41
|
-
*
|
|
42
|
-
* @param input - The value to test.
|
|
43
|
-
*
|
|
44
|
-
* @example
|
|
45
|
-
* import { isString } from "effect/Predicate"
|
|
46
|
-
*
|
|
47
|
-
* assert.deepStrictEqual(isString("a"), true)
|
|
48
|
-
*
|
|
49
|
-
* assert.deepStrictEqual(isString(1), false)
|
|
50
|
-
*
|
|
51
|
-
* @category guards
|
|
52
|
-
* @since 2.0.0
|
|
53
|
-
*/
|
|
54
|
-
const isString = input => typeof input === "string";
|
|
55
|
-
|
|
56
36
|
const RE_JSX_ANNOTATION_REGEX = /@jsx\s+(\S+)/u;
|
|
57
37
|
// Does not check for reserved keywords or unicode characters
|
|
58
38
|
const RE_JS_IDENTIFIER_REGEX = /^[$A-Z_a-z][\w$]*$/u;
|
|
@@ -60,7 +40,7 @@ function getFragmentFromContext(context) {
|
|
|
60
40
|
// eslint-disable-next-line prefer-destructuring
|
|
61
41
|
const settings = context.settings;
|
|
62
42
|
const fragment = settings.react?.fragment;
|
|
63
|
-
if (isString(fragment) && RE_JS_IDENTIFIER_REGEX.test(fragment)) {
|
|
43
|
+
if (tools.Pred.isString(fragment) && RE_JS_IDENTIFIER_REGEX.test(fragment)) {
|
|
64
44
|
return fragment;
|
|
65
45
|
}
|
|
66
46
|
return "Fragment";
|
|
@@ -397,14 +377,14 @@ const isFragment = (node, pragma, fragment)=>{
|
|
|
397
377
|
StrictLogical: 1n << 7n,
|
|
398
378
|
StrictConditional: 1n << 8n
|
|
399
379
|
};
|
|
400
|
-
/* eslint-enable perfectionist/sort-objects */ const
|
|
380
|
+
/* eslint-enable perfectionist/sort-objects */ const DEFAULT_JSX_VALUE_CHECK_HINT = JSXValueCheckHint.SkipUndefinedLiteral | JSXValueCheckHint.SkipBooleanLiteral;
|
|
401
381
|
/**
|
|
402
382
|
* Check if a node is a JSX value
|
|
403
383
|
* @param node The AST node to check
|
|
404
384
|
* @param context The rule context
|
|
405
385
|
* @param hint The `JSXValueCheckHint` to use
|
|
406
386
|
* @returns boolean
|
|
407
|
-
*/ function isJSXValue(node, context, hint =
|
|
387
|
+
*/ function isJSXValue(node, context, hint = DEFAULT_JSX_VALUE_CHECK_HINT) {
|
|
408
388
|
if (!node) {
|
|
409
389
|
return false;
|
|
410
390
|
}
|
|
@@ -487,7 +467,7 @@ const isFragment = (node, pragma, fragment)=>{
|
|
|
487
467
|
* @param context The rule context
|
|
488
468
|
* @param hint The `JSXValueCheckHint` to use
|
|
489
469
|
* @returns boolean
|
|
490
|
-
*/ function isFunctionReturningJSXValue(node, context, hint =
|
|
470
|
+
*/ function isFunctionReturningJSXValue(node, context, hint = DEFAULT_JSX_VALUE_CHECK_HINT) {
|
|
491
471
|
if (node.body.type !== ast.NodeType.BlockStatement) {
|
|
492
472
|
return isJSXValue(node.body, context, hint);
|
|
493
473
|
}
|
|
@@ -679,7 +659,7 @@ function getProp(props, propName, context) {
|
|
|
679
659
|
* @param node The AST node to check
|
|
680
660
|
* @returns boolean `true` if the node is whitespace
|
|
681
661
|
*/ function isWhiteSpace(node) {
|
|
682
|
-
return isString(node.value) && node.value.trim() === "";
|
|
662
|
+
return tools.Pred.isString(node.value) && node.value.trim() === "";
|
|
683
663
|
}
|
|
684
664
|
/**
|
|
685
665
|
* Check if a Literal or JSXText node is a line break
|
|
@@ -696,8 +676,8 @@ function getProp(props, propName, context) {
|
|
|
696
676
|
return isLiteral(node) && isWhiteSpace(node) && node.raw.includes("\n");
|
|
697
677
|
}
|
|
698
678
|
|
|
679
|
+
exports.DEFAULT_JSX_VALUE_CHECK_HINT = DEFAULT_JSX_VALUE_CHECK_HINT;
|
|
699
680
|
exports.JSXValueCheckHint = JSXValueCheckHint;
|
|
700
|
-
exports.defaultJSXValueCheckHint = defaultJSXValueCheckHint;
|
|
701
681
|
exports.elementType = elementType;
|
|
702
682
|
exports.findPropInAttributes = findPropInAttributes;
|
|
703
683
|
exports.findPropInProperties = findPropInProperties;
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AST_NODE_TYPES } from '@typescript-eslint/types';
|
|
2
2
|
import { getVariablesUpToGlobal, findVariableByName, NodeType, traverseUp, is, isOneOf, isJSXTagNameExpression, findVariableByNameUpToGlobal, getVariableInit, getNestedReturnStatements, getStaticValue, traverseUpGuard, isStringLiteral, isMultiLine } from '@eslint-react/ast';
|
|
3
|
-
import { F, O as O$1 } from '@eslint-react/tools';
|
|
3
|
+
import { F, O as O$1, Pred } from '@eslint-react/tools';
|
|
4
4
|
import memo from 'micro-memoize';
|
|
5
5
|
|
|
6
6
|
function resolveMemberExpressions(object, property) {
|
|
@@ -31,26 +31,6 @@ function resolveMemberExpressions(object, property) {
|
|
|
31
31
|
return name.name;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
/**
|
|
35
|
-
* @since 2.0.0
|
|
36
|
-
*/
|
|
37
|
-
/**
|
|
38
|
-
* Tests if a value is a `string`.
|
|
39
|
-
*
|
|
40
|
-
* @param input - The value to test.
|
|
41
|
-
*
|
|
42
|
-
* @example
|
|
43
|
-
* import { isString } from "effect/Predicate"
|
|
44
|
-
*
|
|
45
|
-
* assert.deepStrictEqual(isString("a"), true)
|
|
46
|
-
*
|
|
47
|
-
* assert.deepStrictEqual(isString(1), false)
|
|
48
|
-
*
|
|
49
|
-
* @category guards
|
|
50
|
-
* @since 2.0.0
|
|
51
|
-
*/
|
|
52
|
-
const isString = input => typeof input === "string";
|
|
53
|
-
|
|
54
34
|
const RE_JSX_ANNOTATION_REGEX = /@jsx\s+(\S+)/u;
|
|
55
35
|
// Does not check for reserved keywords or unicode characters
|
|
56
36
|
const RE_JS_IDENTIFIER_REGEX = /^[$A-Z_a-z][\w$]*$/u;
|
|
@@ -58,7 +38,7 @@ function getFragmentFromContext(context) {
|
|
|
58
38
|
// eslint-disable-next-line prefer-destructuring
|
|
59
39
|
const settings = context.settings;
|
|
60
40
|
const fragment = settings.react?.fragment;
|
|
61
|
-
if (isString(fragment) && RE_JS_IDENTIFIER_REGEX.test(fragment)) {
|
|
41
|
+
if (Pred.isString(fragment) && RE_JS_IDENTIFIER_REGEX.test(fragment)) {
|
|
62
42
|
return fragment;
|
|
63
43
|
}
|
|
64
44
|
return "Fragment";
|
|
@@ -395,14 +375,14 @@ const isFragment = (node, pragma, fragment)=>{
|
|
|
395
375
|
StrictLogical: 1n << 7n,
|
|
396
376
|
StrictConditional: 1n << 8n
|
|
397
377
|
};
|
|
398
|
-
/* eslint-enable perfectionist/sort-objects */ const
|
|
378
|
+
/* eslint-enable perfectionist/sort-objects */ const DEFAULT_JSX_VALUE_CHECK_HINT = JSXValueCheckHint.SkipUndefinedLiteral | JSXValueCheckHint.SkipBooleanLiteral;
|
|
399
379
|
/**
|
|
400
380
|
* Check if a node is a JSX value
|
|
401
381
|
* @param node The AST node to check
|
|
402
382
|
* @param context The rule context
|
|
403
383
|
* @param hint The `JSXValueCheckHint` to use
|
|
404
384
|
* @returns boolean
|
|
405
|
-
*/ function isJSXValue(node, context, hint =
|
|
385
|
+
*/ function isJSXValue(node, context, hint = DEFAULT_JSX_VALUE_CHECK_HINT) {
|
|
406
386
|
if (!node) {
|
|
407
387
|
return false;
|
|
408
388
|
}
|
|
@@ -485,7 +465,7 @@ const isFragment = (node, pragma, fragment)=>{
|
|
|
485
465
|
* @param context The rule context
|
|
486
466
|
* @param hint The `JSXValueCheckHint` to use
|
|
487
467
|
* @returns boolean
|
|
488
|
-
*/ function isFunctionReturningJSXValue(node, context, hint =
|
|
468
|
+
*/ function isFunctionReturningJSXValue(node, context, hint = DEFAULT_JSX_VALUE_CHECK_HINT) {
|
|
489
469
|
if (node.body.type !== NodeType.BlockStatement) {
|
|
490
470
|
return isJSXValue(node.body, context, hint);
|
|
491
471
|
}
|
|
@@ -677,7 +657,7 @@ function getProp(props, propName, context) {
|
|
|
677
657
|
* @param node The AST node to check
|
|
678
658
|
* @returns boolean `true` if the node is whitespace
|
|
679
659
|
*/ function isWhiteSpace(node) {
|
|
680
|
-
return isString(node.value) && node.value.trim() === "";
|
|
660
|
+
return Pred.isString(node.value) && node.value.trim() === "";
|
|
681
661
|
}
|
|
682
662
|
/**
|
|
683
663
|
* Check if a Literal or JSXText node is a line break
|
|
@@ -694,4 +674,4 @@ function getProp(props, propName, context) {
|
|
|
694
674
|
return isLiteral(node) && isWhiteSpace(node) && node.raw.includes("\n");
|
|
695
675
|
}
|
|
696
676
|
|
|
697
|
-
export {
|
|
677
|
+
export { DEFAULT_JSX_VALUE_CHECK_HINT, JSXValueCheckHint, elementType, findPropInAttributes, findPropInProperties, getFragmentFromContext, getPragmaFromContext, getProp, getPropName, getPropValue, hasAnyProp, hasChildren, hasEveryProp, hasProp, hdlAnimation, hdlClipboard, hdlComposition, hdlFocus, hdlForm, hdlImage, hdlKeyboard, hdlMedia, hdlMouse, hdlScroll, hdlSelection, hdlTouch, hdlTransition, hdlWheel, isCallFromPragma, isChildOfJSXElement, isChildrenOfCreateElement, isCloneElementCall, isCreateElementCall, isFragment, isFragmentElement, isFragmentSyntax, isFunctionReturningJSXValue, isInitializedFromPragma, isInsideCreateElementProps, isInsidePropValue, isJSXElementOfBuiltinComponent, isJSXElementOfUserDefinedComponent, isJSXValue, isLineBreak, isLiteral, isPaddingSpaces, isPropertyOfPragma, isWhiteSpace, traverseUpProp };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eslint-react/jsx",
|
|
3
|
-
"version": "0.9.0-beta.
|
|
3
|
+
"version": "0.9.0-beta.2",
|
|
4
4
|
"description": "ESLint x React's TSESTree AST utility module for static analysis of JSX.",
|
|
5
5
|
"homepage": "https://github.com/rel1cx/eslint-react",
|
|
6
6
|
"bugs": {
|
|
@@ -38,10 +38,10 @@
|
|
|
38
38
|
"@typescript-eslint/types": "6.13.1",
|
|
39
39
|
"@typescript-eslint/utils": "6.13.1",
|
|
40
40
|
"micro-memoize": "4.1.2",
|
|
41
|
-
"@eslint-react/
|
|
42
|
-
"@eslint-react/
|
|
43
|
-
"@eslint-react/shared": "0.9.0-beta.
|
|
44
|
-
"@eslint-react/
|
|
41
|
+
"@eslint-react/ast": "0.9.0-beta.2",
|
|
42
|
+
"@eslint-react/types": "0.9.0-beta.2",
|
|
43
|
+
"@eslint-react/shared": "0.9.0-beta.2",
|
|
44
|
+
"@eslint-react/tools": "0.9.0-beta.2"
|
|
45
45
|
},
|
|
46
46
|
"scripts": {
|
|
47
47
|
"build": "rollup -c rollup.config.ts --configPlugin swc3 && cp dist/index.d.ts dist/index.d.mts",
|