Skip to content

Commit

Permalink
chore(deps): update dependency depcheck to ^1.4.7
Browse files Browse the repository at this point in the history
  • Loading branch information
binoy14 committed Jan 31, 2024
1 parent 0ad94fb commit 4ee79ca
Show file tree
Hide file tree
Showing 4 changed files with 233 additions and 184 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@
"babel-jest": "^29.7.0",
"cac": "^6.7.12",
"chalk": "^4.1.2",
"depcheck": "^1.4.3",
"depcheck": "^1.4.7",
"dotenv": "^16.0.3",
"dotenv-flow": "^3.2.0",
"esbuild": "^0.19.8",
Expand Down
3 changes: 2 additions & 1 deletion packages/groq/.depcheckignore.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"ignore": ["@optimize-lodash/rollup-plugin", "@sanity/pkg-utils"]
"ignore": ["@optimize-lodash/rollup-plugin", "@sanity/pkg-utils"],
"ignoreDirs": ["test"]
}
26 changes: 12 additions & 14 deletions scripts/depcheck.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ const cwd = path.resolve(process.cwd(), process.argv[2] || '.')

const manifest = JSON.parse(fs.readFileSync(`${cwd}/package.json`, 'utf-8'))

const options = {
const options: depcheck.Options = {
ignoreMatches: ['@types/jest', '@types/webpack-env', 'ts-node', ...getProjectIgnores(cwd)],
ignoreDirs: ['lib'],
ignoreDirs: ['lib', ...getProjectIgnoresDirs(cwd)],
detectors: [
depcheck.detector.exportDeclaration,
depcheck.detector.extract,
Expand Down Expand Up @@ -90,12 +90,7 @@ const IMPLICIT_DEPS: Record<string, string | string[]> = {
recast: '@babel/parser', // recast/parsers/typescript implicitly requires @babel/parser
}

function implicitDepsParser(
content: string,
filePath: string,
deps: ReadonlyArray<string>,
rootDir: string,
) {
function implicitDepsParser(filePath: string, deps: ReadonlyArray<string>) {
return deps.flatMap((dep) => IMPLICIT_DEPS[dep] || [])
}

Expand All @@ -107,6 +102,14 @@ function getProjectIgnores(baseDir: string) {
}
}

function getProjectIgnoresDirs(baseDir: string) {
try {
return JSON.parse(fs.readFileSync(`${baseDir}/.depcheckignore.json`, 'utf-8'))?.ignoreDirs || []
} catch (e) {
return []
}
}

function typeScriptReferencesDirective(node: Node): ReadonlyArray<string> | string {
let match
if (node.type === 'CommentLine' && (match = node.value.match(/\/<reference types="(.+)" \/>/))) {
Expand All @@ -115,12 +118,7 @@ function typeScriptReferencesDirective(node: Node): ReadonlyArray<string> | stri
return []
}

function sanityJSONParser(
content: string,
filePath: string,
deps: ReadonlyArray<string>,
rootDir: string,
) {
function sanityJSONParser(filePath: string, deps: ReadonlyArray<string>) {
const filename = path.basename(filePath)
if (filename === 'sanity.json') {
const sanityConfig = JSON.parse(fs.readFileSync(filePath, 'utf-8'))
Expand Down
Loading

0 comments on commit 4ee79ca

Please sign in to comment.