Skip to content

Commit

Permalink
Suggest running yarn lint --fix (#23413)
Browse files Browse the repository at this point in the history
Summary:
This PR expands the code analysis script to allow for customizing the GitHub Review left by analysis-bot whenever it finds code-level issues.

Some, but not all, `eslint` errors are fixable by running `yarn lint --fix`. When the `eslint` converter finds warnings or errors, the bot will suggest running the command as part of the review.

The script could be adjusted to only suggest this when `eslint` returns a non-zero `fixableErrorCount` or `fixableWarningCount`, but I think this is a good first step to get people to unblock themselves when they see this type of review from the bot.

I've also excluded `bots/` and `scripts/` from eslint as these have several `eslint` errors that need to be addressed. These directories do not contain core RN code, so they can be excluded for now.

[GENERAL] [Changed] - analysis-bot will suggest fixing eslint warnings on code reviews
Pull Request resolved: #23413

Differential Revision: D14065757

Pulled By: cpojer

fbshipit-source-id: cc588643f7ddb3c4631d89c26b799f7a7244e616
  • Loading branch information
hramos authored and facebook-github-bot committed Feb 13, 2019
1 parent 00392ac commit 937c79e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ Libraries/Renderer/*
pr-inactivity-bookmarklet.js
question-bookmarklet.js
flow/
danger/
bots/node_modules
9 changes: 8 additions & 1 deletion scripts/circleci/code-analysis-bot.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ function push(arr, key, value) {
arr[key].push(value);
}

const converterSummary = {
eslint:
'`eslint` found some issues. Run `yarn lint --fix` to automatically fix problems.',
flow: '`flow` found some issues.',
shellcheck: '`shellcheck` found some issues.',
};

/**
* There is unfortunately no standard format to report an error, so we have
* to write a specific converter for each tool we want to support.
Expand Down Expand Up @@ -250,7 +257,7 @@ function main(messages, owner, repo, number) {
let body = '**Code analysis results:**\n\n';
const uniqueconvertersUsed = [...new Set(convertersUsed)];
uniqueconvertersUsed.forEach(converter => {
body += '* `' + converter + '` found some issues.\n';
body += '* ' + converterSummary[converter] + '\n';
});

sendReview(owner, repo, number, sha, body, comments);
Expand Down

0 comments on commit 937c79e

Please sign in to comment.