Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -289,23 +289,21 @@ Percy Ma

<!--teamend-->

## Sponsors

The following companies, organizations, and individuals support ESLint's ongoing maintenance and development. [Become a Sponsor](https://eslint.org/donate) to get your logo on our README and website.

<!-- NOTE: This section is autogenerated. Do not manually edit.-->
<!--sponsorsstart-->
## Sponsors

The following companies, organizations, and individuals support ESLint's ongoing maintenance and development. [Become a Sponsor](https://eslint.org/donate)
to get your logo on our READMEs and [website](https://eslint.org/sponsors).
<h3>Platinum Sponsors</h3>
<p><a href="https://automattic.com"><img src="https://images.opencollective.com/automattic/d0ef3e1/logo.png" alt="Automattic" height="128"></a> <a href="https://www.airbnb.com/"><img src="https://images.opencollective.com/airbnb/d327d66/logo.png" alt="Airbnb" height="128"></a></p><h3>Gold Sponsors</h3>
<p><a href="https://trunk.io/"><img src="https://images.opencollective.com/trunkio/fb92d60/avatar.png" alt="trunk.io" height="96"></a></p><h3>Silver Sponsors</h3>
<p><a href="https://www.jetbrains.com/"><img src="https://images.opencollective.com/jetbrains/fe76f99/logo.png" alt="JetBrains" height="64"></a> <a href="https://liftoff.io/"><img src="https://images.opencollective.com/liftoff/5c4fa84/logo.png" alt="Liftoff" height="64"></a> <a href="https://americanexpress.io"><img src="https://avatars.githubusercontent.com/u/3853301?v=4" alt="American Express" height="64"></a> <a href="https://www.workleap.com"><img src="https://avatars.githubusercontent.com/u/53535748?u=d1e55d7661d724bf2281c1bfd33cb8f99fe2465f&v=4" alt="Workleap" height="64"></a></p><h3>Bronze Sponsors</h3>
<p><a href="https://www.wordhint.net/"><img src="https://images.opencollective.com/wordhint/be86813/avatar.png" alt="WordHint" height="32"></a> <a href="https://www.crosswordsolver.org/anagram-solver/"><img src="https://images.opencollective.com/anagram-solver/2666271/logo.png" alt="Anagram Solver" height="32"></a> <a href="https://icons8.com/"><img src="https://images.opencollective.com/icons8/7fa1641/logo.png" alt="Icons8" height="32"></a> <a href="https://discord.com"><img src="https://images.opencollective.com/discordapp/f9645d9/logo.png" alt="Discord" height="32"></a> <a href="https://www.gitbook.com"><img src="https://avatars.githubusercontent.com/u/7111340?v=4" alt="GitBook" height="32"></a> <a href="https://nx.dev"><img src="https://avatars.githubusercontent.com/u/23692104?v=4" alt="Nx" height="32"></a> <a href="https://herocoders.com"><img src="https://avatars.githubusercontent.com/u/37549774?v=4" alt="HeroCoders" height="32"></a> <a href="https://usenextbase.com"><img src="https://avatars.githubusercontent.com/u/145838380?v=4" alt="Nextbase Starter Kit" height="32"></a></p>
<!--sponsorsend-->

<!--techsponsorsstart-->
<h2>Technology Sponsors</h2>
<h3>Technology Sponsors</h3>
Technology sponsors allow us to use their products and services for free as part of a contribution to the open source ecosystem and our work.
<p><a href="https://netlify.com"><img src="https://raw.githubusercontent.com/eslint/eslint.org/main/src/assets/images/techsponsors/netlify-icon.svg" alt="Netlify" height="32"></a> <a href="https://algolia.com"><img src="https://raw.githubusercontent.com/eslint/eslint.org/main/src/assets/images/techsponsors/algolia-icon.svg" alt="Algolia" height="32"></a> <a href="https://1password.com"><img src="https://raw.githubusercontent.com/eslint/eslint.org/main/src/assets/images/techsponsors/1password-icon.svg" alt="1Password" height="32"></a></p>
<!--techsponsorsend-->
<!--sponsorsend-->

[tidelift]: https://tidelift.com/funding/github/npm/eslint
[herodevs]: https://www.herodevs.com/support/eslint-nes?utm_source=ESLintWebsite&utm_medium=ESLintWebsite&utm_campaign=ESLintNES&utm_id=ESLintNES
102 changes: 9 additions & 93 deletions tools/update-readme.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,39 +23,23 @@ const got = require("got");
//-----------------------------------------------------------------------------

const SPONSORS_URL =
"https://raw.githubusercontent.com/eslint/eslint.org/main/src/_data/sponsors.json";
"https://raw.githubusercontent.com/eslint/eslint.org/main/includes/sponsors.md";
const TEAM_URL =
"https://raw.githubusercontent.com/eslint/eslint.org/main/src/_data/team.json";
const README_FILE_PATH = "./README.md";
const TECH_SPONSORS_URL =
"https://raw.githubusercontent.com/eslint/eslint.org/main/src/_data/techsponsors.json";
const TECH_SPONSORS_IMAGE_PATH =
"https://raw.githubusercontent.com/eslint/eslint.org/main/src";

const readme = fs.readFileSync(README_FILE_PATH, "utf8");

const heights = {
platinum: 128,
gold: 96,
silver: 64,
bronze: 32
};

//-----------------------------------------------------------------------------
// Helpers
//-----------------------------------------------------------------------------

/**
* Fetches the latest sponsors data from the website.
* @returns {Object} The sponsors data object.
* Fetches the latest sponsors from the website.
* @returns {Promise<string>}} Prerendered sponsors markdown.
*/
async function fetchSponsorsData() {
const data = await got(SPONSORS_URL).json();

// remove backers from sponsors list - not shown on readme
delete data.backers;

return data;
async function fetchSponsorsMarkdown() {
return got(SPONSORS_URL).text();
}

/**
Expand Down Expand Up @@ -89,68 +73,6 @@ function formatTeamMembers(members) {
/* eslint-enable indent -- Allow deeper template substitution indent */
}

/**
* Formats an array of sponsors into HTML for the readme.
* @param {Array} sponsors The array of sponsors.
* @returns {string} The HTML for the readme.
*/
function formatSponsors(sponsors) {
const nonEmptySponsors = Object.keys(sponsors).filter(
tier => sponsors[tier].length
);

/* eslint-disable indent -- Allow deeper template substitution indent */
return stripIndents`<!--sponsorsstart-->
${nonEmptySponsors
.map(
tier => `<h3>${tier[0].toUpperCase()}${tier.slice(
1
)} Sponsors</h3>
<p>${sponsors[tier]
.map(
sponsor =>
`<a href="${sponsor.url || "#"}"><img src="${
sponsor.image
}" alt="${sponsor.name}" height="${heights[tier]}"></a>`
)
.join(" ")}</p>`
)
.join("")}
<!--sponsorsend-->`;
/* eslint-enable indent -- Allow deeper template substitution indent */
}

/**
* Fetches the latest tech sponsors data from the website.
* @returns {Array<Object>} The tech sponsors array of data object.
*/
async function fetchTechSponsors() {
const data = await got(TECH_SPONSORS_URL).json();

return data;
}

/**
* Formats an array of sponsors into HTML for the readme.
* @param {Array} sponsors The array of sponsors.
* @returns {string} The HTML for the readme.
*/
function formatTechSponsors(sponsors) {
return stripIndents`<!--techsponsorsstart-->
<h2>Technology Sponsors</h2>
<p>${sponsors
.map(
sponsor =>
`<a href="${sponsor.url || "#"}"><img src="${
TECH_SPONSORS_IMAGE_PATH + sponsor.image
}" alt="${sponsor.name}" height="${
heights.bronze
}"></a>`
)
.join(" ")}</p>
<!--techsponsorsend-->`;
}

//-----------------------------------------------------------------------------
// Main
//-----------------------------------------------------------------------------
Expand Down Expand Up @@ -195,10 +117,9 @@ const HTML_TEMPLATE = stripIndents`
`;

(async () => {
const [allSponsors, team, techSponsors] = await Promise.all([
fetchSponsorsData(),
fetchTeamData(),
fetchTechSponsors()
const [allSponsors, team] = await Promise.all([
fetchSponsorsMarkdown(),
fetchTeamData()
]);

// replace all of the section
Expand All @@ -212,12 +133,7 @@ const HTML_TEMPLATE = stripIndents`

newReadme = newReadme.replace(
/<!--sponsorsstart-->[\w\W]*?<!--sponsorsend-->/u,
formatSponsors(allSponsors)
);

newReadme = newReadme.replace(
/<!--techsponsorsstart-->[\w\W]*?<!--techsponsorsend-->/u,
formatTechSponsors(techSponsors)
`<!--sponsorsstart-->\n${allSponsors}\n<!--sponsorsend-->`
);

// replace multiple consecutive blank lines with just one blank line
Expand Down
Loading