diff --git a/bin/packages/lint-staged-typecheck.js b/bin/packages/lint-staged-typecheck.js index 30c513ec983c5..7b7eb7b846bfb 100644 --- a/bin/packages/lint-staged-typecheck.js +++ b/bin/packages/lint-staged-typecheck.js @@ -1,7 +1,6 @@ /** * External dependencies */ -const _ = require( 'lodash' ); const path = require( 'path' ); const fs = require( 'fs' ); const execa = require( 'execa' ); @@ -18,12 +17,14 @@ const tscPath = path.join( repoRoot, 'node_modules', '.bin', 'tsc' ); const changedFiles = process.argv.slice( 2 ); // Transform changed files to package directories containing tsconfig.json. -const changedPackages = _.uniq( - changedFiles.map( ( fullPath ) => { - const relativePath = path.relative( repoRoot, fullPath ); - return path.join( ...relativePath.split( path.sep ).slice( 0, 2 ) ); - } ) -).filter( ( packageRoot ) => +const changedPackages = [ + ...new Set( + changedFiles.map( ( fullPath ) => { + const relativePath = path.relative( repoRoot, fullPath ); + return path.join( ...relativePath.split( path.sep ).slice( 0, 2 ) ); + } ) + ), +].filter( ( packageRoot ) => fs.existsSync( path.join( packageRoot, 'tsconfig.json' ) ) );