@@ -162,35 +162,51 @@ const isIdentifier = <V extends string>(
162162 node . type === AST_NODE_TYPES . Identifier &&
163163 ( name === undefined || node . name === name ) ;
164164
165+ /**
166+ * Checks if the given `node` is a "supported accessor".
167+ *
168+ * This means that it's a node can be used to access properties,
169+ * and who's "value" can be statically determined.
170+ *
171+ * `MemberExpression` nodes most commonly contain accessors,
172+ * but it's possible for other nodes to contain them.
173+ *
174+ * If a `value` is provided & the `node` is an `AccessorNode`,
175+ * the `value` will be compared to that of the `AccessorNode`.
176+ *
177+ * Note that `value` here refers to the normalised value.
178+ * The property that holds the value is not always called `name`.
179+ *
180+ * @param {Node } node
181+ * @param {V? } value
182+ *
183+ * @return {node is AccessorNode<V> }
184+ *
185+ * @template V
186+ */
165187export const isSupportedAccessor = < V extends string > (
166188 node : TSESTree . Node ,
167189 value ?: V ,
168190) : node is AccessorNode < V > =>
169191 isIdentifier ( node , value ) || isStringNode ( node , value ) ;
170192
193+ /**
194+ * Gets the value of the given `AccessorNode`,
195+ * account for the different node types.
196+ *
197+ * @param {AccessorNode<S> } accessor
198+ *
199+ * @return {S }
200+ *
201+ * @template S
202+ */
171203export const getAccessorValue = < S extends string = string > (
172204 accessor : AccessorNode < S > ,
173205) : S =>
174206 accessor . type === AST_NODE_TYPES . Identifier
175207 ? accessor . name
176208 : getStringValue ( accessor ) ;
177209
178- /**
179- * Checks if the given `node` is an `AccessorExpression` with the specific `value`.
180- *
181- * @param {Node } node
182- * @param {V } accessor
183- *
184- * @return {node is SpecificAccessorExpression<V> }
185- *
186- * @template V
187- */
188- export const isAccessorNode = < V extends string > (
189- node : TSESTree . Node ,
190- accessor : V ,
191- ) : node is AccessorNode < V > =>
192- isIdentifier ( node , accessor ) || isStringNode ( node , accessor ) ;
193-
194210export interface ValidExpectCall <
195211 Argument extends TSESTree . Expression = TSESTree . Expression
196212> extends ExpectCall {
@@ -215,7 +231,7 @@ type AccessorNode<Specifics extends string = string> =
215231type ExpectAccessor = AccessorNode < 'expect' > ;
216232
217233export const isExpectAccessor = ( node : TSESTree . Node ) : node is ExpectAccessor =>
218- isAccessorNode ( node , 'expect' ) ;
234+ isSupportedAccessor ( node , 'expect' ) ;
219235
220236export interface ExpectCall extends TSESTree . CallExpression {
221237 callee : AccessorNode < 'expect' > ;
0 commit comments