mirror of
https://github.com/facebook/react.git
synced 2026-02-23 20:23:02 +00:00
Compiler: unfork prettier config (#30205)
Updates the prettier config to format all `.ts` and `.tsx` files in the repo using the existing defaults and removing overrides. The first commit in this PR contains the config changes, the second is just the result of running `yarn prettier-all`.
This commit is contained in:
@@ -13,48 +13,48 @@
|
||||
* - $ GITHUB_AUTH_TOKEN="..." git filter-branch -f --msg-filter "node update-commit-message.js" 2364096862b72cf4d801ef2008c54252335a2df9..HEAD
|
||||
*/
|
||||
|
||||
const { Octokit, App } = require("octokit");
|
||||
const fs = require("fs");
|
||||
const {Octokit, App} = require('octokit');
|
||||
const fs = require('fs');
|
||||
|
||||
const OWNER = "facebook";
|
||||
const REPO = "react-forget";
|
||||
const octokit = new Octokit({ auth: process.env.GITHUB_AUTH_TOKEN });
|
||||
const OWNER = 'facebook';
|
||||
const REPO = 'react-forget';
|
||||
const octokit = new Octokit({auth: process.env.GITHUB_AUTH_TOKEN});
|
||||
|
||||
const fetchPullRequest = async (pullNumber) => {
|
||||
const fetchPullRequest = async pullNumber => {
|
||||
const response = await octokit.request(
|
||||
"GET /repos/{owner}/{repo}/pulls/{pull_number}",
|
||||
'GET /repos/{owner}/{repo}/pulls/{pull_number}',
|
||||
{
|
||||
owner: OWNER,
|
||||
repo: REPO,
|
||||
pull_number: pullNumber,
|
||||
headers: {
|
||||
"X-GitHub-Api-Version": "2022-11-28",
|
||||
'X-GitHub-Api-Version': '2022-11-28',
|
||||
},
|
||||
}
|
||||
);
|
||||
return { body: response.data.body, title: response.data.title };
|
||||
return {body: response.data.body, title: response.data.title};
|
||||
};
|
||||
|
||||
function formatCommitMessage(str) {
|
||||
let formattedStr = "";
|
||||
let line = "";
|
||||
let formattedStr = '';
|
||||
let line = '';
|
||||
|
||||
const trim = str.replace(/(\r\n|\n|\r)/gm, " ").trim();
|
||||
const trim = str.replace(/(\r\n|\n|\r)/gm, ' ').trim();
|
||||
if (!trim) {
|
||||
return "";
|
||||
return '';
|
||||
}
|
||||
|
||||
// Split the string into words
|
||||
const words = trim.split(" ");
|
||||
const words = trim.split(' ');
|
||||
// Iterate over each word
|
||||
for (let i = 0; i < words.length; i++) {
|
||||
// If adding the next word doesn't exceed the line length limit, add it to the line
|
||||
if ((line + words[i]).length <= 80) {
|
||||
line += words[i] + " ";
|
||||
line += words[i] + ' ';
|
||||
} else {
|
||||
// Otherwise, add the line to the formatted string and start a new line
|
||||
formattedStr += line + "\n";
|
||||
line = words[i] + " ";
|
||||
formattedStr += line + '\n';
|
||||
line = words[i] + ' ';
|
||||
}
|
||||
}
|
||||
// Add the last line to the formatted string
|
||||
@@ -63,9 +63,9 @@ function formatCommitMessage(str) {
|
||||
}
|
||||
|
||||
function filterMsg(response) {
|
||||
const { body, title } = response;
|
||||
const {body, title} = response;
|
||||
|
||||
const msgs = body.split("\n\n").flatMap((x) => x.split("\r\n"));
|
||||
const msgs = body.split('\n\n').flatMap(x => x.split('\r\n'));
|
||||
|
||||
const newMessage = [];
|
||||
|
||||
@@ -74,17 +74,17 @@ function filterMsg(response) {
|
||||
|
||||
for (const msg of msgs) {
|
||||
// remove "Stack from [ghstack] blurb"
|
||||
if (msg.startsWith("Stack from ")) {
|
||||
if (msg.startsWith('Stack from ')) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// remove "* #1234"
|
||||
if (msg.startsWith("* #")) {
|
||||
if (msg.startsWith('* #')) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// remove "* __->__ #1234"
|
||||
if (msg.startsWith("* __")) {
|
||||
if (msg.startsWith('* __')) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -95,7 +95,7 @@ function filterMsg(response) {
|
||||
newMessage.push(formattedStr);
|
||||
}
|
||||
|
||||
const updatedMsg = newMessage.join("\n\n");
|
||||
const updatedMsg = newMessage.join('\n\n');
|
||||
return updatedMsg;
|
||||
}
|
||||
|
||||
@@ -109,9 +109,7 @@ function parsePullRequestNumber(text) {
|
||||
if (ghstackMatch) {
|
||||
return ghstackMatch[1];
|
||||
}
|
||||
const firstLine = text
|
||||
.split("\n")
|
||||
.filter((text) => text.trim().length > 0)[0];
|
||||
const firstLine = text.split('\n').filter(text => text.trim().length > 0)[0];
|
||||
if (firstLine == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -124,7 +122,7 @@ function parsePullRequestNumber(text) {
|
||||
}
|
||||
|
||||
async function main() {
|
||||
const data = fs.readFileSync(0, "utf-8");
|
||||
const data = fs.readFileSync(0, 'utf-8');
|
||||
const pr = parsePullRequestNumber(data);
|
||||
|
||||
if (pr) {
|
||||
|
||||
Reference in New Issue
Block a user