@eslint-react/jsx 1.17.4-next.1 → 1.17.4-next.11
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.d.mts +3 -11
- package/dist/index.d.ts +3 -11
- package/dist/index.js +4 -25
- package/dist/index.mjs +5 -25
- package/package.json +5 -5
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { TSESTree } from '@typescript-eslint/types';
|
|
2
|
-
import { Scope } from '@typescript-eslint/scope-manager';
|
|
3
2
|
import { O } from '@eslint-react/tools';
|
|
3
|
+
import { Scope } from '@typescript-eslint/scope-manager';
|
|
4
4
|
import { TSESTree as TSESTree$1 } from '@typescript-eslint/utils';
|
|
5
5
|
import * as birecord from 'birecord';
|
|
6
6
|
|
|
@@ -11,10 +11,6 @@ import * as birecord from 'birecord';
|
|
|
11
11
|
*/
|
|
12
12
|
declare function getElementName(node: TSESTree.JSXOpeningElement | TSESTree.JSXOpeningFragment): string;
|
|
13
13
|
|
|
14
|
-
declare function getElementType(jsxCtx: {
|
|
15
|
-
getScope: (node: TSESTree.Node) => Scope;
|
|
16
|
-
}, components?: Map<string, string>, polymorphicPropName?: string): (node: TSESTree.JSXOpeningElement) => string;
|
|
17
|
-
|
|
18
14
|
/**
|
|
19
15
|
* Get the name of a JSX attribute with namespace
|
|
20
16
|
* @param node The JSX attribute node
|
|
@@ -28,11 +24,7 @@ declare function getProp(props: (TSESTree$1.JSXAttribute | TSESTree$1.JSXSpreadA
|
|
|
28
24
|
* @param initialScope The initial scope to start from
|
|
29
25
|
* @returns The static value of the given JSX attribute
|
|
30
26
|
*/
|
|
31
|
-
declare function getPropValue(attribute: TSESTree$1.JSXAttribute | TSESTree$1.JSXSpreadAttribute, initialScope: Scope): O.None<
|
|
32
|
-
value: unknown;
|
|
33
|
-
} | null> | O.Some<{
|
|
34
|
-
value: unknown;
|
|
35
|
-
} | null>;
|
|
27
|
+
declare function getPropValue(attribute: TSESTree$1.JSXAttribute | TSESTree$1.JSXSpreadAttribute, initialScope: Scope): O.None<unknown> | O.Some<unknown>;
|
|
36
28
|
/**
|
|
37
29
|
* @param properties The properties to search in
|
|
38
30
|
* @param initialScope The initial scope to start from
|
|
@@ -408,4 +400,4 @@ declare const xhtmlEntities: birecord.BiRecord<{
|
|
|
408
400
|
readonly zwnj: "";
|
|
409
401
|
}>;
|
|
410
402
|
|
|
411
|
-
export { DEFAULT_JSX_VALUE_HINT, JSXValueHint, findPropInAttributes, findPropInProperties, getElementName,
|
|
403
|
+
export { DEFAULT_JSX_VALUE_HINT, JSXValueHint, findPropInAttributes, findPropInProperties, getElementName, getProp, getPropName, getPropValue, hasAnyProp, hasEveryProp, hasProp, isBuiltInElement, isJSXValue, isKeyedElement, isLineBreak, isLiteral, isPaddingSpaces, isUserDefinedElement, isWhiteSpace, traverseUpProp, unescapeStringLiteralText, xhtmlEntities };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { TSESTree } from '@typescript-eslint/types';
|
|
2
|
-
import { Scope } from '@typescript-eslint/scope-manager';
|
|
3
2
|
import { O } from '@eslint-react/tools';
|
|
3
|
+
import { Scope } from '@typescript-eslint/scope-manager';
|
|
4
4
|
import { TSESTree as TSESTree$1 } from '@typescript-eslint/utils';
|
|
5
5
|
import * as birecord from 'birecord';
|
|
6
6
|
|
|
@@ -11,10 +11,6 @@ import * as birecord from 'birecord';
|
|
|
11
11
|
*/
|
|
12
12
|
declare function getElementName(node: TSESTree.JSXOpeningElement | TSESTree.JSXOpeningFragment): string;
|
|
13
13
|
|
|
14
|
-
declare function getElementType(jsxCtx: {
|
|
15
|
-
getScope: (node: TSESTree.Node) => Scope;
|
|
16
|
-
}, components?: Map<string, string>, polymorphicPropName?: string): (node: TSESTree.JSXOpeningElement) => string;
|
|
17
|
-
|
|
18
14
|
/**
|
|
19
15
|
* Get the name of a JSX attribute with namespace
|
|
20
16
|
* @param node The JSX attribute node
|
|
@@ -28,11 +24,7 @@ declare function getProp(props: (TSESTree$1.JSXAttribute | TSESTree$1.JSXSpreadA
|
|
|
28
24
|
* @param initialScope The initial scope to start from
|
|
29
25
|
* @returns The static value of the given JSX attribute
|
|
30
26
|
*/
|
|
31
|
-
declare function getPropValue(attribute: TSESTree$1.JSXAttribute | TSESTree$1.JSXSpreadAttribute, initialScope: Scope): O.None<
|
|
32
|
-
value: unknown;
|
|
33
|
-
} | null> | O.Some<{
|
|
34
|
-
value: unknown;
|
|
35
|
-
} | null>;
|
|
27
|
+
declare function getPropValue(attribute: TSESTree$1.JSXAttribute | TSESTree$1.JSXSpreadAttribute, initialScope: Scope): O.None<unknown> | O.Some<unknown>;
|
|
36
28
|
/**
|
|
37
29
|
* @param properties The properties to search in
|
|
38
30
|
* @param initialScope The initial scope to start from
|
|
@@ -408,4 +400,4 @@ declare const xhtmlEntities: birecord.BiRecord<{
|
|
|
408
400
|
readonly zwnj: "";
|
|
409
401
|
}>;
|
|
410
402
|
|
|
411
|
-
export { DEFAULT_JSX_VALUE_HINT, JSXValueHint, findPropInAttributes, findPropInProperties, getElementName,
|
|
403
|
+
export { DEFAULT_JSX_VALUE_HINT, JSXValueHint, findPropInAttributes, findPropInProperties, getElementName, getProp, getPropName, getPropValue, hasAnyProp, hasEveryProp, hasProp, isBuiltInElement, isJSXValue, isKeyedElement, isLineBreak, isLiteral, isPaddingSpaces, isUserDefinedElement, isWhiteSpace, traverseUpProp, unescapeStringLiteralText, xhtmlEntities };
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var types = require('@typescript-eslint/types');
|
|
4
|
-
var tools = require('@eslint-react/tools');
|
|
5
4
|
var AST = require('@eslint-react/ast');
|
|
5
|
+
var tools = require('@eslint-react/tools');
|
|
6
6
|
var VAR = require('@eslint-react/var');
|
|
7
|
-
var astUtils = require('@typescript-eslint/utils/ast-utils');
|
|
8
7
|
var tsPattern = require('ts-pattern');
|
|
9
8
|
var birecord = require('birecord');
|
|
10
9
|
|
|
@@ -71,14 +70,14 @@ function getPropValue(attribute, initialScope) {
|
|
|
71
70
|
if (attribute.type === types.AST_NODE_TYPES.JSXAttribute && "value" in attribute) {
|
|
72
71
|
const { value } = attribute;
|
|
73
72
|
if (value === null) return tools.O.none();
|
|
74
|
-
if (value.type === types.AST_NODE_TYPES.Literal) return
|
|
73
|
+
if (value.type === types.AST_NODE_TYPES.Literal) return VAR__namespace.getStaticValue(value, initialScope);
|
|
75
74
|
if (value.type === types.AST_NODE_TYPES.JSXExpressionContainer) {
|
|
76
|
-
return
|
|
75
|
+
return VAR__namespace.getStaticValue(value.expression, initialScope);
|
|
77
76
|
}
|
|
78
77
|
return tools.O.none();
|
|
79
78
|
}
|
|
80
79
|
const { argument } = attribute;
|
|
81
|
-
return
|
|
80
|
+
return VAR__namespace.getStaticValue(argument, initialScope);
|
|
82
81
|
}
|
|
83
82
|
function findPropInProperties(properties, initialScope, seenProps = []) {
|
|
84
83
|
return (propName) => {
|
|
@@ -157,25 +156,6 @@ function findPropInAttributes(attributes, initialScope) {
|
|
|
157
156
|
);
|
|
158
157
|
};
|
|
159
158
|
}
|
|
160
|
-
|
|
161
|
-
// src/get-element-type.ts
|
|
162
|
-
function getElementType(jsxCtx, components, polymorphicPropName) {
|
|
163
|
-
return (node) => {
|
|
164
|
-
const elementName = getElementName(node);
|
|
165
|
-
if (elementName === elementName.toLowerCase()) return elementName;
|
|
166
|
-
const asElementName = components?.get(elementName);
|
|
167
|
-
if (tools.isString(asElementName)) return asElementName;
|
|
168
|
-
const initialScope = jsxCtx.getScope(node);
|
|
169
|
-
return tools.F.pipe(
|
|
170
|
-
tools.O.fromNullable(polymorphicPropName),
|
|
171
|
-
tools.O.flatMap(findPropInAttributes(node.attributes, initialScope)),
|
|
172
|
-
tools.O.flatMap((attr) => getPropValue(attr, jsxCtx.getScope(attr))),
|
|
173
|
-
tools.O.flatMapNullable((v) => v?.value),
|
|
174
|
-
tools.O.filter(tools.isString),
|
|
175
|
-
tools.O.getOrElse(() => elementName)
|
|
176
|
-
);
|
|
177
|
-
};
|
|
178
|
-
}
|
|
179
159
|
function hasProp(attributes, propName, initialScope) {
|
|
180
160
|
return tools.O.isSome(findPropInAttributes(attributes, initialScope)(propName));
|
|
181
161
|
}
|
|
@@ -545,7 +525,6 @@ exports.JSXValueHint = JSXValueHint;
|
|
|
545
525
|
exports.findPropInAttributes = findPropInAttributes;
|
|
546
526
|
exports.findPropInProperties = findPropInProperties;
|
|
547
527
|
exports.getElementName = getElementName;
|
|
548
|
-
exports.getElementType = getElementType;
|
|
549
528
|
exports.getProp = getProp;
|
|
550
529
|
exports.getPropName = getPropName;
|
|
551
530
|
exports.getPropValue = getPropValue;
|
package/dist/index.mjs
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { AST_NODE_TYPES } from '@typescript-eslint/types';
|
|
2
|
-
import { O, isString, F } from '@eslint-react/tools';
|
|
3
2
|
import * as AST from '@eslint-react/ast';
|
|
3
|
+
import { O, F, isString } from '@eslint-react/tools';
|
|
4
4
|
import * as VAR from '@eslint-react/var';
|
|
5
|
-
import { getStaticValue } from '@typescript-eslint/utils/ast-utils';
|
|
6
5
|
import { match, P } from 'ts-pattern';
|
|
7
6
|
import birecord from 'birecord';
|
|
8
7
|
|
|
@@ -45,14 +44,14 @@ function getPropValue(attribute, initialScope) {
|
|
|
45
44
|
if (attribute.type === AST_NODE_TYPES.JSXAttribute && "value" in attribute) {
|
|
46
45
|
const { value } = attribute;
|
|
47
46
|
if (value === null) return O.none();
|
|
48
|
-
if (value.type === AST_NODE_TYPES.Literal) return
|
|
47
|
+
if (value.type === AST_NODE_TYPES.Literal) return VAR.getStaticValue(value, initialScope);
|
|
49
48
|
if (value.type === AST_NODE_TYPES.JSXExpressionContainer) {
|
|
50
|
-
return
|
|
49
|
+
return VAR.getStaticValue(value.expression, initialScope);
|
|
51
50
|
}
|
|
52
51
|
return O.none();
|
|
53
52
|
}
|
|
54
53
|
const { argument } = attribute;
|
|
55
|
-
return
|
|
54
|
+
return VAR.getStaticValue(argument, initialScope);
|
|
56
55
|
}
|
|
57
56
|
function findPropInProperties(properties, initialScope, seenProps = []) {
|
|
58
57
|
return (propName) => {
|
|
@@ -131,25 +130,6 @@ function findPropInAttributes(attributes, initialScope) {
|
|
|
131
130
|
);
|
|
132
131
|
};
|
|
133
132
|
}
|
|
134
|
-
|
|
135
|
-
// src/get-element-type.ts
|
|
136
|
-
function getElementType(jsxCtx, components, polymorphicPropName) {
|
|
137
|
-
return (node) => {
|
|
138
|
-
const elementName = getElementName(node);
|
|
139
|
-
if (elementName === elementName.toLowerCase()) return elementName;
|
|
140
|
-
const asElementName = components?.get(elementName);
|
|
141
|
-
if (isString(asElementName)) return asElementName;
|
|
142
|
-
const initialScope = jsxCtx.getScope(node);
|
|
143
|
-
return F.pipe(
|
|
144
|
-
O.fromNullable(polymorphicPropName),
|
|
145
|
-
O.flatMap(findPropInAttributes(node.attributes, initialScope)),
|
|
146
|
-
O.flatMap((attr) => getPropValue(attr, jsxCtx.getScope(attr))),
|
|
147
|
-
O.flatMapNullable((v) => v?.value),
|
|
148
|
-
O.filter(isString),
|
|
149
|
-
O.getOrElse(() => elementName)
|
|
150
|
-
);
|
|
151
|
-
};
|
|
152
|
-
}
|
|
153
133
|
function hasProp(attributes, propName, initialScope) {
|
|
154
134
|
return O.isSome(findPropInAttributes(attributes, initialScope)(propName));
|
|
155
135
|
}
|
|
@@ -514,4 +494,4 @@ function unescapeStringLiteralText(text) {
|
|
|
514
494
|
});
|
|
515
495
|
}
|
|
516
496
|
|
|
517
|
-
export { DEFAULT_JSX_VALUE_HINT, JSXValueHint, findPropInAttributes, findPropInProperties, getElementName,
|
|
497
|
+
export { DEFAULT_JSX_VALUE_HINT, JSXValueHint, findPropInAttributes, findPropInProperties, getElementName, getProp, getPropName, getPropValue, hasAnyProp, hasEveryProp, hasProp, isBuiltInElement, isJSXValue, isKeyedElement, isLineBreak, isLiteral, isPaddingSpaces, isUserDefinedElement, isWhiteSpace, traverseUpProp, unescapeStringLiteralText, xhtmlEntities };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eslint-react/jsx",
|
|
3
|
-
"version": "1.17.4-next.
|
|
3
|
+
"version": "1.17.4-next.11",
|
|
4
4
|
"description": "ESLint React's TSESTree AST utility module for static analysis of JSX.",
|
|
5
5
|
"homepage": "https://github.com/rel1cx/eslint-react",
|
|
6
6
|
"bugs": {
|
|
@@ -40,10 +40,10 @@
|
|
|
40
40
|
"@typescript-eslint/utils": "^8.17.0",
|
|
41
41
|
"birecord": "^0.1.1",
|
|
42
42
|
"ts-pattern": "^5.5.0",
|
|
43
|
-
"@eslint-react/ast": "1.17.4-next.
|
|
44
|
-
"@eslint-react/
|
|
45
|
-
"@eslint-react/
|
|
46
|
-
"@eslint-react/
|
|
43
|
+
"@eslint-react/ast": "1.17.4-next.11",
|
|
44
|
+
"@eslint-react/types": "1.17.4-next.11",
|
|
45
|
+
"@eslint-react/var": "1.17.4-next.11",
|
|
46
|
+
"@eslint-react/tools": "1.17.4-next.11"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"tsup": "^8.3.5"
|