First install and run

How to install and run your first analysis

Requirements

  • Having Node.js installed (version 18 or higher)

Install Debt-collector in your project

npm i debt-collector -D
yarn add -D debt-collector
pnpm add -D debt-collector
circle-exclamation
npm i debt-collector@1.0.0-alpha.13 -D
yarn add -D debt-collector@1.0.0-alpha.13
pnpm add -D debt-collector@1.0.0-alpha.13

Create a configuration file

Create a configuration file named debt-collector.config.js in your project's root directory

then add the following content :

export default {
  projectName: 'my-project',
  include: ['./src/**/*'],
  fileRules: [
    {
      id: 'REMOVE_FOO',
      title: 'we should get rid of all "Foo" occurences',
      debtScore: 3,
      matchRule: ({ countAll }) => countAll('foo'),
    }, {
      id: 'MIGRATE_CSS_TO_SCSS',
      title: 'use scss instead of css',
      debtScore: 5,
      include: ['**/*.css'],
    }
  ]
}
circle-info

If your project does not use "type": "module" in package.json, you can use module.exports = { ... } instead of export default.

What we've done here :

  • defined a project name for identification

  • defined that debt-collector should track all files contained in the src directory

  • created two file rules :

    • the first one will monitor for every occurences of "foo" in every files and increment your debt score of 3 points for every occurences

    • the second will count all css files, and increment your debt score of 5 points for every matches

Add a script to your package.json

Let's try it :

Open your command line and run :

That's it, you've installed debt-collector and created your first rules. But debt-collector is a lot more than a glorified search engine.

Last updated