Skip to main content

tsquery()

API > @betterer/tsquery > tsquery

Use this test to incrementally remove TSQuery matches from your codebase. See the TSQuery documentation for more details about the query syntax.

Signature

export declare function tsquery(query: string, issueMessage?: string): BettererFileTest;

Parameters

ParameterTypeDescription
querystringA TSQuery query to match.
issueMessagestringA message that describes the issue. Defaults to 'TSQuery match'.

Returns

BettererFileTest

Exceptions

BettererError Will throw if the user doesn't pass query.

Remarks

tsquery is a BettererFileTest, so you can use include(), exclude(), only(), and skip().

Example

import { tsquery } from '@betterer/tsquery';

export default {
'no raw console.log': () =>
tsquery(
'CallExpression > PropertyAccessExpression[expression.name="console"][name.name="log"]'
)
.include('./src/*.ts')
};