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 7a4822f commit 28ca6c5
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 4 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/ci.yml
Expand Up @@ -21,7 +21,9 @@ jobs:
run: npm ci
- name: Install playground dependencies
run: npm run install:playground
- name: Run build
run: npm run build
- name: Lint Files
run: npm run lint
- name: Run build
run: npm run build
- name: Validate Internal Links
run: npm run validate:links
1 change: 1 addition & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Expand Up @@ -29,15 +29,15 @@
"start": "npm-run-all build:sass --parallel watch:*",
"build": "npm-run-all install:playground build:sass build:eleventy build:webpack images",
"minify:svg": "svgo -r -f ./",
"validate:links": "cross-env NODE_OPTIONS=--max-old-space-size=4096 node tools/validate-links.js",
"lint:js": "eslint --ext=.js,.jsx .",
"lint:md": "markdownlint \"**/*.md\" ",
"lint:scss": "stylelint \"**/*.scss\"",
"lint:links": "hyperlink ./_site/index.html --canonicalroot https://eslint.org/ -r --internal ./_site/index.html --pretty --skip https:// --skip _site/sponsors --skip _site/docs > internal-links.tap; cat internal-links.tap | tap-spot",
"lint": "npm-run-all --parallel lint:*",
"lint:fix:js": "eslint --ext=.js,.jsx . --fix",
"lint:fix:scss": "stylelint \"**/*.scss\" --fix",
"lint:fix:md": "markdownlint --fix \"**/*.md\"",
"fix": "npm-run-all --parallel lint:fix:*"
"fix": "npm-run-all --parallel lint:fix:*",
},
"lint-staged": {
"**/*.{js,jsx}": "eslint --fix",
Expand All @@ -57,6 +57,7 @@
"@babel/core": "^7.17.5",
"@babel/preset-env": "^7.16.11",
"@babel/preset-react": "^7.16.7",
"@munter/tap-render": "^0.2.0",
"@octokit/graphql": "^4.8.0",
"@octokit/rest": "^18.12.0",
"babel-loader": "^8.2.3",
Expand Down
44 changes: 44 additions & 0 deletions tools/validate-links.js
@@ -0,0 +1,44 @@
const path = require("path");
const TapRender = require("@munter/tap-render");
const spot = require("tap-spot");
const hyperlink = require("hyperlink");

const tapRenderInstance = new TapRender();

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

const skipPatterns = [
"https://",
"fragment-redirect",
"_site/sponsors",
"_site/docs"
];

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/",
recursive: true,
internalOnly: true,
pretty: true,
concurrency: 25,
skipFilter,
},
tapRenderInstance
);
} catch (err) {
console.log(err.stack);
process.exit(1);
}
const results = t.close();

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

0 comments on commit 28ca6c5

Please sign in to comment.