Skip to content

Commit

Permalink
[tools] Ignore versioned and vendored Swift code when linting (expo#1…
Browse files Browse the repository at this point in the history
  • Loading branch information
tsapeta authored and Ddv0623 committed Sep 26, 2022
1 parent 729ee4b commit c26c0b1
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion tools/src/code-review/reviewers/lintSwiftFiles.ts
@@ -1,15 +1,22 @@
import minimatch from 'minimatch';
import path from 'path';

import Git from '../../Git';
import { lintStringAsync, LintViolation } from '../../linting/SwiftLint';
import { ReviewComment, ReviewInput, ReviewOutput, ReviewStatus } from '../types';

const IGNORED_PATHS = ['ios/{vendored,versioned}/**', '**/{Tests,UITests}/**'];

/**
* The entry point for the reviewer checking whether the PR violates SwiftLint rules.
*/
export default async function ({ pullRequest, diff }: ReviewInput): Promise<ReviewOutput | null> {
const swiftFiles = diff.filter((fileDiff) => {
return !fileDiff.deleted && path.extname(fileDiff.path) === '.swift';
return (
!fileDiff.deleted &&
path.extname(fileDiff.path) === '.swift' &&
!IGNORED_PATHS.some((pattern) => minimatch(fileDiff.to!, pattern))
);
});

const comments: ReviewComment[] = [];
Expand Down

0 comments on commit c26c0b1

Please sign in to comment.