Skip to content

Commit

Permalink
chore: use custom script
Browse files Browse the repository at this point in the history
  • Loading branch information
snitin315 committed Feb 18, 2023
1 parent dc38328 commit 3192281
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 1 deletion.
2 changes: 1 addition & 1 deletion docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"start": "npm-run-all build:sass --parallel watch:*",
"build": "npm-run-all build:sass build:eleventy images",
"lint:scss": "stylelint \"**/*.{scss,html}\"",
"lint:links": "hyperlink ./_site/index.html --canonicalroot https://eslint.org/docs/head/ -r --internal ./_site/index.html --pretty --skip https:// --skip fragment-redirect --skip migrating-to --skip /blog --skip /play --skip /team --skip /donate --skip /docs/latest --skip _site/rules/null > internal-links.tap; cat internal-links.tap | tap-spot",
"lint:links": "hyperlink ./_site/index.html --canonicalroot https://eslint.org/docs/head/ -r --internal ./_site/index.html --pretty --skip https:// --skip fragment-redirect --skip migrating-to --skip /blog --skip /play --skip /team --skip /donate --skip /docs/latest --skip _site/rules/null",
"lint:fix:scss": "npm run lint:scss -- --fix"
},
"devDependencies": {
Expand Down
49 changes: 49 additions & 0 deletions docs/tools/validate-links.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
const path = require("path");
const TapRender = require("@munter/tap-render");
const spot = require("tap-spot");
const hyperlink = require("hyperlink");

const t = new TapRender();

t.pipe(spot()).pipe(process.stdout);

const skipPatterns = [
"https://",
"fragment-redirect",
"migrating-to",
"/blog",
"/play",
"/team",
"/donate",
"/docs/latest",
"_site/rules/null"
];

const skipFilter = (report) =>
Object.values(report).some((value) =>
skipPatterns.some((pattern) => String(value).includes(pattern))
);

(async () => {
try {
await hyperlink(
{
inputUrls: ["../_site/index.html"],
root: path.resolve(__dirname, "../_site"),
canonicalRoot: "https://eslint.org/docs/head/",
recursive: true,
internalOnly: true,
pretty: true,
concurrency: 25,
skipFilter,
},
t
);
} catch (err) {
console.log(err.stack);
process.exit(1);
}
const results = t.close();

process.exit(results.fail ? 1 : 0);
})();

0 comments on commit 3192281

Please sign in to comment.