Skip to content

Commit

Permalink
fix(commit-hook): lint staged files thorugh `yarn lint-fix -Pinternal…
Browse files Browse the repository at this point in the history
…KtlintGitFilter`

- The lint staged script was using a command that was removed in #66
  so replaces it with `yarn lint-fix -PinternalKtlintGitFilter`
  • Loading branch information
ricardodalarme committed Jun 20, 2023
1 parent d49b7cb commit cb44220
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions scripts/lint-staged-config.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import micromatch from 'micromatch';
import path from 'path';

const kotlinExtension = '*.kt';
const kotlinFilePattern = '**/' + kotlinExtension;
Expand All @@ -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;
Expand Down

0 comments on commit cb44220

Please sign in to comment.