diff --git a/Makefile.js b/Makefile.js index 970b1bc10ed..146aa03fc29 100644 --- a/Makefile.js +++ b/Makefile.js @@ -12,7 +12,6 @@ const checker = require("npm-license"), ReleaseOps = require("eslint-release"), - dateformat = require("dateformat"), fs = require("fs"), glob = require("glob"), marked = require("marked"), @@ -33,7 +32,7 @@ require("shelljs/make"); * @see https://github.com/shelljs/shelljs/blob/124d3349af42cb794ae8f78fc9b0b538109f7ca7/make.js#L4 * @see https://github.com/DefinitelyTyped/DefinitelyTyped/blob/3aa2d09b6408380598cfb802743b07e1edb725f3/types/shelljs/make.d.ts#L8-L11 */ -const { cat, cd, cp, echo, exec, exit, find, ls, mkdir, pwd, rm, test } = require("shelljs"); +const { cat, cd, echo, exec, exit, find, ls, mkdir, pwd, test } = require("shelljs"); //------------------------------------------------------------------------------ // Settings @@ -60,8 +59,10 @@ const NODE = "node ", // intentional extra space TEMP_DIR = "./tmp/", DEBUG_DIR = "./debug/", BUILD_DIR = "build", - DOCS_DIR = "../website/docs", - SITE_DIR = "../website/", + SITE_DIR = "../eslint.org", + DOCS_DIR = "./docs", + DOCS_SRC_DIR = path.join(DOCS_DIR, "src"), + DOCS_DATA_DIR = path.join(DOCS_SRC_DIR, "_data"), PERF_TMP_DIR = path.join(TEMP_DIR, "eslint", "performance"), // Utilities - intentional extra space at the end of each string @@ -144,10 +145,10 @@ function generateBlogPost(releaseInfo, prereleaseMajorVersion) { now = new Date(), month = now.getMonth() + 1, day = now.getDate(), - filename = `../website/_posts/${now.getFullYear()}-${ + filename = path.join(SITE_DIR, `src/content/blog/${now.getFullYear()}-${ month < 10 ? `0${month}` : month}-${ day < 10 ? `0${day}` : day}-eslint-v${ - releaseInfo.version}-released.md`; + releaseInfo.version}-released.md`); output.to(filename); } @@ -155,21 +156,16 @@ function generateBlogPost(releaseInfo, prereleaseMajorVersion) { /** * Generates a doc page with formatter result examples * @param {Object} formatterInfo Linting results from each formatter - * @param {string} [prereleaseVersion] The version used for a prerelease. This - * changes where the output is stored. * @returns {void} */ -function generateFormatterExamples(formatterInfo, prereleaseVersion) { +function generateFormatterExamples(formatterInfo) { const output = ejs.render(cat("./templates/formatter-examples.md.ejs"), formatterInfo); - let filename = "../website/docs/user-guide/formatters/index.md", - htmlFilename = "../website/docs/user-guide/formatters/html-formatter-example.html"; - - if (prereleaseVersion) { - filename = filename.replace("/docs", `/docs/${prereleaseVersion}`); - htmlFilename = htmlFilename.replace("/docs", `/docs/${prereleaseVersion}`); - if (!test("-d", path.dirname(filename))) { - mkdir(path.dirname(filename)); - } + const outputDir = path.join(DOCS_SRC_DIR, "user-guide/formatters/"), + filename = path.join(outputDir, "index.md"), + htmlFilename = path.join(outputDir, "html-formatter-example.html"); + + if (!test("-d", outputDir)) { + mkdir(outputDir); } output.to(filename); @@ -181,9 +177,8 @@ function generateFormatterExamples(formatterInfo, prereleaseVersion) { * @returns {void} */ function generateRuleIndexPage() { - const legacyWebsiteOutputFile = "../website/_data/rules.yml", - docsSiteOutputFile = "docs/src/_data/rules.json", - docsSiteMetaOutputFile = "docs/src/_data/rules_meta.json", + const docsSiteOutputFile = path.join(DOCS_DATA_DIR, "rules.json"), + docsSiteMetaOutputFile = path.join(DOCS_DATA_DIR, "rules_meta.json"), ruleTypes = "conf/rule-type-list.json", ruleTypesData = JSON.parse(cat(path.resolve(ruleTypes))); @@ -240,9 +235,6 @@ function generateRuleIndexPage() { JSON.stringify(ruleTypesData, null, 4).to(docsSiteOutputFile); JSON.stringify(meta, null, 4).to(docsSiteMetaOutputFile); - const legacyOutput = yaml.dump(ruleTypesData, { sortKeys: true }); - - legacyOutput.to(legacyWebsiteOutputFile); } /** @@ -256,18 +248,14 @@ function commitSiteToGit(tag) { cd(SITE_DIR); exec("git add -A ."); - exec(`git commit -m "Autogenerated new docs and demo at ${dateformat(new Date())}"`); - - if (tag) { - exec(`git tag ${tag}`); - } - - exec("git fetch origin && git rebase origin/master"); + exec(`git commit -m "Added release blog post for ${tag}"`); + exec(`git tag ${tag}`); + exec("git fetch origin && git rebase origin/main"); cd(currentDir); } /** - * Publishes the changes in an adjacent `website` repository to the remote. The + * Publishes the changes in an adjacent `eslint.org` repository to the remote. The * site should already have local commits (e.g. from running `commitSiteToGit`). * @returns {void} */ @@ -275,7 +263,7 @@ function publishSite() { const currentDir = pwd(); cd(SITE_DIR); - exec("git push origin master --tags"); + exec("git push origin HEAD --tags"); cd(currentDir); } @@ -294,7 +282,7 @@ function generateRelease() { commitSiteToGit(`v${releaseInfo.version}`); echo("Updating commit with docs data"); - exec("git add docs/src/_data && git commit --amend --no-edit"); + exec("git add docs/ && git commit --amend --no-edit"); exec(`git tag -a -f v${releaseInfo.version} -m ${releaseInfo.version}`); } @@ -636,60 +624,14 @@ target.test = function() { target.checkLicenses(); }; -target.gensite = function(prereleaseVersion) { - echo("Generating eslint.org"); - - let docFiles = [ - "/rules/", - "/user-guide/", - "/maintainer-guide/", - "/developer-guide/", - "/about/" - ]; - - // append version - if (prereleaseVersion) { - docFiles = docFiles.map(docFile => `/${prereleaseVersion}${docFile}`); - } - - // 1. create temp and build directory - echo("> Creating a temporary directory (Step 1)"); - if (!test("-d", TEMP_DIR)) { - mkdir(TEMP_DIR); - } - - // 2. remove old files from the site - echo("> Removing old files (Step 2)"); - docFiles.forEach(filePath => { - const fullPath = path.join(DOCS_DIR, filePath), - htmlFullPath = fullPath.replace(".md", ".html"); - - if (test("-f", fullPath)) { - rm("-rf", fullPath); +target.gensite = function() { + echo("Generating documentation"); - if (filePath.includes(".md") && test("-f", htmlFullPath)) { - rm("-rf", htmlFullPath); - } - } - }); - - // 3. Copy docs folder to a temporary directory - echo("> Copying the docs folder (Step 3)"); - docFiles.forEach(filePath => { - const pathToCopy = path.join("docs/src", filePath, "*"), - tempPath = path.join(TEMP_DIR, filePath); - - if (!test("-d", tempPath)) { - mkdir(tempPath); - } - - cp("-rf", pathToCopy, tempPath); - }); + const DOCS_RULES_DIR = path.join(DOCS_SRC_DIR, "rules"); + const RULE_VERSIONS_FILE = path.join(DOCS_SRC_DIR, "_data/rule_versions.json"); - // special case (for now) - rm("-rf", path.join(TEMP_DIR, "pages")); - - let versions = test("-f", "./versions.json") ? JSON.parse(cat("./versions.json")) : {}; + // Set up rule version information + let versions = test("-f", RULE_VERSIONS_FILE) ? JSON.parse(cat(RULE_VERSIONS_FILE)) : {}; if (!versions.added) { versions = { @@ -698,117 +640,41 @@ target.gensite = function(prereleaseVersion) { }; } - const { Linter } = require("."); - const rules = new Linter().getRules(); - - const RECOMMENDED_TEXT = "\n\n(recommended) The `\"extends\": \"eslint:recommended\"` property in a configuration file enables this rule."; - const FIXABLE_TEXT = "\n\n(fixable) The `--fix` option on the [command line](../user-guide/command-line-interface#fixing-problems) can automatically fix some of the problems reported by this rule."; - const HAS_SUGGESTIONS_TEXT = "\n\n(hasSuggestions) Some problems reported by this rule are manually fixable by editor [suggestions](../developer-guide/working-with-rules#providing-suggestions)."; - - // 4. Loop through all files in temporary directory - process.stdout.write("> Updating files (Steps 4-9): 0/... - ...\r"); - const tempFiles = find(TEMP_DIR); - const length = tempFiles.length; + // 1. Update rule meta data by checking rule docs - important to catch removed rules + echo("> Updating rule version meta data (Step 1)"); + const ruleDocsFiles = find(DOCS_RULES_DIR); - tempFiles.forEach((filename, i) => { + ruleDocsFiles.forEach((filename, i) => { if (test("-f", filename) && path.extname(filename) === ".md") { - const rulesUrl = "https://github.com/eslint/eslint/tree/HEAD/lib/rules/", - testsUrl = "https://github.com/eslint/eslint/tree/HEAD/tests/lib/rules/", - docsUrl = "https://github.com/eslint/eslint/tree/HEAD/docs/src/rules/", - baseName = path.basename(filename), - sourceBaseName = `${path.basename(filename, ".md")}.js`, - sourcePath = path.join("lib/rules", sourceBaseName), - ruleName = path.basename(filename, ".md"), - filePath = path.posix.join("docs", path.relative("tmp", filename)); - let text = cat(filename); - - process.stdout.write(`> Updating files (Steps 4-9): ${i}/${length} - ${filePath + " ".repeat(30)}\r`); - - // 5. Prepend page title and layout variables at the top of rules - if (path.dirname(filename).includes("rules")) { - - // Find out if the rule requires a special docs portion (e.g. if it is recommended and/or fixable) - const rule = rules.get(ruleName); - const isRecommended = rule && rule.meta.docs.recommended; - const isFixable = rule && rule.meta.fixable; - const hasSuggestions = rule && rule.meta.hasSuggestions; + echo(`> Updating rule version meta data (Step 1: ${i + 1}/${ruleDocsFiles.length}): ${filename}`); - text = text.replace("", isFixable ? FIXABLE_TEXT : "") - .replace("", hasSuggestions ? HAS_SUGGESTIONS_TEXT : "") - .replace("", isRecommended ? RECOMMENDED_TEXT : ""); + const baseName = path.basename(filename, ".md"), + sourceBaseName = `${baseName}.js`, + sourcePath = path.join("lib/rules", sourceBaseName); + if (!versions.added[baseName]) { + versions.added[baseName] = getFirstVersionOfFile(sourcePath); } - // 6. Remove .md extension for relative links and change README to empty string - text = text.replace(/\((?!https?:\/\/)([^)]*?)\.md(.*?)\)/gu, "($1$2)").replace("README.html", ""); - - // 7. Check if there's a trailing white line at the end of the file, if there isn't one, add it - if (!/\n$/u.test(text)) { - text = `${text}\n`; + if (!versions.removed[baseName] && !test("-f", sourcePath)) { + versions.removed[baseName] = getFirstVersionOfDeletion(sourcePath); } - // 8. Append first version of ESLint rule was added at. - if (filename.includes("rules/")) { - if (!versions.added[baseName]) { - versions.added[baseName] = getFirstVersionOfFile(sourcePath); - } - const added = versions.added[baseName]; - - if (!versions.removed[baseName] && !test("-f", sourcePath)) { - versions.removed[baseName] = getFirstVersionOfDeletion(sourcePath); - } - const removed = versions.removed[baseName]; - - text += "\n## Version\n\n"; - text += removed - ? `This rule was introduced in ESLint ${added} and removed in ${removed}.\n` - : `This rule was introduced in ESLint ${added}.\n`; - - text += "\n## Resources\n\n"; - if (!removed) { - text += `* [Rule source](${rulesUrl}${sourceBaseName})\n`; - text += `* [Test source](${testsUrl}${sourceBaseName})\n`; - } - text += `* [Documentation source](${docsUrl}${baseName})\n`; - } - - // 9. Update content of the file with changes - text.to(filename.replace("README.md", "index.md")); } }); - JSON.stringify(versions).to("./versions.json"); - echo(`> Updating files (Steps 4-9)${" ".repeat(50)}`); - - // 10. Copy temporary directory to site's docs folder - echo("> Copying the temporary directory into the site's docs folder (Step 10)"); - let outputDir = DOCS_DIR; - if (prereleaseVersion) { - outputDir += `/${prereleaseVersion}`; - if (!test("-d", outputDir)) { - mkdir(outputDir); - } - } - cp("-rf", `${TEMP_DIR}*`, outputDir); - - // 11. Generate rules index page - if (prereleaseVersion) { - echo("> Skipping generating rules index page because this is a prerelease (Step 11)"); - } else { - echo("> Generating the rules index page (Step 11)"); - generateRuleIndexPage(); - } + JSON.stringify(versions, null, 4).to(RULE_VERSIONS_FILE); - // 12. Delete temporary directory - echo("> Removing the temporary directory (Step 12)"); - rm("-rf", TEMP_DIR); + // 2. Generate rules index page meta data + echo("> Generating the rules index page (Step 2)"); + generateRuleIndexPage(); - // 13. Create Example Formatter Output Page - echo("> Creating the formatter examples (Step 14)"); - generateFormatterExamples(getFormatterResults(), prereleaseVersion); + // 3. Create Example Formatter Output Page + echo("> Creating the formatter examples (Step 3)"); + generateFormatterExamples(getFormatterResults()); - echo("Done generating eslint.org"); + echo("Done generating documentation"); }; target.generateRuleIndexPage = generateRuleIndexPage; diff --git a/docs/src/_data/rule_versions.json b/docs/src/_data/rule_versions.json new file mode 100644 index 00000000000..98463d4bb6d --- /dev/null +++ b/docs/src/_data/rule_versions.json @@ -0,0 +1,329 @@ +{ + "added": { + "accessor-pairs": "0.22.0", + "array-bracket-newline": "4.0.0-alpha.1", + "array-bracket-spacing": "0.24.0", + "array-callback-return": "2.0.0-alpha-1", + "array-element-newline": "4.0.0-rc.0", + "arrow-body-style": "1.8.0", + "arrow-parens": "1.0.0-rc-1", + "arrow-spacing": "1.0.0-rc-1", + "block-scoped-var": "0.1.0", + "block-spacing": "1.2.0", + "brace-style": "0.0.7", + "callback-return": "1.0.0-rc-1", + "camelcase": "0.0.2", + "capitalized-comments": "3.11.0", + "class-methods-use-this": "3.4.0", + "comma-dangle": "0.16.0", + "comma-spacing": "0.9.0", + "comma-style": "0.9.0", + "complexity": "0.0.9", + "computed-property-spacing": "0.23.0", + "consistent-return": "0.4.0", + "consistent-this": "0.0.9", + "constructor-super": "0.24.0", + "curly": "0.0.2", + "default-case-last": "7.0.0-alpha.0", + "default-case": "0.6.0", + "default-param-last": "6.4.0", + "dot-location": "0.21.0", + "dot-notation": "0.0.7", + "eol-last": "0.7.1", + "eqeqeq": "0.0.2", + "for-direction": "4.0.0-beta.0", + "func-call-spacing": "3.3.0", + "func-name-matching": "3.8.0", + "func-names": "0.4.0", + "func-style": "0.2.0", + "function-call-argument-newline": "6.2.0", + "function-paren-newline": "4.6.0", + "generator-star-spacing": "0.17.0", + "generator-star": "0.12.0", + "getter-return": "4.2.0", + "global-require": "1.4.0", + "global-strict": "0.8.0", + "grouped-accessor-pairs": "6.7.0", + "guard-for-in": "0.0.6", + "handle-callback-err": "0.4.5", + "id-blacklist": "2.0.0-beta.2", + "id-denylist": "7.4.0", + "id-length": "1.0.0", + "id-match": "1.0.0", + "implicit-arrow-linebreak": "4.12.0", + "indent-legacy": "4.0.0-alpha.0", + "indent": "0.14.0", + "init-declarations": "1.0.0-rc-1", + "jsx-quotes": "1.4.0", + "key-spacing": "0.9.0", + "keyword-spacing": "2.0.0-beta.1", + "line-comment-position": "3.5.0", + "linebreak-style": "0.21.0", + "lines-around-comment": "0.22.0", + "lines-around-directive": "3.5.0", + "lines-between-class-members": "4.9.0", + "max-classes-per-file": "5.0.0-alpha.3", + "max-depth": "0.0.9", + "max-len": "0.0.9", + "max-lines-per-function": "5.0.0", + "max-lines": "2.12.0", + "max-nested-callbacks": "0.2.0", + "max-params": "0.0.9", + "max-statements-per-line": "2.5.0", + "max-statements": "0.0.9", + "multiline-comment-style": "4.10.0", + "multiline-ternary": "3.1.0", + "new-cap": "0.0.3-0", + "new-parens": "0.0.6", + "newline-after-var": "0.18.0", + "newline-before-return": "2.3.0", + "newline-per-chained-call": "2.0.0-rc.0", + "no-alert": "0.0.5", + "no-array-constructor": "0.4.0", + "no-arrow-condition": "1.8.0", + "no-async-promise-executor": "5.3.0", + "no-await-in-loop": "3.12.0", + "no-bitwise": "0.0.2", + "no-buffer-constructor": "4.0.0-alpha.0", + "no-caller": "0.0.6", + "no-case-declarations": "1.9.0", + "no-catch-shadow": "0.0.9", + "no-class-assign": "1.0.0-rc-1", + "no-comma-dangle": "0.0.9", + "no-compare-neg-zero": "3.17.0", + "no-cond-assign": "0.0.9", + "no-confusing-arrow": "2.0.0-alpha-2", + "no-console": "0.0.2", + "no-const-assign": "1.0.0-rc-1", + "no-constant-binary-expression": "8.14.0", + "no-constant-condition": "0.4.1", + "no-constructor-return": "6.7.0", + "no-continue": "0.19.0", + "no-control-regex": "0.1.0", + "no-debugger": "0.0.2", + "no-delete-var": "0.0.9", + "no-div-regex": "0.1.0", + "no-dupe-args": "0.16.0", + "no-dupe-class-members": "1.2.0", + "no-dupe-else-if": "6.7.0", + "no-dupe-keys": "0.0.9", + "no-duplicate-case": "0.17.0", + "no-duplicate-imports": "2.5.0", + "no-else-return": "0.0.9", + "no-empty-character-class": "0.22.0", + "no-empty-class": "0.0.9", + "no-empty-function": "2.0.0", + "no-empty-label": "0.0.9", + "no-empty-pattern": "1.7.0", + "no-empty": "0.0.2", + "no-eq-null": "0.0.9", + "no-eval": "0.0.2", + "no-ex-assign": "0.0.9", + "no-extend-native": "0.1.4", + "no-extra-bind": "0.8.0", + "no-extra-boolean-cast": "0.4.0", + "no-extra-label": "2.0.0-rc.0", + "no-extra-parens": "0.1.4", + "no-extra-semi": "0.0.9", + "no-extra-strict": "0.3.0", + "no-fallthrough": "0.0.7", + "no-floating-decimal": "0.0.6", + "no-func-assign": "0.0.9", + "no-global-assign": "3.3.0", + "no-implicit-coercion": "1.0.0-rc-2", + "no-implicit-globals": "2.0.0-alpha-1", + "no-implied-eval": "0.0.7", + "no-import-assign": "6.4.0", + "no-inline-comments": "0.10.0", + "no-inner-declarations": "0.6.0", + "no-invalid-regexp": "0.1.4", + "no-invalid-this": "1.0.0-rc-2", + "no-irregular-whitespace": "0.9.0", + "no-iterator": "0.0.9", + "no-label-var": "0.0.9", + "no-labels": "0.4.0", + "no-lone-blocks": "0.4.0", + "no-lonely-if": "0.6.0", + "no-loop-func": "0.0.9", + "no-loss-of-precision": "7.1.0", + "no-magic-numbers": "1.7.0", + "no-misleading-character-class": "5.3.0", + "no-mixed-operators": "2.12.0", + "no-mixed-requires": "0.0.9", + "no-mixed-spaces-and-tabs": "0.7.1", + "no-multi-assign": "3.14.0", + "no-multi-spaces": "0.9.0", + "no-multi-str": "0.0.9", + "no-multiple-empty-lines": "0.9.0", + "no-native-reassign": "0.0.9", + "no-negated-condition": "1.6.0", + "no-negated-in-lhs": "0.1.2", + "no-nested-ternary": "0.2.0", + "no-new-func": "0.0.7", + "no-new-object": "0.0.9", + "no-new-require": "0.6.0", + "no-new-symbol": "2.0.0-beta.1", + "no-new-wrappers": "0.0.6", + "no-new": "0.0.7", + "no-nonoctal-decimal-escape": "7.14.0", + "no-obj-calls": "0.0.9", + "no-octal-escape": "0.0.9", + "no-octal": "0.0.6", + "no-param-reassign": "0.18.0", + "no-path-concat": "0.4.0", + "no-plusplus": "0.0.9", + "no-process-env": "0.9.0", + "no-process-exit": "0.4.0", + "no-promise-executor-return": "7.3.0", + "no-proto": "0.0.9", + "no-prototype-builtins": "2.11.0", + "no-redeclare": "0.0.9", + "no-regex-spaces": "0.4.0", + "no-reserved-keys": "0.8.0", + "no-restricted-exports": "7.0.0-alpha.0", + "no-restricted-globals": "2.3.0", + "no-restricted-imports": "2.0.0-alpha-1", + "no-restricted-modules": "0.6.0", + "no-restricted-properties": "3.5.0", + "no-restricted-syntax": "1.4.0", + "no-return-assign": "0.0.9", + "no-return-await": "3.10.0", + "no-script-url": "0.0.9", + "no-self-assign": "2.0.0-rc.0", + "no-self-compare": "0.0.9", + "no-sequences": "0.5.1", + "no-setter-return": "6.7.0", + "no-shadow-restricted-names": "0.1.4", + "no-shadow": "0.0.9", + "no-space-before-semi": "0.4.3", + "no-spaced-func": "0.1.2", + "no-sparse-arrays": "0.4.0", + "no-sync": "0.0.9", + "no-tabs": "3.2.0", + "no-template-curly-in-string": "3.3.0", + "no-ternary": "0.0.9", + "no-this-before-super": "0.24.0", + "no-throw-literal": "0.15.0", + "no-trailing-spaces": "0.7.1", + "no-undef-init": "0.0.6", + "no-undef": "0.0.9", + "no-undefined": "0.7.1", + "no-underscore-dangle": "0.0.9", + "no-unexpected-multiline": "0.24.0", + "no-unmodified-loop-condition": "2.0.0-alpha-2", + "no-unneeded-ternary": "0.21.0", + "no-unreachable-loop": "7.3.0", + "no-unreachable": "0.0.6", + "no-unsafe-finally": "2.9.0", + "no-unsafe-negation": "3.3.0", + "no-unsafe-optional-chaining": "7.15.0", + "no-unused-expressions": "0.1.0", + "no-unused-labels": "2.0.0-rc.0", + "no-unused-private-class-members": "8.1.0", + "no-unused-vars": "0.0.9", + "no-use-before-define": "0.0.9", + "no-useless-backreference": "7.0.0-alpha.0", + "no-useless-call": "1.0.0-rc-1", + "no-useless-catch": "5.11.0", + "no-useless-computed-key": "2.9.0", + "no-useless-concat": "1.3.0", + "no-useless-constructor": "2.0.0-beta.1", + "no-useless-escape": "2.5.0", + "no-useless-rename": "2.11.0", + "no-useless-return": "3.9.0", + "no-var": "0.12.0", + "no-void": "0.8.0", + "no-warning-comments": "0.4.4", + "no-whitespace-before-property": "2.0.0-beta.1", + "no-with": "0.0.2", + "no-wrap-func": "0.0.9", + "nonblock-statement-body-position": "3.17.0", + "object-curly-newline": "2.12.0", + "object-curly-spacing": "0.22.0", + "object-property-newline": "2.10.0", + "object-shorthand": "0.20.0", + "one-var-declaration-per-line": "2.0.0-beta.3", + "one-var": "0.0.9", + "operator-assignment": "0.10.0", + "operator-linebreak": "0.19.0", + "padded-blocks": "0.9.0", + "padding-line-between-statements": "4.0.0-beta.0", + "prefer-arrow-callback": "1.2.0", + "prefer-const": "0.23.0", + "prefer-destructuring": "3.13.0", + "prefer-exponentiation-operator": "6.7.0", + "prefer-named-capture-group": "5.15.0", + "prefer-numeric-literals": "3.5.0", + "prefer-object-has-own": "8.5.0", + "prefer-object-spread": "5.0.0-alpha.3", + "prefer-promise-reject-errors": "3.14.0", + "prefer-reflect": "1.0.0-rc-2", + "prefer-regex-literals": "6.4.0", + "prefer-rest-params": "2.0.0-alpha-1", + "prefer-spread": "1.0.0-rc-1", + "prefer-template": "1.2.0", + "quote-props": "0.0.6", + "quotes": "0.0.7", + "radix": "0.0.7", + "require-atomic-updates": "5.3.0", + "require-await": "3.11.0", + "require-jsdoc": "1.4.0", + "require-unicode-regexp": "5.3.0", + "require-yield": "1.0.0-rc-1", + "rest-spread-spacing": "2.12.0", + "semi-spacing": "0.16.0", + "semi-style": "4.0.0-beta.0", + "semi": "0.0.6", + "sort-imports": "2.0.0-beta.1", + "sort-keys": "3.3.0", + "sort-vars": "0.2.0", + "space-after-function-name": "0.11.0", + "space-after-keywords": "0.6.0", + "space-before-blocks": "0.9.0", + "space-before-function-paren": "0.18.0", + "space-before-function-parentheses": "0.15.0", + "space-before-keywords": "1.4.0", + "space-in-brackets": "0.4.1", + "space-in-parens": "0.8.0", + "space-infix-ops": "0.2.0", + "space-return-throw-case": "0.1.4", + "space-unary-ops": "0.10.0", + "space-unary-word-ops": "0.1.4", + "spaced-comment": "0.23.0", + "spaced-line-comment": "0.9.0", + "strict": "0.1.0", + "switch-colon-spacing": "4.0.0-beta.0", + "symbol-description": "3.4.0", + "template-curly-spacing": "2.0.0-rc.0", + "template-tag-spacing": "3.15.0", + "unicode-bom": "2.11.0", + "use-isnan": "0.0.6", + "valid-jsdoc": "0.4.0", + "valid-typeof": "0.5.0", + "vars-on-top": "0.8.0", + "wrap-iife": "0.0.9", + "wrap-regex": "0.1.0", + "yield-star-spacing": "2.0.0-alpha-1", + "yoda": "0.7.1" + }, + "removed": { + "generator-star": "1.0.0-rc-1", + "global-strict": "1.0.0-rc-1", + "no-arrow-condition": "2.0.0-beta.3", + "no-comma-dangle": "1.0.0-rc-1", + "no-empty-class": "1.0.0-rc-1", + "no-empty-label": "2.0.0-rc.0", + "no-extra-strict": "1.0.0-rc-1", + "no-reserved-keys": "1.0.0", + "no-space-before-semi": "1.0.0-rc-1", + "no-wrap-func": "1.0.0-rc-1", + "space-after-function-name": "1.0.0-rc-1", + "space-after-keywords": "2.0.0-beta.3", + "space-before-function-parentheses": "1.0.0-rc-1", + "space-before-keywords": "2.0.0-beta.3", + "space-in-brackets": "1.0.0-rc-1", + "space-return-throw-case": "2.0.0-beta.3", + "space-unary-word-ops": "0.10.0", + "spaced-line-comment": "1.0.0-rc-1" + } +} \ No newline at end of file diff --git a/docs/src/_includes/layouts/doc.html b/docs/src/_includes/layouts/doc.html index b032d2f740c..ed11a29bbaf 100644 --- a/docs/src/_includes/layouts/doc.html +++ b/docs/src/_includes/layouts/doc.html @@ -16,6 +16,8 @@ {# Add in various sections to content so TOC is accurate #} {% set all_content = content %} {% set rule_meta = rules_meta[title] %} + {% set added_version = rule_versions.added[title] %} + {% set removed_version = rule_versions.removed[title] %} {% if related_rules %} {% set related_rules_content %} @@ -26,6 +28,16 @@ {% set all_content = [all_content, related_rules_content] | join %} {% endif %} + {% if added_version %} + {% set version_content %} +

