Repository: eslint/eslint
File: docs/.eleventy.js (JavaScript)

Code before:
     * The path prefix is turned off for deploy previews so we can properly
     * see changes before deployed.
     */

    let pathPrefix = "/docs/head/";

    if (process.env.CONTEXT === "deploy-preview") {
        pathPrefix = "/";
    } else if (process.env.BRANCH === "latest") {
        pathPrefix = "/docs/latest/";
    } else if (process.env.BRANCH === "next") {
        pathPrefix = "/docs/next/";
    } else if (process.env.BRANCH && /^v\d+\.x$/u.test(process.env.BRANCH)) {
        pathPrefix = `/docs/${process.env.BRANCH}/`; // `/docs/v8.x/`, `/docs/v9.x/`, `/docs/v10.x/` ...
    }

    //------------------------------------------------------------------------------
    // Data
    //------------------------------------------------------------------------------

    // Load site-specific data
    const siteName = process.env.ESLINT_SITE_NAME || "en";

    /**
     * Determines whether the given version is a prerelease.
     * @returns {boolean} `true` if it is a prerelease, `false` otherwise.
     */
    async function isPreRelease() {
        const eslintVersions = await require("./src/_data/eslintVersions")();

        return eslintVersions.items.some(item => item.branch === "next");
    }

    eleventyConfig.addGlobalData("site_name", siteName);
    eleventyConfig.addGlobalData("GIT_BRANCH", process.env.BRANCH);
    eleventyConfig.addGlobalData("HEAD", process.env.BRANCH === "main");
    eleventyConfig.addGlobalData("NOINDEX", process.env.BRANCH !== "latest");
    eleventyConfig.addGlobalData("PATH_PREFIX", pathPrefix);
    eleventyConfig.addGlobalData("is_pre_release", isPreRelease);
    eleventyConfig.addGlobalData("is_number_version", process.env.BRANCH && /^v\d+\.x$/u.test(process.env.BRANCH));
    eleventyConfig.addDataExtension("yml", contents => yaml.load(contents));

    //------------------------------------------------------------------------------
    // Filters
    //------------------------------------------------------------------------------

    eleventyConfig.addFilter("limitTo", (arr, limit) => arr.slice(0, limit));

    eleventyConfig.addFilter("jsonify", variable => JSON.stringify(variable));

    eleventyConfig.addFilter("slugify", str => {

Review comment (suggestion):
```suggestion
     * Determines whether we are in the prerelease phase
     * @returns {Promise<boolean>} `true` if there is a prerelease of the next major version, `false` otherwise.
```

Code after:
     * The path prefix is turned off for deploy previews so we can properly
     * see changes before deployed.
     */

    let pathPrefix = "/docs/head/";
    const isNumberVersion = process.env.BRANCH && /^v\d+\.x$/u.test(process.env.BRANCH);

    if (process.env.CONTEXT === "deploy-preview") {
        pathPrefix = "/";
    } else if (process.env.BRANCH === "latest") {
        pathPrefix = "/docs/latest/";
    } else if (process.env.BRANCH === "next") {
        pathPrefix = "/docs/next/";
    } else if (isNumberVersion) {
        pathPrefix = `/docs/${process.env.BRANCH}/`; // `/docs/v8.x/`, `/docs/v9.x/`, `/docs/v10.x/` ...
    }

    //------------------------------------------------------------------------------
    // Data
    //------------------------------------------------------------------------------

    // Load site-specific data
    const siteName = process.env.ESLINT_SITE_NAME || "en";

    eleventyConfig.addGlobalData("site_name", siteName);
    eleventyConfig.addGlobalData("GIT_BRANCH", process.env.BRANCH);
    eleventyConfig.addGlobalData("HEAD", process.env.BRANCH === "main");
    eleventyConfig.addGlobalData("NOINDEX", process.env.BRANCH !== "latest");
    eleventyConfig.addGlobalData("PATH_PREFIX", pathPrefix);
    eleventyConfig.addGlobalData("is_number_version", isNumberVersion);
    eleventyConfig.addDataExtension("yml", contents => yaml.load(contents));

    //------------------------------------------------------------------------------
    // Filters
    //------------------------------------------------------------------------------

    eleventyConfig.addFilter("limitTo", (arr, limit) => arr.slice(0, limit));

    eleventyConfig.addFilter("jsonify", variable => JSON.stringify(variable));

    eleventyConfig.addFilter("slugify", str => {
        if (!str) {
            return "";
        }

        return slug(str);
    });

    eleventyConfig.addFilter("URIencode", str => {
        if (!str) {
            return "";