How to use depcheck - 10 common examples

To help you get started, we’ve selected a few depcheck examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ckeditor / ckeditor5-dev / packages / ckeditor5-dev-tests / bin / check-dependencies.js View on Github external
const fs = require( 'fs' );
const path = require( 'path' );
const glob = require( 'glob' );
const depCheck = require( 'depcheck' );
const chalk = require( 'chalk' );

const cwd = process.cwd();
const packageJson = require( path.join( cwd, 'package.json' ) );
const nonExistingCSSFiles = [];

const depCheckOptions = {
	// We need to add all values manually because if we modify it, the rest is being lost.
	parsers: {
		'*.css': parsePostCSS,
		'*.js': depCheck.parser.es6,
		'*.jsx': depCheck.parser.jsx,
		'*.ts': depCheck.parser.typescript,
		'*.vue': depCheck.parser.vue
	},
	ignoreDirs: [ 'docs', 'build' ],
	ignoreMatches: [ 'eslint', 'eslint-plugin-ckeditor5-rules', 'husky', 'lint-staged', 'webpack-cli' ]
};

if ( Array.isArray( packageJson.depcheckIgnore ) ) {
	depCheckOptions.ignoreMatches.push( ...packageJson.depcheckIgnore );
}

console.log( 'Checking dependencies...' );

depCheck( cwd, depCheckOptions )
	.then( unused => {
github ckeditor / ckeditor5-dev / packages / ckeditor5-dev-tests / bin / check-dependencies.js View on Github external
const path = require( 'path' );
const glob = require( 'glob' );
const depCheck = require( 'depcheck' );
const chalk = require( 'chalk' );

const cwd = process.cwd();
const packageJson = require( path.join( cwd, 'package.json' ) );
const nonExistingCSSFiles = [];

const depCheckOptions = {
	// We need to add all values manually because if we modify it, the rest is being lost.
	parsers: {
		'*.css': parsePostCSS,
		'*.js': depCheck.parser.es6,
		'*.jsx': depCheck.parser.jsx,
		'*.ts': depCheck.parser.typescript,
		'*.vue': depCheck.parser.vue
	},
	ignoreDirs: [ 'docs', 'build' ],
	ignoreMatches: [ 'eslint', 'eslint-plugin-ckeditor5-rules', 'husky', 'lint-staged', 'webpack-cli' ]
};

if ( Array.isArray( packageJson.depcheckIgnore ) ) {
	depCheckOptions.ignoreMatches.push( ...packageJson.depcheckIgnore );
}

console.log( 'Checking dependencies...' );

depCheck( cwd, depCheckOptions )
	.then( unused => {
		const missingPackages = groupMissingPackages( unused.missing, packageJson.name );
github electron-userland / electron-builder / test / src / helpers / checkDeps.ts View on Github external
const result = await new Promise(resolve => {
    depCheck(projectDir, {
      ignoreDirs: [
        "src", "test", "docs", "typings", "docker", "certs", "templates", "vendor",
      ],
      // ignore d.ts
      parsers: {
        "*.js": (depCheck as any).parser.es6,
      },
    }, resolve)
  })
github scimusmn / stele / scripts / depcheck.js View on Github external
'url-loader',
    'webpack-cli',
    'webpack-dev-server',
    'yarn',
  ],
  // skip calculation of missing dependencies
  skipMissing: true,
  ignoreDirs: [
    'dist',
    'dll',
    'release',
    'src/dist',
  ],
  // the target special parsers
  specials: [
    depcheck.special.babel,
    depcheck.special.eslint,
    depcheck.special.webpack,
  ],
};

depcheck(path.join(__dirname, '..'), options, (unused) => {
  const unusedDependencies = _.get(unused, 'dependencies', null);
  const unusedDevDependencies = _.get(unused, 'devDependencies', null);
  if (!_.isEmpty(unusedDependencies)) {
    console.log(chalk.yellow.bold('Unused dependencies'));
    console.log(chalk.yellow(_.join(unusedDependencies, '\n')));
  }
  if (!_.isEmpty(unusedDevDependencies)) {
    console.log(chalk.yellow.bold('Unused devDependencies'));
    console.log(chalk.yellow(_.join(unusedDevDependencies, '\n')));
  }
github scimusmn / stele / scripts / depcheck.js View on Github external
skipMissing: true,
  ignoreDirs: [
    'dist',
    'dll',
    'release',
    'src/dist',
  ],
  // the target special parsers
  specials: [
    depcheck.special.babel,
    depcheck.special.eslint,
    depcheck.special.webpack,
  ],
};

depcheck(path.join(__dirname, '..'), options, (unused) => {
  const unusedDependencies = _.get(unused, 'dependencies', null);
  const unusedDevDependencies = _.get(unused, 'devDependencies', null);
  if (!_.isEmpty(unusedDependencies)) {
    console.log(chalk.yellow.bold('Unused dependencies'));
    console.log(chalk.yellow(_.join(unusedDependencies, '\n')));
  }
  if (!_.isEmpty(unusedDevDependencies)) {
    console.log(chalk.yellow.bold('Unused devDependencies'));
    console.log(chalk.yellow(_.join(unusedDevDependencies, '\n')));
  }
});
github edj-boston / simple-mesh / gulpfile.js View on Github external
'clean',
        'lint',
        'scripts',
        'cover',
        'test'
    )(done);
});


