Skip to content

Commit

Permalink
docs: upgrade to 11ty 2.0 (#17632)
Browse files Browse the repository at this point in the history
* docs: upgrade to 11ty 2.0

* docs: fix broken links

* chore: clean

* Update Makefile.js

Co-authored-by: Milos Djermanovic <milos.djermanovic@gmail.com>

* chore: change filename

---------

Co-authored-by: Milos Djermanovic <milos.djermanovic@gmail.com>
  • Loading branch information
kecrily and mdjermanovic committed Oct 11, 2023
1 parent ff8e4bf commit 9fafe45
Show file tree
Hide file tree
Showing 7 changed files with 2,093 additions and 2,119 deletions.
16 changes: 6 additions & 10 deletions Makefile.js
Expand Up @@ -214,7 +214,7 @@ function generateRuleIndexPage() {
};

if (rule.meta.deprecated) {
ruleTypesData.deprecated.rules.push({
ruleTypesData.deprecated.push({
name: basename,
replacedBy: rule.meta.replacedBy || []
});
Expand All @@ -226,22 +226,18 @@ function generateRuleIndexPage() {
fixable: !!rule.meta.fixable,
hasSuggestions: !!rule.meta.hasSuggestions
},
ruleType = ruleTypesData.types.find(c => c.name === rule.meta.type);
ruleType = ruleTypesData.types[rule.meta.type];

if (!ruleType.rules) {
ruleType.rules = [];
}

ruleType.rules.push(output);
ruleType.push(output);
}
});

// `.rules` will be `undefined` if all rules in category are deprecated.
ruleTypesData.types = ruleTypesData.types.filter(ruleType => !!ruleType.rules);
ruleTypesData.types = Object.fromEntries(
Object.entries(ruleTypesData.types).filter(([, value]) => value && value.length > 0)
);

JSON.stringify(ruleTypesData, null, 4).to(docsSiteOutputFile);
JSON.stringify(meta, null, 4).to(docsSiteMetaOutputFile);

}

