Skip to content

Commit

Permalink
Merge branch 'main' into flat-eslint-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nzakas committed Dec 15, 2022
2 parents 29c4a79 + ba74253 commit 5e77440
Show file tree
Hide file tree
Showing 89 changed files with 4,498 additions and 2,656 deletions.
2 changes: 2 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
@@ -0,0 +1,2 @@
/docs/ @eslint/website-team @eslint/eslint-team
* @eslint/eslint-team
3 changes: 3 additions & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Expand Up @@ -6,3 +6,6 @@ contact_links:
- name: 📝 Help with VS Code ESLint
url: https://github.com/microsoft/vscode-eslint/issues/
about: Bugs and feature requests for the VS Code ESLint plugin
- name: Discord Server
url: https://eslint.org/chat
about: Talk with the team
1 change: 1 addition & 0 deletions .npmrc
@@ -1 +1,2 @@
package-lock = false
install-links = false
17 changes: 17 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,20 @@
v8.29.0 - December 2, 2022

* [`0311d81`](https://github.com/eslint/eslint/commit/0311d81834d675b8ae7cc92a460b37115edc4018) docs: Configuring Plugins page intro, page tweaks, and rename (#16534) (Ben Perlmutter)
* [`57089b1`](https://github.com/eslint/eslint/commit/57089b1ede624452bc94404b6e60d01d48cfd468) docs: add a property assignment example for camelcase rule (#16605) (Milos Djermanovic)
* [`b6ab030`](https://github.com/eslint/eslint/commit/b6ab030897d2e8b314b33a6502346a4ac45bb8da) docs: add docs codeowners (#16601) (Strek)
* [`7628403`](https://github.com/eslint/eslint/commit/7628403a57d9d9b4e2cb2b36309170900f58832e) chore: add discord channel link (#16590) (Amaresh S M)
* [`49a07c5`](https://github.com/eslint/eslint/commit/49a07c52c5af7e98d161ff4acd44bbbe0aa6383b) feat: add `allowParensAfterCommentPattern` option to no-extra-parens (#16561) (Nitin Kumar)
* [`6380c87`](https://github.com/eslint/eslint/commit/6380c87c563be5dc78ce0ddd5c7409aaf71692bb) docs: fix sitemap and feed (#16592) (Milos Djermanovic)
* [`e6a865d`](https://github.com/eslint/eslint/commit/e6a865d70aed9e1c07be712e40c38da1a5dda849) feat: `prefer-named-capture-group` add suggestions (#16544) (Josh Goldberg)
* [`ade621d`](https://github.com/eslint/eslint/commit/ade621dd12fcd3b65644bb3468248cc040db756c) docs: perf debounce the search query (#16586) (Shanmughapriyan S)
* [`a91332b`](https://github.com/eslint/eslint/commit/a91332b8bd9adfa2aa8110071bdf73f56d400050) feat: In no-invalid-regexp validate flags also for non-literal patterns (#16583) (trosos)
* [`fbcf3ab`](https://github.com/eslint/eslint/commit/fbcf3abd54dd20aec3c695cacece56493633c97f) docs: fix searchbar clear button (#16585) (Shanmughapriyan S)
* [`f894035`](https://github.com/eslint/eslint/commit/f89403553b31d24f4fc841424cc7dcb8c3ef689f) docs: HTTPS link to yeoman.io (#16582) (Christian Oliff)
* [`de12b26`](https://github.com/eslint/eslint/commit/de12b266f2aa6f063d0af888b8f0de41d09ec33f) docs: Update configuration file pages (#16509) (Ben Perlmutter)
* [`f5808cb`](https://github.com/eslint/eslint/commit/f5808cb51529174a67b4938223f06435ad6d5118) chore: fix rule doc headers check (#16564) (Milos Djermanovic)
* [`1ae9f20`](https://github.com/eslint/eslint/commit/1ae9f2067442434c6ccc6b41703624b302d17c67) docs: update correct code examples for `no-extra-parens` rule (#16560) (Nitin Kumar)

v8.28.0 - November 18, 2022

* [`34c05a7`](https://github.com/eslint/eslint/commit/34c05a779ada3142995392ae12978461900088df) docs: Language Options page intro and tweaks (#16511) (Ben Perlmutter)
Expand Down
7 changes: 4 additions & 3 deletions Makefile.js
Expand Up @@ -447,8 +447,9 @@ function lintMarkdown(files) {
*/
function getFormatterResults() {
const stripAnsi = require("strip-ansi");
const formattersMetadata = require("./lib/cli-engine/formatters/formatters-meta.json");

const formatterFiles = fs.readdirSync("./lib/cli-engine/formatters/"),
const formatterFiles = fs.readdirSync("./lib/cli-engine/formatters/").filter(fileName => !fileName.includes("formatters-meta.json")),
rules = {
"no-else-return": "warn",
indent: ["warn", 4],
Expand Down Expand Up @@ -489,7 +490,8 @@ function getFormatterResults() {
);

data.formatterResults[name] = {
result: stripAnsi(formattedOutput)
result: stripAnsi(formattedOutput),
description: formattersMetadata.find(formatter => formatter.name === name).description
};
}
return data;
Expand Down Expand Up @@ -630,7 +632,6 @@ target.karma = () => {
};

target.test = function() {
target.lint();
target.checkRuleFiles();
target.mocha();
target.karma();
Expand Down
55 changes: 29 additions & 26 deletions docs/.eleventy.js
Expand Up @@ -10,7 +10,7 @@ const Image = require("@11ty/eleventy-img");
const path = require("path");
const { slug } = require("github-slugger");
const yaml = require("js-yaml");

const { highlighter, preWrapperPlugin, lineNumberPlugin } = require("./src/_plugins/md-syntax-highlighter");
const {
DateTime
} = require("luxon");
Expand Down Expand Up @@ -145,7 +145,8 @@ module.exports = function(eleventyConfig) {

eleventyConfig.addPlugin(eleventyNavigationPlugin);
eleventyConfig.addPlugin(syntaxHighlight, {
alwaysWrapLineHighlights: true
alwaysWrapLineHighlights: true,
templateFormats: ["liquid", "njk"]
});
eleventyConfig.addPlugin(pluginRss);
eleventyConfig.addPlugin(pluginTOC, {
Expand Down Expand Up @@ -186,30 +187,32 @@ module.exports = function(eleventyConfig) {
}

const markdownIt = require("markdown-it");
const md = markdownIt({ html: true, linkify: true, typographer: true, highlight: (str, lang) => highlighter(md, str, lang) })
.use(markdownItAnchor, {
slugify
})
.use(markdownItContainer, "correct", {})
.use(markdownItContainer, "incorrect", {})
.use(markdownItContainer, "warning", {
render(tokens, idx) {
return generateAlertMarkup("warning", tokens, idx);
}
})
.use(markdownItContainer, "tip", {
render(tokens, idx) {
return generateAlertMarkup("tip", tokens, idx);
}
})
.use(markdownItContainer, "important", {
render(tokens, idx) {
return generateAlertMarkup("important", tokens, idx);
}
})
.use(preWrapperPlugin)
.use(lineNumberPlugin)
.disable("code");

eleventyConfig.setLibrary("md",
markdownIt({ html: true, linkify: true, typographer: true })
.use(markdownItAnchor, {
slugify
})
.use(markdownItContainer, "correct", {})
.use(markdownItContainer, "incorrect", {})
.use(markdownItContainer, "warning", {
render(tokens, idx) {
return generateAlertMarkup("warning", tokens, idx);
}
})
.use(markdownItContainer, "tip", {
render(tokens, idx) {
return generateAlertMarkup("tip", tokens, idx);
}
})
.use(markdownItContainer, "important", {
render(tokens, idx) {
return generateAlertMarkup("important", tokens, idx);
}
})
.disable("code"));
eleventyConfig.setLibrary("md", md);

//------------------------------------------------------------------------------
// Shortcodes
Expand Down Expand Up @@ -452,7 +455,7 @@ module.exports = function(eleventyConfig) {
* URLs with a file extension, like main.css, main.js, sitemap.xml, etc. should not be rewritten
*/
eleventyConfig.setBrowserSyncConfig({
middleware: (req, res, next) => {
middleware(req, res, next) {
if (!/(?:\.[a-zA-Z][^/]*|\/)$/u.test(req.url)) {
req.url += ".html";
}
Expand Down
3 changes: 2 additions & 1 deletion docs/package.json
@@ -1,7 +1,7 @@
{
"name": "docs-eslint",
"private": true,
"version": "8.28.0",
"version": "8.29.0",
"description": "",
"main": "index.js",
"keywords": [],
Expand Down Expand Up @@ -42,6 +42,7 @@
"netlify-cli": "^10.3.1",
"npm-run-all": "^4.1.5",
"postcss-html": "^1.5.0",
"prismjs": "^1.29.0",
"rimraf": "^3.0.2",
"sass": "^1.52.1",
"stylelint": "^14.13.0",
Expand Down
2 changes: 1 addition & 1 deletion docs/src/_data/links.json
Expand Up @@ -14,7 +14,7 @@
"team": "/team",

"configuring": "https://eslint.org/docs/user-guide/configuring/",
"fixProblems": "https://eslint.org/docs/user-guide/command-line-interface#fixing-problems",
"fixProblems": "https://eslint.org/docs/user-guide/command-line-interface#fix-problems",

"donate": "/donate",
"openCollective": "https://opencollective.com/eslint",
Expand Down
2 changes: 1 addition & 1 deletion docs/src/_data/rules.json
Expand Up @@ -1298,7 +1298,7 @@
"description": "Enforce using named capture group in regular expression",
"recommended": false,
"fixable": false,
"hasSuggestions": false
"hasSuggestions": true
},
{
"name": "prefer-numeric-literals",
Expand Down
3 changes: 2 additions & 1 deletion docs/src/_data/rules_meta.json
Expand Up @@ -2116,7 +2116,8 @@
"description": "Enforce using named capture group in regular expression",
"recommended": false,
"url": "https://eslint.org/docs/rules/prefer-named-capture-group"
}
},
"hasSuggestions": true
},
"prefer-numeric-literals": {
"type": "suggestion",
Expand Down
107 changes: 107 additions & 0 deletions docs/src/_plugins/md-syntax-highlighter.js
@@ -0,0 +1,107 @@
/**
* MIT License
Copyright (c) 2019-present, Yuxi (Evan) You
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/

/** @typedef {import("markdown-it")} MarkdownIt */

const Prism = require("prismjs");
const loadLanguages = require("prismjs/components/");

/**
*
* @param {MarkdownIt} md markdown-it
* @param {string} str code
* @param {string} lang code language
* @returns
*/
const highlighter = function (md, str, lang) {
let result = "";
if (lang) {
try {
loadLanguages([lang]);
result = Prism.highlight(str, Prism.languages[lang], lang);
} catch (err) {
console.log(err);
}
} else {
result = md.utils.escapeHtml(str);
}

return `<pre><code>${result}</code></pre>`;
};

/**
*
* modified from https://github.com/vuejs/vitepress/blob/main/src/node/markdown/plugins/preWrapper.ts
* @param {MarkdownIt} md
* @license MIT License. See file header.
*/
const preWrapperPlugin = (md) => {
const fence = md.renderer.rules.fence;
md.renderer.rules.fence = (...args) => {
const [tokens, idx] = args;
const lang = tokens[idx].info.trim();
const rawCode = fence(...args);
return `<div class="language-${lang}">${rawCode}</div>`;
};
};

/**
*
* modified from https://github.com/vuejs/vitepress/blob/main/src/node/markdown/plugins/lineNumbers.ts
* @param {MarkdownIt} md
* @license MIT License. See file header.
*/
const lineNumberPlugin = (md) => {
const fence = md.renderer.rules.fence;
md.renderer.rules.fence = (...args) => {
const [tokens, idx] = args;
const lang = tokens[idx].info.trim();
const rawCode = fence(...args);
const code = rawCode.slice(
rawCode.indexOf("<code>"),
rawCode.indexOf("</code>")
);
const lines = code.split("\n");
const lineNumbersCode = [...Array(lines.length - 1)]
.map(
(line, index) =>
`<span class="line-number">${index + 1}</span><br>`
)
.join("");

const lineNumbersWrapperCode = `<div class="line-numbers-wrapper" aria-hidden="true">${lineNumbersCode}</div>`;

const finalCode = rawCode
.replace(/<\/div>$/, `${lineNumbersWrapperCode}</div>`)
.replace(/"(language-\S*?)"/, '"$1 line-numbers-mode"')
.replace(/<code>/, `<code class="language-${lang}">`)
.replace(/<pre>/, `<pre class="language-${lang}">`);

return finalCode;
};
};

module.exports.highlighter = highlighter;
module.exports.preWrapperPlugin = preWrapperPlugin;
module.exports.lineNumberPlugin = lineNumberPlugin;
28 changes: 22 additions & 6 deletions docs/src/assets/js/search.js
Expand Up @@ -49,7 +49,6 @@ function clearSearchResults() {
resultsElement.removeChild(resultsElement.firstChild);
}
resultsElement.innerHTML = "";
searchClearBtn.setAttribute('hidden', '');
}

/**
Expand Down Expand Up @@ -80,13 +79,11 @@ function displaySearchResults(results) {
`.trim();
list.append(listItem);
}
searchClearBtn.removeAttribute('hidden');

} else {
resultsLiveRegion.innerHTML = "No results found.";
resultsElement.innerHTML = "No results found.";
resultsElement.setAttribute('data-results', 'false');
searchClearBtn.setAttribute('hidden', '');
}

}
Expand Down Expand Up @@ -114,6 +111,25 @@ function maintainScrollVisibility(activeElement, scrollParent) {

}

/**
* Debounces the provided callback with a given delay.
* @param {Function} callback The callback that needs to be debounced.
* @param {Number} delay Time in ms that the timer should wait before the callback is executed.
* @returns {Function} Returns the new debounced function.
*/
function debounce(callback, delay) {
let timer;
return (...args) => {
if (timer) clearTimeout(timer);
timer = setTimeout(() => callback.apply(this, args), delay);
}
}

const debouncedFetchSearchResults = debounce((query) => {
fetchSearchResults(query)
.then(displaySearchResults)
.catch(clearSearchResults);
}, 300);

//-----------------------------------------------------------------------------
// Event Handlers
Expand All @@ -130,9 +146,8 @@ if(searchInput)
else searchClearBtn.setAttribute('hidden', '');

if (query.length > 2) {
fetchSearchResults(query)
.then(displaySearchResults)
.catch(clearSearchResults);

debouncedFetchSearchResults(query);

document.addEventListener('click', function(e) {
if(e.target !== resultsElement) clearSearchResults();
Expand All @@ -151,6 +166,7 @@ if(searchClearBtn)
searchInput.value = '';
searchInput.focus();
clearSearchResults();
searchClearBtn.setAttribute('hidden', '');
});

document.addEventListener('keydown', function (e) {
Expand Down
2 changes: 1 addition & 1 deletion docs/src/assets/scss/components/rules.scss
Expand Up @@ -65,7 +65,7 @@
}
}

.rule {
.rule:not(.token) {
border-radius: var(--border-radius);
background-color: var(--lightest-background-color);
display: flex;
Expand Down

0 comments on commit 5e77440

Please sign in to comment.