Skip to main content

regexp()

API > @betterer/regexp > regexp

Use this test to incrementally remove RegExp matches from your codebase.

Signature

export declare function regexp(pattern: RegExp, issueMessage?: string): BettererFileTest;

Parameters

ParameterTypeDescription
patternRegExpA RegExp pattern to match.
issueMessagestringA message that describes the issue. Defaults to 'RegExp match'.

Returns

BettererFileTest

Exceptions

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

Remarks

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

Example

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

export default {
'no hack comments': () =>
regexp(/(\/\/\s*HACK)/i)
.include('./src/*.ts')
};