fs = require("fs"),
glob = require("glob"),
marked = require("marked"),
+ matter = require("gray-matter"),
markdownlint = require("markdownlint"),
os = require("os"),
path = require("path"),
*/
function generateFormatterExamples(formatterInfo) {
const output = ejs.render(cat("./templates/formatter-examples.md.ejs"), formatterInfo);
- const outputDir = path.join(DOCS_SRC_DIR, "user-guide/formatters/"),
+ const outputDir = path.join(DOCS_SRC_DIR, "use/formatters/"),
filename = path.join(outputDir, "index.md"),
htmlFilename = path.join(outputDir, "html-formatter-example.html");
*/
function publishRelease() {
ReleaseOps.publishRelease();
+ const releaseInfo = JSON.parse(cat(".eslint-release-info.json"));
+ const isPreRelease = /[a-z]/u.test(releaseInfo.version);
- // push to latest branch to trigger docs deploy
- exec("git push origin HEAD:latest -f");
+ /*
+ * for a pre-release, push to the "next" branch to trigger docs deploy
+ * for a release, push to the "latest" branch to trigger docs deploy
+ */
+ if (isPreRelease) {
+ exec("git push origin HEAD:next -f");
+ } else {
+ exec("git push origin HEAD:latest -f");
+ }
publishSite();
}
*/
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],
);
data.formatterResults[name] = {
- result: stripAnsi(formattedOutput)
+ result: stripAnsi(formattedOutput),
+ description: formattersMetadata.find(formatter => formatter.name === name).description
};
}
return data;
* when analyzing `require()` calls from CJS modules in the `docs` directory. Since our release process does not run `npm install`
* in the `docs` directory, linting would fail and break the release. Also, working on the main `eslint` package does not require
* installing dependencies declared in `docs/package.json`, so most contributors will not have `docs/node_modules` locally.
- * Therefore, we add `--ignore-pattern docs` to exclude linting the `docs` directory from this command.
+ * Therefore, we add `--ignore-pattern "docs/**"` to exclude linting the `docs` directory from this command.
* There is a separate command `target.lintDocsJS` for linting JavaScript files in the `docs` directory.
*/
echo("Validating JavaScript files");
- lastReturn = exec(`${ESLINT}${fix ? "--fix" : ""} . --ignore-pattern docs`);
+ lastReturn = exec(`${ESLINT}${fix ? "--fix" : ""} . --ignore-pattern "docs/**"`);
if (lastReturn.code !== 0) {
errors++;
}
let errors = 0;
echo("Validating JavaScript files in the docs directory");
- const lastReturn = exec(`${ESLINT}${fix ? "--fix" : ""} docs/.eleventy.js`);
+ const lastReturn = exec(`${ESLINT}${fix ? "--fix" : ""} docs`);
if (lastReturn.code !== 0) {
errors++;
};
target.test = function() {
- target.lint();
target.checkRuleFiles();
target.mocha();
target.karma();
const basename = path.basename(filename, ".js");
const docFilename = `docs/src/rules/${basename}.md`;
const docText = cat(docFilename);
- const docMarkdown = marked.lexer(docText, { gfm: true, silent: false });
+ const docTextWithoutFrontmatter = matter(String(docText)).content;
+ const docMarkdown = marked.lexer(docTextWithoutFrontmatter, { gfm: true, silent: false });
const ruleCode = cat(filename);
const knownHeaders = ["Rule Details", "Options", "Environments", "Examples", "Known Limitations", "When Not To Use It", "Compatibility"];
}
// check eslint:recommended
- const recommended = require("./conf/eslint-recommended");
+ const recommended = require("./packages/js").configs.recommended;
if (ruleDef.meta.docs.recommended) {
if (recommended.rules[basename] !== "error") {
- console.error(`Missing rule from eslint:recommended (./conf/eslint-recommended.js): ${basename}. If you just made a rule recommended then add an entry for it in this file.`);
+ console.error(`Missing rule from eslint:recommended (./packages/js/src/configs/eslint-recommended.js): ${basename}. If you just made a rule recommended then add an entry for it in this file.`);
errors++;
}
} else {
if (basename in recommended.rules) {
- console.error(`Extra rule in eslint:recommended (./conf/eslint-recommended.js): ${basename}. If you just added a rule then don't add an entry for it in this file.`);
+ console.error(`Extra rule in eslint:recommended (./packages/js/src/configs/eslint-recommended.js): ${basename}. If you just added a rule then don't add an entry for it in this file.`);
errors++;
}
}