/**
Expand Down
58 changes: 25 additions & 33 deletions conf/rule-type-list.json
@@ -1,36 +1,28 @@
{
"types": [
{ "name": "problem", "displayName": "Possible Problems", "description": "These rules relate to possible logic errors in code:" },
{ "name": "suggestion", "displayName": "Suggestions", "description": "These rules suggest alternate ways of doing things:" },
{ "name": "layout", "displayName": "Layout & Formatting", "description": "These rules care about how the code looks rather than how it executes:" }
],
"deprecated": {
"name": "Deprecated",
"description": "These rules have been deprecated in accordance with the <a href=\"{{ '/use/rule-deprecation' | url }}\">deprecation policy</a>, and replaced by newer rules:",
"rules": []
"types": {
"problem": [],
"suggestion": [],
"layout": []
},
"removed": {
"name": "Removed",
"description": "These rules from older versions of ESLint (before the <a href=\"{{ '/use/rule-deprecation' | url }}\">deprecation policy</a> existed) have been replaced by newer rules:",
"rules": [
{ "removed": "generator-star", "replacedBy": ["generator-star-spacing"] },
{ "removed": "global-strict", "replacedBy": ["strict"] },
{ "removed": "no-arrow-condition", "replacedBy": ["no-confusing-arrow", "no-constant-condition"] },
{ "removed": "no-comma-dangle", "replacedBy": ["comma-dangle"] },
{ "removed": "no-empty-class", "replacedBy": ["no-empty-character-class"] },
{ "removed": "no-empty-label", "replacedBy": ["no-labels"] },
{ "removed": "no-extra-strict", "replacedBy": ["strict"] },
{ "removed": "no-reserved-keys", "replacedBy": ["quote-props"] },
{ "removed": "no-space-before-semi", "replacedBy": ["semi-spacing"] },
{ "removed": "no-wrap-func", "replacedBy": ["no-extra-parens"] },
{ "removed": "space-after-function-name", "replacedBy": ["space-before-function-paren"] },
{ "removed": "space-after-keywords", "replacedBy": ["keyword-spacing"] },
{ "removed": "space-before-function-parentheses", "replacedBy": ["space-before-function-paren"] },
{ "removed": "space-before-keywords", "replacedBy": ["keyword-spacing"] },
{ "removed": "space-in-brackets", "replacedBy": ["object-curly-spacing", "array-bracket-spacing"] },
{ "removed": "space-return-throw-case", "replacedBy": ["keyword-spacing"] },
{ "removed": "space-unary-word-ops", "replacedBy": ["space-unary-ops"] },
{ "removed": "spaced-line-comment", "replacedBy": ["spaced-comment"] }
]
}
"deprecated": [],
"removed": [
{ "removed": "generator-star", "replacedBy": ["generator-star-spacing"] },
{ "removed": "global-strict", "replacedBy": ["strict"] },
{ "removed": "no-arrow-condition", "replacedBy": ["no-confusing-arrow", "no-constant-condition"] },
{ "removed": "no-comma-dangle", "replacedBy": ["comma-dangle"] },
{ "removed": "no-empty-class", "replacedBy": ["no-empty-character-class"] },
{ "removed": "no-empty-label", "replacedBy": ["no-labels"] },
{ "removed": "no-extra-strict", "replacedBy": ["strict"] },
{ "removed": "no-reserved-keys", "replacedBy": ["quote-props"] },
{ "removed": "no-space-before-semi", "replacedBy": ["semi-spacing"] },
{ "removed": "no-wrap-func", "replacedBy": ["no-extra-parens"] },
{ "removed": "space-after-function-name", "replacedBy": ["space-before-function-paren"] },
{ "removed": "space-after-keywords", "replacedBy": ["keyword-spacing"] },
{ "removed": "space-before-function-parentheses", "replacedBy": ["space-before-function-paren"] },
{ "removed": "space-before-keywords", "replacedBy": ["keyword-spacing"] },
{ "removed": "space-in-brackets", "replacedBy": ["object-curly-spacing", "array-bracket-spacing"] },
{ "removed": "space-return-throw-case", "replacedBy": ["keyword-spacing"] },
{ "removed": "space-unary-word-ops", "replacedBy": ["space-unary-ops"] },
{ "removed": "spaced-line-comment", "replacedBy": ["spaced-comment"] }
]
}
22 changes: 1 addition & 21 deletions docs/.eleventy.js
Expand Up @@ -54,6 +54,7 @@ module.exports = function(eleventyConfig) {
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.addDataExtension("yml", contents => yaml.load(contents));

//------------------------------------------------------------------------------
Expand Down Expand Up @@ -487,25 +488,6 @@ module.exports = function(eleventyConfig) {
// Settings
//------------------------------------------------------------------------------

/*
* When we run `eleventy --serve`, Eleventy 1.x uses browser-sync to serve the content.
* By default, browser-sync (more precisely, underlying serve-static) will not serve
* `foo/bar.html` when we request `foo/bar`. Thus, we need to rewrite URLs to append `.html`
* so that pretty links without `.html` can work in a local development environment.
*
* There's no need to rewrite URLs that end with `/`, because that already works well
* (server will return the content of `index.html` in the directory).
* URLs with a file extension, like main.css, main.js, sitemap.xml, etc. should not be rewritten
*/
eleventyConfig.setBrowserSyncConfig({
middleware(req, res, next) {
if (!/(?:\.[a-zA-Z][^/]*|\/)$/u.test(req.url)) {
req.url += ".html";
}
return next();
}
});

/*
* Generate the sitemap only in certain contexts to prevent unwanted discovery of sitemaps that
* contain URLs we'd prefer not to appear in search results (URLs in sitemaps are considered important).
Expand All @@ -525,14 +507,12 @@ module.exports = function(eleventyConfig) {
eleventyConfig.ignores.add("src/static/sitemap.njk"); // ... then don't generate the sitemap.
}


return {
passthroughFileCopy: true,

pathPrefix,

markdownTemplateEngine: "njk",
dataTemplateEngine: "njk",
htmlTemplateEngine: "njk",

dir: {
Expand Down
8 changes: 4 additions & 4 deletions docs/package.json
Expand Up @@ -23,11 +23,11 @@
"start": "npm-run-all build:sass build:postcss --parallel *:*:watch"
},
"devDependencies": {
"@11ty/eleventy": "^1.0.1",
"@11ty/eleventy-img": "^1.0.0",
"@11ty/eleventy-navigation": "^0.3.2",
"@11ty/eleventy": "^2.0.1",
"@11ty/eleventy-img": "^3.1.1",
"@11ty/eleventy-navigation": "^0.3.5",
"@11ty/eleventy-plugin-rss": "^1.1.1",
"@11ty/eleventy-plugin-syntaxhighlight": "^3.1.2",
"@11ty/eleventy-plugin-syntaxhighlight": "^5.0.0",
"@munter/tap-render": "^0.2.0",
"@types/markdown-it": "^12.2.3",
"algoliasearch": "^4.12.1",
Expand Down

0 comments on commit 9fafe45

Please sign in to comment.