From 19097faa2db43a86ccfa8505e57800b4f0cceeb8 Mon Sep 17 00:00:00 2001 From: Marshall Quander <marshall@quander.me> Date: Thu, 26 Jul 2018 19:08:36 -0700 Subject: [PATCH] Now we can use htmlhint directly on our HTML --- package.json | 2 +- scripts/lint-html.js | 36 ------------------------------------ 2 files changed, 1 insertion(+), 37 deletions(-) delete mode 100644 scripts/lint-html.js diff --git a/package.json b/package.json index f31e683cd..b925f9629 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "doc": "node ./scripts/doc/build.js", "prettier": "prettier --write '*.js' 'src/**/*.js'", "lint:js": "eslint '*.js' 'scripts/**/*.js' 'src/**/*.js'", - "lint:html": "node ./scripts/lint-html.js 'src/**/*.html'", + "lint:html": "htmlhint src/**/*.html", "lint": "npm run lint:js && npm run lint:html" }, "dependencies": { diff --git a/scripts/lint-html.js b/scripts/lint-html.js deleted file mode 100644 index d8891e836..000000000 --- a/scripts/lint-html.js +++ /dev/null @@ -1,36 +0,0 @@ -#!/usr/bin/env node - -const { promisify } = require("util"); -const fs = require("fs"); -const mkdtemp = promisify(fs.mkdtemp); -const path = require("path"); -const os = require("os"); -const shell = require("shelljs"); - -(async function() { - function lintFile(tempDir, arg, file) { - const out = path.join(tempDir, file); - shell.mkdir("-p", path.dirname(out)); - shell.sed(/<%.+%>/, "", file).to(out); - const result = shell.exec(`node_modules/.bin/htmlhint ${arg} --config=.htmlhintrc ${out}`); - return result.code; - } - - let result = 0; - if (process.argv.length > 2) { - const tempDir = await mkdtemp(path.join(os.tmpdir(), "lint-html-")); - let files; - let arg = ""; - if (process.argv.length === 4) { - arg = process.argv[2]; - files = process.argv[3]; - } else { - files = process.argv[2]; - } - const results = shell.ls(files).map(lintFile.bind(null, tempDir, arg)); - result = results.reduce((a, r) => a + r, 0); - shell.rm("-r", tempDir); - } - - shell.exit(result); -})(); -- GitLab