Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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 => {
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 );
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') ||
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 (
const depcheckOptions = {
ignoreDirs: [ 'node_modules' ],
ignoreMatches: [
'@types/*',
'react',
'roboter',
'semantic-release-configuration',
'ts-node',
'tsconfig-paths',
'typescript'
],
parsers: {
'*.js': depcheck.parser.es6,
'*.jsx': depcheck.parser.jsx,
'*.ts': depcheck.parser.typescript,
'*.tsx': depcheck.parser.typescript
},
detectors: [
depcheck.detector.requireCallExpression,
depcheck.detector.importDeclaration
],
specials: [
depcheck.special.babel,
depcheck.special.bin,
depcheck.special.eslint,
depcheck.special.mocha,
depcheck.special.webpack
]
};
const {
throw new Error('Directory is missing.');
}
const depcheckOptions = {
ignoreDirs: [ 'node_modules' ],
ignoreMatches: [
'@types/*',
'react',
'roboter',
'semantic-release-configuration',
'ts-node',
'tsconfig-paths',
'typescript'
],
parsers: {
'*.js': depcheck.parser.es6,
'*.jsx': depcheck.parser.jsx,
'*.ts': depcheck.parser.typescript,
'*.tsx': depcheck.parser.typescript
},
detectors: [
depcheck.detector.requireCallExpression,
depcheck.detector.importDeclaration
],
specials: [
depcheck.special.babel,
depcheck.special.bin,
depcheck.special.eslint,
depcheck.special.mocha,
depcheck.special.webpack
]
};