Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[tools] Ignore versioned and vendored Swift code when linting #19063

Merged
merged 1 commit into from
Sep 12, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 8 additions & 1 deletion tools/src/code-review/reviewers/lintSwiftFiles.ts
Original file line number Diff line number Diff line change
@@ -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