Version

+

This rule was introduced in ESLint v{{added_version}}{% if removed_version%} + and removed in v{{removed_version}}{% endif %}.

+ {% endset %} + + {% set all_content = [all_content, version_content] | join %} + {% endif %} + {% if further_reading %} {% set further_reading_content %}

Further Reading

diff --git a/docs/src/user-guide/formatters/html-formatter-example.html b/docs/src/user-guide/formatters/html-formatter-example.html new file mode 100644 index 00000000000..d04d00527dd --- /dev/null +++ b/docs/src/user-guide/formatters/html-formatter-example.html @@ -0,0 +1,203 @@ + + + + + ESLint Report + + + + + +
+

ESLint Report

+
+ 9 problems (5 errors, 4 warnings) - Generated on Tue Jun 21 2022 14:11:34 GMT-0700 (Pacific Daylight Time) +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ [+] C:\Users\nzaka\projects\eslint\eslint\fullOfProblems.js + 9 problems (5 errors, 4 warnings) +
+ + + diff --git a/docs/src/user-guide/formatters/index.md b/docs/src/user-guide/formatters/index.md new file mode 100644 index 00000000000..b9b8686a52f --- /dev/null +++ b/docs/src/user-guide/formatters/index.md @@ -0,0 +1,242 @@ +--- +title: ESLint Formatters +layout: doc +eleventyNavigation: + key: formatters + parent: user guide + title: Formatters + order: 5 +--- + +ESLint comes with several built-in formatters to control the appearance of the linting results, and supports third-party formatters as well. + +You can specify a formatter using the `--format` or `-f` flag on the command line. For example, `--format json` uses the `json` formatter. + +The built-in formatter options are: + +* [checkstyle](#checkstyle) +* [compact](#compact) +* [html](#html) +* [jslint-xml](#jslint-xml) +* [json-with-metadata](#json-with-metadata) +* [json](#json) +* [junit](#junit) +* [stylish](#stylish) +* [tap](#tap) +* [unix](#unix) +* [visualstudio](#visualstudio) + +## Example Source + +Examples of each formatter were created from linting `fullOfProblems.js` using the `.eslintrc` configuration shown below. + +### `fullOfProblems.js` + +```js +function addOne(i) { + if (i != NaN) { + return i ++ + } else { + return + } +}; +``` + +### `.eslintrc`: + +```json +{ + "extends": "eslint:recommended", + "rules": { + "consistent-return": 2, + "indent" : [1, 4], + "no-else-return" : 1, + "semi" : [1, "always"], + "space-unary-ops" : 2 + } +} +``` + +## Output Examples + +### checkstyle + +```text +<?xml version="1.0" encoding="utf-8"?><checkstyle version="4.3"><file name="C:\Users\nzaka\projects\eslint\eslint\fullOfProblems.js"><error line="1" column="10" severity="error" message="&apos;addOne&apos; is defined but never used. (no-unused-vars)" source="eslint.rules.no-unused-vars" /><error line="2" column="9" severity="error" message="Use the isNaN function to compare with NaN. (use-isnan)" source="eslint.rules.use-isnan" /><error line="3" column="16" severity="error" message="Unexpected space before unary operator &apos;++&apos;. (space-unary-ops)" source="eslint.rules.space-unary-ops" /><error line="3" column="20" severity="warning" message="Missing semicolon. (semi)" source="eslint.rules.semi" /><error line="4" column="12" severity="warning" message="Unnecessary &apos;else&apos; after &apos;return&apos;. (no-else-return)" source="eslint.rules.no-else-return" /><error line="5" column="1" severity="warning" message="Expected indentation of 8 spaces but found 6. (indent)" source="eslint.rules.indent" /><error line="5" column="7" severity="error" message="Function &apos;addOne&apos; expected a return value. (consistent-return)" source="eslint.rules.consistent-return" /><error line="5" column="13" severity="warning" message="Missing semicolon. (semi)" source="eslint.rules.semi" /><error line="7" column="2" severity="error" message="Unnecessary semicolon. (no-extra-semi)" source="eslint.rules.no-extra-semi" /></file></checkstyle> +``` + +### compact + +```text +C:\Users\nzaka\projects\eslint\eslint\fullOfProblems.js: line 1, col 10, Error - 'addOne' is defined but never used. (no-unused-vars) +C:\Users\nzaka\projects\eslint\eslint\fullOfProblems.js: line 2, col 9, Error - Use the isNaN function to compare with NaN. (use-isnan) +C:\Users\nzaka\projects\eslint\eslint\fullOfProblems.js: line 3, col 16, Error - Unexpected space before unary operator '++'. (space-unary-ops) +C:\Users\nzaka\projects\eslint\eslint\fullOfProblems.js: line 3, col 20, Warning - Missing semicolon. (semi) +C:\Users\nzaka\projects\eslint\eslint\fullOfProblems.js: line 4, col 12, Warning - Unnecessary 'else' after 'return'. (no-else-return) +C:\Users\nzaka\projects\eslint\eslint\fullOfProblems.js: line 5, col 1, Warning - Expected indentation of 8 spaces but found 6. (indent) +C:\Users\nzaka\projects\eslint\eslint\fullOfProblems.js: line 5, col 7, Error - Function 'addOne' expected a return value. (consistent-return) +C:\Users\nzaka\projects\eslint\eslint\fullOfProblems.js: line 5, col 13, Warning - Missing semicolon. (semi) +C:\Users\nzaka\projects\eslint\eslint\fullOfProblems.js: line 7, col 2, Error - Unnecessary semicolon. (no-extra-semi) + +9 problems +``` + +### html + + + +### jslint-xml + +```text +<?xml version="1.0" encoding="utf-8"?><jslint><file name="C:\Users\nzaka\projects\eslint\eslint\fullOfProblems.js"><issue line="1" char="10" evidence="" reason="&apos;addOne&apos; is defined but never used. (no-unused-vars)" /><issue line="2" char="9" evidence="" reason="Use the isNaN function to compare with NaN. (use-isnan)" /><issue line="3" char="16" evidence="" reason="Unexpected space before unary operator &apos;++&apos;. (space-unary-ops)" /><issue line="3" char="20" evidence="" reason="Missing semicolon. (semi)" /><issue line="4" char="12" evidence="" reason="Unnecessary &apos;else&apos; after &apos;return&apos;. (no-else-return)" /><issue line="5" char="1" evidence="" reason="Expected indentation of 8 spaces but found 6. (indent)" /><issue line="5" char="7" evidence="" reason="Function &apos;addOne&apos; expected a return value. (consistent-return)" /><issue line="5" char="13" evidence="" reason="Missing semicolon. (semi)" /><issue line="7" char="2" evidence="" reason="Unnecessary semicolon. (no-extra-semi)" /></file></jslint> +``` + +### json-with-metadata + +```text +{"results":[{"filePath":"C:\\Users\\nzaka\\projects\\eslint\\eslint\\fullOfProblems.js","messages":[{"ruleId":"no-unused-vars","severity":2,"message":"'addOne' is defined but never used.","line":1,"column":10,"nodeType":"Identifier","messageId":"unusedVar","endLine":1,"endColumn":16},{"ruleId":"use-isnan","severity":2,"message":"Use the isNaN function to compare with NaN.","line":2,"column":9,"nodeType":"BinaryExpression","messageId":"comparisonWithNaN","endLine":2,"endColumn":17},{"ruleId":"space-unary-ops","severity":2,"message":"Unexpected space before unary operator '++'.","line":3,"column":16,"nodeType":"UpdateExpression","messageId":"unexpectedBefore","endLine":3,"endColumn":20,"fix":{"range":[57,58],"text":""}},{"ruleId":"semi","severity":1,"message":"Missing semicolon.","line":3,"column":20,"nodeType":"ReturnStatement","messageId":"missingSemi","endLine":4,"endColumn":1,"fix":{"range":[60,60],"text":";"}},{"ruleId":"no-else-return","severity":1,"message":"Unnecessary 'else' after 'return'.","line":4,"column":12,"nodeType":"BlockStatement","messageId":"unexpected","endLine":6,"endColumn":6,"fix":{"range":[0,94],"text":"function addOne(i) {\n if (i != NaN) {\n return i ++\n } \n return\n \n}"}},{"ruleId":"indent","severity":1,"message":"Expected indentation of 8 spaces but found 6.","line":5,"column":1,"nodeType":"Keyword","messageId":"wrongIndentation","endLine":5,"endColumn":7,"fix":{"range":[74,80],"text":" "}},{"ruleId":"consistent-return","severity":2,"message":"Function 'addOne' expected a return value.","line":5,"column":7,"nodeType":"ReturnStatement","messageId":"missingReturnValue","endLine":5,"endColumn":13},{"ruleId":"semi","severity":1,"message":"Missing semicolon.","line":5,"column":13,"nodeType":"ReturnStatement","messageId":"missingSemi","endLine":6,"endColumn":1,"fix":{"range":[86,86],"text":";"}},{"ruleId":"no-extra-semi","severity":2,"message":"Unnecessary semicolon.","line":7,"column":2,"nodeType":"EmptyStatement","messageId":"unexpected","endLine":7,"endColumn":3,"fix":{"range":[93,95],"text":"}"}}],"suppressedMessages":[],"errorCount":5,"fatalErrorCount":0,"warningCount":4,"fixableErrorCount":2,"fixableWarningCount":4,"source":"function addOne(i) {\n if (i != NaN) {\n return i ++\n } else {\n return\n }\n};"}],"metadata":{"rulesMeta":{"no-else-return":{"type":"suggestion","docs":{"description":"disallow `else` blocks after `return` statements in `if` statements","recommended":false,"url":"https://eslint.org/docs/rules/no-else-return"},"schema":[{"type":"object","properties":{"allowElseIf":{"type":"boolean","default":true}},"additionalProperties":false}],"fixable":"code","messages":{"unexpected":"Unnecessary 'else' after 'return'."}},"indent":{"type":"layout","docs":{"description":"enforce consistent indentation","recommended":false,"url":"https://eslint.org/docs/rules/indent"},"fixable":"whitespace","schema":[{"oneOf":[{"enum":["tab"]},{"type":"integer","minimum":0}]},{"type":"object","properties":{"SwitchCase":{"type":"integer","minimum":0,"default":0},"VariableDeclarator":{"oneOf":[{"oneOf":[{"type":"integer","minimum":0},{"enum":["first","off"]}]},{"type":"object","properties":{"var":{"oneOf":[{"type":"integer","minimum":0},{"enum":["first","off"]}]},"let":{"oneOf":[{"type":"integer","minimum":0},{"enum":["first","off"]}]},"const":{"oneOf":[{"type":"integer","minimum":0},{"enum":["first","off"]}]}},"additionalProperties":false}]},"outerIIFEBody":{"oneOf":[{"type":"integer","minimum":0},{"enum":["off"]}]},"MemberExpression":{"oneOf":[{"type":"integer","minimum":0},{"enum":["off"]}]},"FunctionDeclaration":{"type":"object","properties":{"parameters":{"oneOf":[{"type":"integer","minimum":0},{"enum":["first","off"]}]},"body":{"type":"integer","minimum":0}},"additionalProperties":false},"FunctionExpression":{"type":"object","properties":{"parameters":{"oneOf":[{"type":"integer","minimum":0},{"enum":["first","off"]}]},"body":{"type":"integer","minimum":0}},"additionalProperties":false},"StaticBlock":{"type":"object","properties":{"body":{"type":"integer","minimum":0}},"additionalProperties":false},"CallExpression":{"type":"object","properties":{"arguments":{"oneOf":[{"type":"integer","minimum":0},{"enum":["first","off"]}]}},"additionalProperties":false},"ArrayExpression":{"oneOf":[{"type":"integer","minimum":0},{"enum":["first","off"]}]},"ObjectExpression":{"oneOf":[{"type":"integer","minimum":0},{"enum":["first","off"]}]},"ImportDeclaration":{"oneOf":[{"type":"integer","minimum":0},{"enum":["first","off"]}]},"flatTernaryExpressions":{"type":"boolean","default":false},"offsetTernaryExpressions":{"type":"boolean","default":false},"ignoredNodes":{"type":"array","items":{"type":"string","not":{"pattern":":exit$"}}},"ignoreComments":{"type":"boolean","default":false}},"additionalProperties":false}],"messages":{"wrongIndentation":"Expected indentation of {{expected}} but found {{actual}}."}},"space-unary-ops":{"type":"layout","docs":{"description":"enforce consistent spacing before or after unary operators","recommended":false,"url":"https://eslint.org/docs/rules/space-unary-ops"},"fixable":"whitespace","schema":[{"type":"object","properties":{"words":{"type":"boolean","default":true},"nonwords":{"type":"boolean","default":false},"overrides":{"type":"object","additionalProperties":{"type":"boolean"}}},"additionalProperties":false}],"messages":{"unexpectedBefore":"Unexpected space before unary operator '{{operator}}'.","unexpectedAfter":"Unexpected space after unary operator '{{operator}}'.","unexpectedAfterWord":"Unexpected space after unary word operator '{{word}}'.","wordOperator":"Unary word operator '{{word}}' must be followed by whitespace.","operator":"Unary operator '{{operator}}' must be followed by whitespace.","beforeUnaryExpressions":"Space is required before unary expressions '{{token}}'."}},"semi":{"type":"layout","docs":{"description":"require or disallow semicolons instead of ASI","recommended":false,"url":"https://eslint.org/docs/rules/semi"},"fixable":"code","schema":{"anyOf":[{"type":"array","items":[{"enum":["never"]},{"type":"object","properties":{"beforeStatementContinuationChars":{"enum":["always","any","never"]}},"additionalProperties":false}],"minItems":0,"maxItems":2},{"type":"array","items":[{"enum":["always"]},{"type":"object","properties":{"omitLastInOneLineBlock":{"type":"boolean"}},"additionalProperties":false}],"minItems":0,"maxItems":2}]},"messages":{"missingSemi":"Missing semicolon.","extraSemi":"Extra semicolon."}},"consistent-return":{"type":"suggestion","docs":{"description":"require `return` statements to either always or never specify values","recommended":false,"url":"https://eslint.org/docs/rules/consistent-return"},"schema":[{"type":"object","properties":{"treatUndefinedAsUnspecified":{"type":"boolean","default":false}},"additionalProperties":false}],"messages":{"missingReturn":"Expected to return a value at the end of {{name}}.","missingReturnValue":"{{name}} expected a return value.","unexpectedReturnValue":"{{name}} expected no return value."}}}}} +``` + +### json + +```text +[{"filePath":"C:\\Users\\nzaka\\projects\\eslint\\eslint\\fullOfProblems.js","messages":[{"ruleId":"no-unused-vars","severity":2,"message":"'addOne' is defined but never used.","line":1,"column":10,"nodeType":"Identifier","messageId":"unusedVar","endLine":1,"endColumn":16},{"ruleId":"use-isnan","severity":2,"message":"Use the isNaN function to compare with NaN.","line":2,"column":9,"nodeType":"BinaryExpression","messageId":"comparisonWithNaN","endLine":2,"endColumn":17},{"ruleId":"space-unary-ops","severity":2,"message":"Unexpected space before unary operator '++'.","line":3,"column":16,"nodeType":"UpdateExpression","messageId":"unexpectedBefore","endLine":3,"endColumn":20,"fix":{"range":[57,58],"text":""}},{"ruleId":"semi","severity":1,"message":"Missing semicolon.","line":3,"column":20,"nodeType":"ReturnStatement","messageId":"missingSemi","endLine":4,"endColumn":1,"fix":{"range":[60,60],"text":";"}},{"ruleId":"no-else-return","severity":1,"message":"Unnecessary 'else' after 'return'.","line":4,"column":12,"nodeType":"BlockStatement","messageId":"unexpected","endLine":6,"endColumn":6,"fix":{"range":[0,94],"text":"function addOne(i) {\n if (i != NaN) {\n return i ++\n } \n return\n \n}"}},{"ruleId":"indent","severity":1,"message":"Expected indentation of 8 spaces but found 6.","line":5,"column":1,"nodeType":"Keyword","messageId":"wrongIndentation","endLine":5,"endColumn":7,"fix":{"range":[74,80],"text":" "}},{"ruleId":"consistent-return","severity":2,"message":"Function 'addOne' expected a return value.","line":5,"column":7,"nodeType":"ReturnStatement","messageId":"missingReturnValue","endLine":5,"endColumn":13},{"ruleId":"semi","severity":1,"message":"Missing semicolon.","line":5,"column":13,"nodeType":"ReturnStatement","messageId":"missingSemi","endLine":6,"endColumn":1,"fix":{"range":[86,86],"text":";"}},{"ruleId":"no-extra-semi","severity":2,"message":"Unnecessary semicolon.","line":7,"column":2,"nodeType":"EmptyStatement","messageId":"unexpected","endLine":7,"endColumn":3,"fix":{"range":[93,95],"text":"}"}}],"suppressedMessages":[],"errorCount":5,"fatalErrorCount":0,"warningCount":4,"fixableErrorCount":2,"fixableWarningCount":4,"source":"function addOne(i) {\n if (i != NaN) {\n return i ++\n } else {\n return\n }\n};"}] +``` + +### junit + +```text +<?xml version="1.0" encoding="utf-8"?> +<testsuites> +<testsuite package="org.eslint" time="0" tests="9" errors="9" name="C:\Users\nzaka\projects\eslint\eslint\fullOfProblems.js"> +<testcase time="0" name="org.eslint.no-unused-vars" classname="C:\Users\nzaka\projects\eslint\eslint\fullOfProblems"><failure message="&apos;addOne&apos; is defined but never used."><![CDATA[line 1, col 10, Error - &apos;addOne&apos; is defined but never used. (no-unused-vars)]]></failure></testcase> +<testcase time="0" name="org.eslint.use-isnan" classname="C:\Users\nzaka\projects\eslint\eslint\fullOfProblems"><failure message="Use the isNaN function to compare with NaN."><![CDATA[line 2, col 9, Error - Use the isNaN function to compare with NaN. (use-isnan)]]></failure></testcase> +<testcase time="0" name="org.eslint.space-unary-ops" classname="C:\Users\nzaka\projects\eslint\eslint\fullOfProblems"><failure message="Unexpected space before unary operator &apos;++&apos;."><![CDATA[line 3, col 16, Error - Unexpected space before unary operator &apos;++&apos;. (space-unary-ops)]]></failure></testcase> +<testcase time="0" name="org.eslint.semi" classname="C:\Users\nzaka\projects\eslint\eslint\fullOfProblems"><failure message="Missing semicolon."><![CDATA[line 3, col 20, Warning - Missing semicolon. (semi)]]></failure></testcase> +<testcase time="0" name="org.eslint.no-else-return" classname="C:\Users\nzaka\projects\eslint\eslint\fullOfProblems"><failure message="Unnecessary &apos;else&apos; after &apos;return&apos;."><![CDATA[line 4, col 12, Warning - Unnecessary &apos;else&apos; after &apos;return&apos;. (no-else-return)]]></failure></testcase> +<testcase time="0" name="org.eslint.indent" classname="C:\Users\nzaka\projects\eslint\eslint\fullOfProblems"><failure message="Expected indentation of 8 spaces but found 6."><![CDATA[line 5, col 1, Warning - Expected indentation of 8 spaces but found 6. (indent)]]></failure></testcase> +<testcase time="0" name="org.eslint.consistent-return" classname="C:\Users\nzaka\projects\eslint\eslint\fullOfProblems"><failure message="Function &apos;addOne&apos; expected a return value."><![CDATA[line 5, col 7, Error - Function &apos;addOne&apos; expected a return value. (consistent-return)]]></failure></testcase> +<testcase time="0" name="org.eslint.semi" classname="C:\Users\nzaka\projects\eslint\eslint\fullOfProblems"><failure message="Missing semicolon."><![CDATA[line 5, col 13, Warning - Missing semicolon. (semi)]]></failure></testcase> +<testcase time="0" name="org.eslint.no-extra-semi" classname="C:\Users\nzaka\projects\eslint\eslint\fullOfProblems"><failure message="Unnecessary semicolon."><![CDATA[line 7, col 2, Error - Unnecessary semicolon. (no-extra-semi)]]></failure></testcase> +</testsuite> +</testsuites> + +``` + +### stylish + +```text + +C:\Users\nzaka\projects\eslint\eslint\fullOfProblems.js + 1:10 error 'addOne' is defined but never used no-unused-vars + 2:9 error Use the isNaN function to compare with NaN use-isnan + 3:16 error Unexpected space before unary operator '++' space-unary-ops + 3:20 warning Missing semicolon semi + 4:12 warning Unnecessary 'else' after 'return' no-else-return + 5:1 warning Expected indentation of 8 spaces but found 6 indent + 5:7 error Function 'addOne' expected a return value consistent-return + 5:13 warning Missing semicolon semi + 7:2 error Unnecessary semicolon no-extra-semi + +✖ 9 problems (5 errors, 4 warnings) + 2 errors and 4 warnings potentially fixable with the `--fix` option. + +``` + +### tap + +```text +TAP version 13 +1..1 +not ok 1 - C:\Users\nzaka\projects\eslint\eslint\fullOfProblems.js + --- + message: '''addOne'' is defined but never used.' + severity: error + data: + line: 1 + column: 10 + ruleId: no-unused-vars + messages: + - message: Use the isNaN function to compare with NaN. + severity: error + data: + line: 2 + column: 9 + ruleId: use-isnan + - message: Unexpected space before unary operator '++'. + severity: error + data: + line: 3 + column: 16 + ruleId: space-unary-ops + - message: Missing semicolon. + severity: warning + data: + line: 3 + column: 20 + ruleId: semi + - message: Unnecessary 'else' after 'return'. + severity: warning + data: + line: 4 + column: 12 + ruleId: no-else-return + - message: Expected indentation of 8 spaces but found 6. + severity: warning + data: + line: 5 + column: 1 + ruleId: indent + - message: Function 'addOne' expected a return value. + severity: error + data: + line: 5 + column: 7 + ruleId: consistent-return + - message: Missing semicolon. + severity: warning + data: + line: 5 + column: 13 + ruleId: semi + - message: Unnecessary semicolon. + severity: error + data: + line: 7 + column: 2 + ruleId: no-extra-semi + ... + +``` + +### unix + +```text +C:\Users\nzaka\projects\eslint\eslint\fullOfProblems.js:1:10: 'addOne' is defined but never used. [Error/no-unused-vars] +C:\Users\nzaka\projects\eslint\eslint\fullOfProblems.js:2:9: Use the isNaN function to compare with NaN. [Error/use-isnan] +C:\Users\nzaka\projects\eslint\eslint\fullOfProblems.js:3:16: Unexpected space before unary operator '++'. [Error/space-unary-ops] +C:\Users\nzaka\projects\eslint\eslint\fullOfProblems.js:3:20: Missing semicolon. [Warning/semi] +C:\Users\nzaka\projects\eslint\eslint\fullOfProblems.js:4:12: Unnecessary 'else' after 'return'. [Warning/no-else-return] +C:\Users\nzaka\projects\eslint\eslint\fullOfProblems.js:5:1: Expected indentation of 8 spaces but found 6. [Warning/indent] +C:\Users\nzaka\projects\eslint\eslint\fullOfProblems.js:5:7: Function 'addOne' expected a return value. [Error/consistent-return] +C:\Users\nzaka\projects\eslint\eslint\fullOfProblems.js:5:13: Missing semicolon. [Warning/semi] +C:\Users\nzaka\projects\eslint\eslint\fullOfProblems.js:7:2: Unnecessary semicolon. [Error/no-extra-semi] + +9 problems +``` + +### visualstudio + +```text +C:\Users\nzaka\projects\eslint\eslint\fullOfProblems.js(1,10): error no-unused-vars : 'addOne' is defined but never used. +C:\Users\nzaka\projects\eslint\eslint\fullOfProblems.js(2,9): error use-isnan : Use the isNaN function to compare with NaN. +C:\Users\nzaka\projects\eslint\eslint\fullOfProblems.js(3,16): error space-unary-ops : Unexpected space before unary operator '++'. +C:\Users\nzaka\projects\eslint\eslint\fullOfProblems.js(3,20): warning semi : Missing semicolon. +C:\Users\nzaka\projects\eslint\eslint\fullOfProblems.js(4,12): warning no-else-return : Unnecessary 'else' after 'return'. +C:\Users\nzaka\projects\eslint\eslint\fullOfProblems.js(5,1): warning indent : Expected indentation of 8 spaces but found 6. +C:\Users\nzaka\projects\eslint\eslint\fullOfProblems.js(5,7): error consistent-return : Function 'addOne' expected a return value. +C:\Users\nzaka\projects\eslint\eslint\fullOfProblems.js(5,13): warning semi : Missing semicolon. +C:\Users\nzaka\projects\eslint\eslint\fullOfProblems.js(7,2): error no-extra-semi : Unnecessary semicolon. + +9 problems +``` diff --git a/package.json b/package.json index 1b1177fc34b..a4c65b51126 100644 --- a/package.json +++ b/package.json @@ -98,7 +98,6 @@ "cheerio": "^0.22.0", "common-tags": "^1.8.0", "core-js": "^3.1.3", - "dateformat": "^4.5.1", "ejs": "^3.0.2", "eslint": "file:.", "eslint-config-eslint": "file:packages/eslint-config-eslint", diff --git a/templates/blogpost.md.ejs b/templates/blogpost.md.ejs index 9d01937e80a..25d6c45661f 100644 --- a/templates/blogpost.md.ejs +++ b/templates/blogpost.md.ejs @@ -3,6 +3,8 @@ layout: post title: ESLint v<%- version %> released teaser: "We just pushed ESLint v<%- version %>, which is a <%- type %> release upgrade of ESLint. This release <% if (type !== "patch") { %>adds some new features and <% } %>fixes several bugs found in the previous release.<% if (type === "major") { %> This release also has some breaking changes, so please read the following closely.<% } %>" image: release-notes-<%- type %>.png +authors: + - eslintbot categories: - Release Notes tags: diff --git a/templates/formatter-examples.md.ejs b/templates/formatter-examples.md.ejs index 7c41544da2f..e4909526d01 100644 --- a/templates/formatter-examples.md.ejs +++ b/templates/formatter-examples.md.ejs @@ -1,6 +1,11 @@ --- -title: ESLint Formatters +title: Formatters layout: doc +eleventyNavigation: + key: formatters + parent: user guide + title: Formatters + order: 5 --- ESLint comes with several built-in formatters to control the appearance of the linting results, and supports third-party formatters as well. @@ -49,8 +54,9 @@ function addOne(i) { ### <%= formatterName %> <% if (formatterName !== "html") { -%> -``` -<%- formatterResults[formatterName].result %> + +```text +<%= formatterResults[formatterName].result %> ``` <% } else {-%>