From cb44220e2ad54ee30e49b7d30c7ca354af6fbcb6 Mon Sep 17 00:00:00 2001 From: ricardodalarme Date: Fri, 16 Jun 2023 10:52:57 -0300 Subject: [PATCH] fix(commit-hook): lint staged files thorugh `yarn lint-fix -PinternalKtlintGitFilter` - The lint staged script was using a command that was removed in #66 so replaces it with `yarn lint-fix -PinternalKtlintGitFilter` --- scripts/lint-staged-config.mjs | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/scripts/lint-staged-config.mjs b/scripts/lint-staged-config.mjs index 52039003..fca8d3b1 100644 --- a/scripts/lint-staged-config.mjs +++ b/scripts/lint-staged-config.mjs @@ -1,4 +1,5 @@ import micromatch from 'micromatch'; +import path from 'path'; const kotlinExtension = '*.kt'; const kotlinFilePattern = '**/' + kotlinExtension; @@ -7,20 +8,16 @@ const jsFilePattern = '**/*.(ts|tsx|js|jsx|mjs)'; function handleKotlinFiles(allStagedFiles) { const matches = micromatch(allStagedFiles, [kotlinFilePattern]); const commands = []; - const networkFiles = '**/data/network/' + kotlinExtension; - const networkFilesMatches = micromatch(allStagedFiles, [networkFiles]); if (matches.length > 0) { - // Returns a single action for all kotlin files. This is an optimization - // to garantee that only a single gradle task is executed (which will lint - // all staged files at once). - commands.push('yarn lint-from-staged'); - } - - // Running Auth tests (which are instrumented) is expensive, thus - // only run when the network package changes - if (networkFilesMatches.length > 0) { - commands.push('yarn auth-test'); + const relativeMatches = matches.map((match) => + path.relative(process.cwd(), match), + ); + + const relativeMatchesString = relativeMatches.join('\n'); + commands.push( + `yarn lint-fix -p . -PinternalKtlintGitFilter="\n${relativeMatchesString}\n"`, + ); } return commands;