@eslint-react/jsx 0.6.0 → 0.6.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.cjs +257 -171
- package/dist/index.d.mts +59 -65
- package/dist/index.d.ts +59 -65
- package/dist/index.js +257 -171
- package/dist/index.mjs +256 -170
- package/package.json +5 -5
package/dist/index.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { TSESTree } from '@typescript-eslint/types';
|
|
2
2
|
import { RuleContext } from '@eslint-react/types';
|
|
3
3
|
import { TSESTreeFunction } from '@eslint-react/ast';
|
|
4
|
-
import { TSESTree as TSESTree$1 } from '@typescript-eslint/utils';
|
|
5
4
|
import { O } from '@eslint-react/tools';
|
|
5
|
+
import { TSESTree as TSESTree$1 } from '@typescript-eslint/utils';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Check if a `JSXElement` or `JSXFragment` has children
|
|
@@ -121,37 +121,49 @@ declare function isFragmentWithOnlyTextAndIsNotChild(node: TSESTree.JSXElement |
|
|
|
121
121
|
declare function isFragmentHasLessThanTwoChildren(node: TSESTree.JSXElement | TSESTree.JSXFragment): boolean;
|
|
122
122
|
declare function isFragmentWithSingleExpression(node: TSESTree.JSXElement | TSESTree.JSXFragment): boolean;
|
|
123
123
|
|
|
124
|
-
type JSXValueCheckOptions = {
|
|
125
|
-
/**
|
|
126
|
-
* Whether to check all branches of the conditional expression
|
|
127
|
-
*/
|
|
128
|
-
strict?: boolean;
|
|
129
|
-
/**
|
|
130
|
-
* Whether to ignore null values
|
|
131
|
-
*/
|
|
132
|
-
ignoreNull?: boolean;
|
|
133
|
-
};
|
|
134
|
-
declare const defaultJSXValueCheckOptions: {
|
|
135
|
-
readonly ignoreNull: false;
|
|
136
|
-
readonly strict: false;
|
|
137
|
-
};
|
|
138
124
|
/**
|
|
139
|
-
* Check if
|
|
140
|
-
* @param node The
|
|
125
|
+
* Check if function is returning JSX
|
|
126
|
+
* @param node The return statement node to check
|
|
141
127
|
* @param context The rule context
|
|
142
|
-
* @param
|
|
128
|
+
* @param hint The `JSXValueCheckHint` to use
|
|
143
129
|
* @returns boolean
|
|
144
130
|
*/
|
|
145
|
-
declare function
|
|
131
|
+
declare function isFunctionReturningJSXValue(node: TSESTreeFunction, context: RuleContext, hint?: 0n): boolean;
|
|
146
132
|
|
|
147
133
|
/**
|
|
148
|
-
*
|
|
149
|
-
* @param node The return statement node to check
|
|
134
|
+
* @param attributes The attributes to search in
|
|
150
135
|
* @param context The rule context
|
|
151
|
-
* @
|
|
152
|
-
|
|
136
|
+
* @returns A function that searches for a property in the given attributes
|
|
137
|
+
*/
|
|
138
|
+
declare function findPropInAttributes(attributes: (TSESTree.JSXAttribute | TSESTree.JSXSpreadAttribute)[], context: RuleContext): (propName: string) => O.Option<NonNullable<TSESTree.JSXAttribute | TSESTree.JSXSpreadAttribute | undefined>>;
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* @param properties The properties to search in
|
|
142
|
+
* @param context The rule context
|
|
143
|
+
* @param seenProps The properties that have already been seen
|
|
144
|
+
* @returns A function that searches for a property in the given properties
|
|
145
|
+
*/
|
|
146
|
+
declare function findPropInProperties(properties: (TSESTree.Property | TSESTree.RestElement | TSESTree.SpreadElement)[] | TSESTree.ObjectLiteralElement[], context: RuleContext, seenProps?: string[]): (propName: string) => O.Option<(typeof properties)[number]>;
|
|
147
|
+
|
|
148
|
+
declare function getProp(props: TSESTree.JSXAttribute[], propName: string, context: RuleContext): O.Option<TSESTree.JSXAttribute | TSESTree.JSXSpreadAttribute>;
|
|
149
|
+
/**
|
|
150
|
+
* Gets and resolves the static value of a JSX attribute
|
|
151
|
+
* @param attribute The JSX attribute to get the value of
|
|
152
|
+
* @param context The rule context
|
|
153
|
+
* @returns The static value of the given JSX attribute
|
|
153
154
|
*/
|
|
154
|
-
declare function
|
|
155
|
+
declare function getPropValue(attribute: TSESTree.JSXAttribute | TSESTree.JSXSpreadAttribute, context: RuleContext): O.None<{
|
|
156
|
+
value: unknown;
|
|
157
|
+
} | null> | O.Some<{
|
|
158
|
+
value: unknown;
|
|
159
|
+
} | null>;
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Get the name of a JSX attribute with namespace
|
|
163
|
+
* @param node The JSX attribute node
|
|
164
|
+
* @returns string
|
|
165
|
+
*/
|
|
166
|
+
declare function getPropName(node: TSESTree.JSXAttribute): string;
|
|
155
167
|
|
|
156
168
|
/**
|
|
157
169
|
* Check if the given prop name is present in the given attributes
|
|
@@ -177,18 +189,14 @@ declare function hasAnyProp(attributes: (TSESTree.JSXAttribute | TSESTree.JSXSpr
|
|
|
177
189
|
* @returns `true` if all of the given prop names are present in the given attributes
|
|
178
190
|
*/
|
|
179
191
|
declare function hasEveryProp(attributes: (TSESTree.JSXAttribute | TSESTree.JSXSpreadAttribute)[], propNames: string[], context: RuleContext): boolean;
|
|
192
|
+
|
|
180
193
|
/**
|
|
181
|
-
*
|
|
182
|
-
* @param node The
|
|
183
|
-
* @returns
|
|
184
|
-
*/
|
|
185
|
-
declare function getPropName(node: TSESTree.JSXAttribute): string;
|
|
186
|
-
/**
|
|
187
|
-
* Get the name of a JSX attribute with namespace
|
|
188
|
-
* @param node The JSX attribute node
|
|
189
|
-
* @returns string
|
|
194
|
+
* Checks if the node is inside a prop's value
|
|
195
|
+
* @param node The AST node to check
|
|
196
|
+
* @returns `true` if the node is inside a prop's value
|
|
190
197
|
*/
|
|
191
|
-
declare function
|
|
198
|
+
declare function isInsidePropValue(node: TSESTree.Node): boolean;
|
|
199
|
+
|
|
192
200
|
/**
|
|
193
201
|
* Traverses up prop node
|
|
194
202
|
* @param node The AST node to start traversing from
|
|
@@ -196,36 +204,6 @@ declare function getPropNameWithNamespace(node: TSESTree.JSXAttribute): string;
|
|
|
196
204
|
* @returns prop node if found
|
|
197
205
|
*/
|
|
198
206
|
declare function traverseUpProp(node: TSESTree.Node, predicate?: (node: TSESTree.JSXAttribute) => boolean): O.Option<TSESTree.JSXAttribute>;
|
|
199
|
-
/**
|
|
200
|
-
* Checks if the node is inside a prop's value
|
|
201
|
-
* @param node The AST node to check
|
|
202
|
-
* @returns `true` if the node is inside a prop's value
|
|
203
|
-
*/
|
|
204
|
-
declare function isInsidePropValue(node: TSESTree.Node): boolean;
|
|
205
|
-
/**
|
|
206
|
-
* @param properties The properties to search in
|
|
207
|
-
* @param context The rule context
|
|
208
|
-
* @param seenProps The properties that have already been seen
|
|
209
|
-
* @returns A function that searches for a property in the given properties
|
|
210
|
-
*/
|
|
211
|
-
declare function findPropInProperties(properties: (TSESTree.Property | TSESTree.RestElement)[] | TSESTree.ObjectLiteralElement[], context: RuleContext, seenProps?: string[]): (propName: string) => O.Option<(typeof properties)[number]>;
|
|
212
|
-
/**
|
|
213
|
-
* @param attributes The attributes to search in
|
|
214
|
-
* @param context The rule context
|
|
215
|
-
* @returns A function that searches for a property in the given attributes
|
|
216
|
-
*/
|
|
217
|
-
declare function findPropInAttributes(attributes: (TSESTree.JSXAttribute | TSESTree.JSXSpreadAttribute)[], context: RuleContext): (propName: string) => O.Option<NonNullable<TSESTree.JSXAttribute | TSESTree.JSXSpreadAttribute | undefined>>;
|
|
218
|
-
/**
|
|
219
|
-
* Gets and resolves the static value of a JSX attribute
|
|
220
|
-
* @param attribute The JSX attribute to get the value of
|
|
221
|
-
* @param context The rule context
|
|
222
|
-
* @returns The static value of the given JSX attribute
|
|
223
|
-
*/
|
|
224
|
-
declare function getPropValue(attribute: TSESTree.JSXAttribute | TSESTree.JSXSpreadAttribute, context: RuleContext): O.None<{
|
|
225
|
-
value: unknown;
|
|
226
|
-
} | null> | O.Some<{
|
|
227
|
-
value: unknown;
|
|
228
|
-
} | null>;
|
|
229
207
|
|
|
230
208
|
/**
|
|
231
209
|
* Check if a node is a Literal or JSXText
|
|
@@ -252,4 +230,20 @@ declare function isLineBreak(node: TSESTree.Node): boolean;
|
|
|
252
230
|
*/
|
|
253
231
|
declare function isPaddingSpaces(node: TSESTree.Node): boolean;
|
|
254
232
|
|
|
255
|
-
|
|
233
|
+
declare const JSXValueCheckHint: {
|
|
234
|
+
readonly None: 0n;
|
|
235
|
+
readonly IgnoreNull: bigint;
|
|
236
|
+
readonly IgnoreCreateElement: bigint;
|
|
237
|
+
readonly StrictLogical: bigint;
|
|
238
|
+
readonly StrictConditional: bigint;
|
|
239
|
+
};
|
|
240
|
+
/**
|
|
241
|
+
* Check if a node is a JSX value
|
|
242
|
+
* @param node The AST node to check
|
|
243
|
+
* @param context The rule context
|
|
244
|
+
* @param hint The `JSXValueCheckHint` to use
|
|
245
|
+
* @returns boolean
|
|
246
|
+
*/
|
|
247
|
+
declare function isJSXValue(node: TSESTree$1.Node | null | undefined, context: RuleContext, hint?: bigint): boolean;
|
|
248
|
+
|
|
249
|
+
export { type CallFromPragmaPredicate, 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, isFragmentHasLessThanTwoChildren, isFragmentSyntax, isFragmentWithOnlyTextAndIsNotChild, isFragmentWithSingleExpression, isFunctionReturningJSXValue, isInitializedFromPragma, isInsideCreateElementProps, isInsidePropValue, isJSXElementOfBuiltinComponent, isJSXElementOfUserDefinedComponent, isJSXValue, isLineBreak, isLiteral, isPaddingSpaces, isPropertyOfPragma, isWhiteSpace, traverseUpProp };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { TSESTree } from '@typescript-eslint/types';
|
|
2
2
|
import { RuleContext } from '@eslint-react/types';
|
|
3
3
|
import { TSESTreeFunction } from '@eslint-react/ast';
|
|
4
|
-
import { TSESTree as TSESTree$1 } from '@typescript-eslint/utils';
|
|
5
4
|
import { O } from '@eslint-react/tools';
|
|
5
|
+
import { TSESTree as TSESTree$1 } from '@typescript-eslint/utils';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Check if a `JSXElement` or `JSXFragment` has children
|
|
@@ -121,37 +121,49 @@ declare function isFragmentWithOnlyTextAndIsNotChild(node: TSESTree.JSXElement |
|
|
|
121
121
|
declare function isFragmentHasLessThanTwoChildren(node: TSESTree.JSXElement | TSESTree.JSXFragment): boolean;
|
|
122
122
|
declare function isFragmentWithSingleExpression(node: TSESTree.JSXElement | TSESTree.JSXFragment): boolean;
|
|
123
123
|
|
|
124
|
-
type JSXValueCheckOptions = {
|
|
125
|
-
/**
|
|
126
|
-
* Whether to check all branches of the conditional expression
|
|
127
|
-
*/
|
|
128
|
-
strict?: boolean;
|
|
129
|
-
/**
|
|
130
|
-
* Whether to ignore null values
|
|
131
|
-
*/
|
|
132
|
-
ignoreNull?: boolean;
|
|
133
|
-
};
|
|
134
|
-
declare const defaultJSXValueCheckOptions: {
|
|
135
|
-
readonly ignoreNull: false;
|
|
136
|
-
readonly strict: false;
|
|
137
|
-
};
|
|
138
124
|
/**
|
|
139
|
-
* Check if
|
|
140
|
-
* @param node The
|
|
125
|
+
* Check if function is returning JSX
|
|
126
|
+
* @param node The return statement node to check
|
|
141
127
|
* @param context The rule context
|
|
142
|
-
* @param
|
|
128
|
+
* @param hint The `JSXValueCheckHint` to use
|
|
143
129
|
* @returns boolean
|
|
144
130
|
*/
|
|
145
|
-
declare function
|
|
131
|
+
declare function isFunctionReturningJSXValue(node: TSESTreeFunction, context: RuleContext, hint?: 0n): boolean;
|
|
146
132
|
|
|
147
133
|
/**
|
|
148
|
-
*
|
|
149
|
-
* @param node The return statement node to check
|
|
134
|
+
* @param attributes The attributes to search in
|
|
150
135
|
* @param context The rule context
|
|
151
|
-
* @
|
|
152
|
-
|
|
136
|
+
* @returns A function that searches for a property in the given attributes
|
|
137
|
+
*/
|
|
138
|
+
declare function findPropInAttributes(attributes: (TSESTree.JSXAttribute | TSESTree.JSXSpreadAttribute)[], context: RuleContext): (propName: string) => O.Option<NonNullable<TSESTree.JSXAttribute | TSESTree.JSXSpreadAttribute | undefined>>;
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* @param properties The properties to search in
|
|
142
|
+
* @param context The rule context
|
|
143
|
+
* @param seenProps The properties that have already been seen
|
|
144
|
+
* @returns A function that searches for a property in the given properties
|
|
145
|
+
*/
|
|
146
|
+
declare function findPropInProperties(properties: (TSESTree.Property | TSESTree.RestElement | TSESTree.SpreadElement)[] | TSESTree.ObjectLiteralElement[], context: RuleContext, seenProps?: string[]): (propName: string) => O.Option<(typeof properties)[number]>;
|
|
147
|
+
|
|
148
|
+
declare function getProp(props: TSESTree.JSXAttribute[], propName: string, context: RuleContext): O.Option<TSESTree.JSXAttribute | TSESTree.JSXSpreadAttribute>;
|
|
149
|
+
/**
|
|
150
|
+
* Gets and resolves the static value of a JSX attribute
|
|
151
|
+
* @param attribute The JSX attribute to get the value of
|
|
152
|
+
* @param context The rule context
|
|
153
|
+
* @returns The static value of the given JSX attribute
|
|
153
154
|
*/
|
|
154
|
-
declare function
|
|
155
|
+
declare function getPropValue(attribute: TSESTree.JSXAttribute | TSESTree.JSXSpreadAttribute, context: RuleContext): O.None<{
|
|
156
|
+
value: unknown;
|
|
157
|
+
} | null> | O.Some<{
|
|
158
|
+
value: unknown;
|
|
159
|
+
} | null>;
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Get the name of a JSX attribute with namespace
|
|
163
|
+
* @param node The JSX attribute node
|
|
164
|
+
* @returns string
|
|
165
|
+
*/
|
|
166
|
+
declare function getPropName(node: TSESTree.JSXAttribute): string;
|
|
155
167
|
|
|
156
168
|
/**
|
|
157
169
|
* Check if the given prop name is present in the given attributes
|
|
@@ -177,18 +189,14 @@ declare function hasAnyProp(attributes: (TSESTree.JSXAttribute | TSESTree.JSXSpr
|
|
|
177
189
|
* @returns `true` if all of the given prop names are present in the given attributes
|
|
178
190
|
*/
|
|
179
191
|
declare function hasEveryProp(attributes: (TSESTree.JSXAttribute | TSESTree.JSXSpreadAttribute)[], propNames: string[], context: RuleContext): boolean;
|
|
192
|
+
|
|
180
193
|
/**
|
|
181
|
-
*
|
|
182
|
-
* @param node The
|
|
183
|
-
* @returns
|
|
184
|
-
*/
|
|
185
|
-
declare function getPropName(node: TSESTree.JSXAttribute): string;
|
|
186
|
-
/**
|
|
187
|
-
* Get the name of a JSX attribute with namespace
|
|
188
|
-
* @param node The JSX attribute node
|
|
189
|
-
* @returns string
|
|
194
|
+
* Checks if the node is inside a prop's value
|
|
195
|
+
* @param node The AST node to check
|
|
196
|
+
* @returns `true` if the node is inside a prop's value
|
|
190
197
|
*/
|
|
191
|
-
declare function
|
|
198
|
+
declare function isInsidePropValue(node: TSESTree.Node): boolean;
|
|
199
|
+
|
|
192
200
|
/**
|
|
193
201
|
* Traverses up prop node
|
|
194
202
|
* @param node The AST node to start traversing from
|
|
@@ -196,36 +204,6 @@ declare function getPropNameWithNamespace(node: TSESTree.JSXAttribute): string;
|
|
|
196
204
|
* @returns prop node if found
|
|
197
205
|
*/
|
|
198
206
|
declare function traverseUpProp(node: TSESTree.Node, predicate?: (node: TSESTree.JSXAttribute) => boolean): O.Option<TSESTree.JSXAttribute>;
|
|
199
|
-
/**
|
|
200
|
-
* Checks if the node is inside a prop's value
|
|
201
|
-
* @param node The AST node to check
|
|
202
|
-
* @returns `true` if the node is inside a prop's value
|
|
203
|
-
*/
|
|
204
|
-
declare function isInsidePropValue(node: TSESTree.Node): boolean;
|
|
205
|
-
/**
|
|
206
|
-
* @param properties The properties to search in
|
|
207
|
-
* @param context The rule context
|
|
208
|
-
* @param seenProps The properties that have already been seen
|
|
209
|
-
* @returns A function that searches for a property in the given properties
|
|
210
|
-
*/
|
|
211
|
-
declare function findPropInProperties(properties: (TSESTree.Property | TSESTree.RestElement)[] | TSESTree.ObjectLiteralElement[], context: RuleContext, seenProps?: string[]): (propName: string) => O.Option<(typeof properties)[number]>;
|
|
212
|
-
/**
|
|
213
|
-
* @param attributes The attributes to search in
|
|
214
|
-
* @param context The rule context
|
|
215
|
-
* @returns A function that searches for a property in the given attributes
|
|
216
|
-
*/
|
|
217
|
-
declare function findPropInAttributes(attributes: (TSESTree.JSXAttribute | TSESTree.JSXSpreadAttribute)[], context: RuleContext): (propName: string) => O.Option<NonNullable<TSESTree.JSXAttribute | TSESTree.JSXSpreadAttribute | undefined>>;
|
|
218
|
-
/**
|
|
219
|
-
* Gets and resolves the static value of a JSX attribute
|
|
220
|
-
* @param attribute The JSX attribute to get the value of
|
|
221
|
-
* @param context The rule context
|
|
222
|
-
* @returns The static value of the given JSX attribute
|
|
223
|
-
*/
|
|
224
|
-
declare function getPropValue(attribute: TSESTree.JSXAttribute | TSESTree.JSXSpreadAttribute, context: RuleContext): O.None<{
|
|
225
|
-
value: unknown;
|
|
226
|
-
} | null> | O.Some<{
|
|
227
|
-
value: unknown;
|
|
228
|
-
} | null>;
|
|
229
207
|
|
|
230
208
|
/**
|
|
231
209
|
* Check if a node is a Literal or JSXText
|
|
@@ -252,4 +230,20 @@ declare function isLineBreak(node: TSESTree.Node): boolean;
|
|
|
252
230
|
*/
|
|
253
231
|
declare function isPaddingSpaces(node: TSESTree.Node): boolean;
|
|
254
232
|
|
|
255
|
-
|
|
233
|
+
declare const JSXValueCheckHint: {
|
|
234
|
+
readonly None: 0n;
|
|
235
|
+
readonly IgnoreNull: bigint;
|
|
236
|
+
readonly IgnoreCreateElement: bigint;
|
|
237
|
+
readonly StrictLogical: bigint;
|
|
238
|
+
readonly StrictConditional: bigint;
|
|
239
|
+
};
|
|
240
|
+
/**
|
|
241
|
+
* Check if a node is a JSX value
|
|
242
|
+
* @param node The AST node to check
|
|
243
|
+
* @param context The rule context
|
|
244
|
+
* @param hint The `JSXValueCheckHint` to use
|
|
245
|
+
* @returns boolean
|
|
246
|
+
*/
|
|
247
|
+
declare function isJSXValue(node: TSESTree$1.Node | null | undefined, context: RuleContext, hint?: bigint): boolean;
|
|
248
|
+
|
|
249
|
+
export { type CallFromPragmaPredicate, 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, isFragmentHasLessThanTwoChildren, isFragmentSyntax, isFragmentWithOnlyTextAndIsNotChild, isFragmentWithSingleExpression, isFunctionReturningJSXValue, isInitializedFromPragma, isInsideCreateElementProps, isInsidePropValue, isJSXElementOfBuiltinComponent, isJSXElementOfUserDefinedComponent, isJSXValue, isLineBreak, isLiteral, isPaddingSpaces, isPropertyOfPragma, isWhiteSpace, traverseUpProp };
|