// Examine package.json for unused deps (except for frontend and gulp)
gulp.task('depcheck', g.depcheck({
    ignoreMatches : [
        'babel-preset-es2015'
    ],
    specials : [
        depcheck.special['gulp-load-plugins']
    ]
}));


// What to do when you run `$ gulp`
gulp.task('default', done => {
    g.sequence(
        [ 'david', 'depcheck' ],
        'build',
        'watch'
    )(done);
});
github thenativeweb / roboter / lib / tasks / universal / unused-dependencies / index.js View on Github external
gulp.task('_unused-dependencies', done => {
    gulpDepcheck({
      ignoreDirs: configuration.exclude,
      ignoreMatches: [ 'roboter-client', 'roboter-server' ],
      parsers: {
        '*.js': depcheck.parser.es6,
        '*.jsx': depcheck.parser.jsx
      },
      detectors: [
        depcheck.detector.requireCallExpression,
        depcheck.detector.importDeclaration
      ],
      specials: [
        depcheck.special.babel,
        depcheck.special.eslint,
        depcheck.special.mocha,
        depcheck.special.webpack
      ]
    })().
      then(done).
      catch(err => {
        if (
          err.message.includes('You have unused dependencies') ||
          err.message.includes('You have missing dependencies')
        ) {
          gutil.log(err.message);

          return done();
        }
github thenativeweb / roboter / lib / tasks / universal / unused-dependencies / index.js View on Github external
gulpDepcheck({
      ignoreDirs: configuration.exclude,
      ignoreMatches: [ 'roboter-client', 'roboter-server' ],
      parsers: {
        '*.js': depcheck.parser.es6,
        '*.jsx': depcheck.parser.jsx
      },
      detectors: [
        depcheck.detector.requireCallExpression,
        depcheck.detector.importDeclaration
      ],
      specials: [
        depcheck.special.babel,
        depcheck.special.eslint,
        depcheck.special.mocha,
        depcheck.special.webpack
      ]
    })().
      then(done).
      catch(err => {
        if (
          err.message.includes('You have unused dependencies') ||
          err.message.includes('You have missing dependencies')
        ) {
          gutil.log(err.message);

          return done();
        }

        done(err);
      });
  });
github urbanjs / urbanjs-tools / packages / urbanjs-tools / legacy / tasks / check-dependencies / index.js View on Github external
.on('data', (file) => {
        options.parsers[file.path] = [
          parser,
          depcheck.special.babel,
          depcheck.special.bin,
          depcheck.special.eslint,
          depcheck.special.webpack
        ];
      })
      .on('end', (err) => {
github urbanjs / urbanjs-tools / packages / urbanjs-tool-check-dependencies / src / tool.ts View on Github external
.on('data', (file: { path: string }) => {
          depcheckOptions.parsers[file.path] = [
            (content: string, filename: string) => {
              return babylon.parse(
                this.transpileService.transpile(content, filename),
                {sourceType: 'module'}
              );
            },
            depcheck.special.babel,
            depcheck.special.bin,
            depcheck.special.eslint,
            depcheck.special.webpack
          ];
        })
        .on('end', (err: Error) => {

depcheck

Check dependencies in your node module

MIT
Latest version published 1 year ago

Package Health Score

81 / 100
Full package analysis