Skip to main content

Built-in Tests

Betterer ships several built-in tests to get you started. Check out the implementations for some more inspiration for your own tests!

@betterer/eslint#

Use this test to incrementally introduce new ESLint rules to your codebase. You can pass as many ESLint rule configurations as you like:

import { eslint } from '@betterer/eslint';
export default {  'no more debuggers': eslint({ 'no-debugger': 'error' }).include('./src/**/*.ts')};

@betterer/eslint is a BettererFileTest, so you can use include, exclude, only, and skip.

@betterer/regexp#

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

import { regexp } from '@betterer/regexp';
export default {  'no hack comments': regexp(/(\/\/\s*HACK)/i).include('**/*.ts')};

@betterer/regexp is a BettererFileTest, so you can use include, exclude, only, and skip.

@betterer/stylelint#

Use this test to incrementally introduce new Stylelint rules to your codebase.

import { stylelint } from '@betterer/stylelint';
export default {  'no unknown units': stylelint({    rules: {      'unit-no-unknown': true    }  }).include('**/*.css)};

@betterer/tsquery#

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

import { tsquery } from '@betterer/tsquery';
export default {  'no raw console.log': tsquery(    './tsconfig.json',    'CallExpression > PropertyAccessExpression[expression.name="console"][name.name="log"]'  )};

@betterer/tsquery is a BettererFileTest, so you can use include, exclude, only, and skip.

@betterer/typescript#

Use this test to incrementally introduce TypeScript configuration to your codebase.

import { typescript } from '@betterer/typescript';
export default {  'stricter compilation': typescript('./tsconfig.json', {    strict: true  })};

@betterer/typescript is a BettererFileTest, so you can use include, exclude, only, and skip.