...
 
Commits (14)
......@@ -105,10 +105,11 @@ Docs:
script:
- npm test
- npm run build
- npm run compatibility
Node 8.x (LTS):
<<: *compat
image: node:8
image: node:8.17
before_script:
- npm install
......@@ -116,10 +117,14 @@ Node 10.x (LTS):
<<: *compat
image: node:10
Node 12.x (current):
Node 12.x (LTS):
<<: *compat
image: node:12
Node 13.x (current):
<<: *compat
image: node:13
Release:
stage: release
only:
......
# html-validate changelog
## [2.8.1](https://gitlab.com/html-validate/html-validate/compare/v2.8.0...v2.8.1) (2020-01-06)
### Bug Fixes
- **cli:** create output directory as needed ([b5569f3](https://gitlab.com/html-validate/html-validate/commit/b5569f3abd47c02348f2aa31a430e1ab31ba65a5))
- **meta:** load metadata with `readFile` instead of `require` ([c5de95b](https://gitlab.com/html-validate/html-validate/commit/c5de95b8a41707bd58a688f130e8beecbece077a))
# [2.8.0](https://gitlab.com/html-validate/html-validate/compare/v2.7.0...v2.8.0) (2020-01-02)
### Features
......
This diff is collapsed.
{
"name": "html-validate",
"version": "2.8.0",
"version": "2.8.1",
"description": "html linter",
"keywords": [
"html",
......@@ -40,6 +40,7 @@
"build": "tsc",
"build:docs": "grunt docs",
"clean": "rm -rf build public",
"compatibility": "scripts/compatibility.sh",
"commitlint": "commitlint",
"debug": "node --inspect ./node_modules/.bin/jest --runInBand --watch --no-coverage",
"eslint": "eslint *.js '{docs,elements,src}/**/*.{js,ts}'",
......@@ -98,11 +99,11 @@
"devDependencies": {
"@babel/core": "7.7.7",
"@babel/preset-env": "7.7.7",
"@commitlint/cli": "8.2.0",
"@commitlint/cli": "8.3.4",
"@html-validate/commitlint-config": "1.0.1",
"@html-validate/eslint-config": "1.0.5",
"@html-validate/eslint-config": "1.0.6",
"@html-validate/prettier-config": "1.0.0",
"@html-validate/semantic-release-config": "1.0.3",
"@html-validate/semantic-release-config": "1.0.4",
"@types/babel__code-frame": "7.0.1",
"@types/estree": "0.0.41",
"@types/glob": "7.1.1",
......@@ -110,7 +111,7 @@
"@types/jest": "24.0.25",
"@types/json-merge-patch": "0.0.4",
"@types/minimist": "1.2.0",
"@types/node": "11.15.3",
"@types/node": "11.15.4",
"autoprefixer": "9.7.3",
"babelify": "10.0.0",
"bootstrap-sass": "3.4.1",
......@@ -121,7 +122,7 @@
"dgeni-packages": "0.28.2",
"eslint-plugin-array-func": "3.1.3",
"eslint-plugin-import": "2.19.1",
"eslint-plugin-jest": "23.2.0",
"eslint-plugin-jest": "23.3.0",
"eslint-plugin-node": "11.0.0",
"eslint-plugin-security": "1.4.0",
"eslint-plugin-sonarjs": "0.5.0",
......@@ -145,7 +146,7 @@
"minimatch": "3.0.4",
"mkdirp": "0.5.1",
"prettier": "1.19.1",
"sass": "1.24.0",
"sass": "1.24.2",
"semantic-release": "15.14.0",
"serve-static": "1.14.1",
"strip-ansi": "6.0.0",
......
#!/bin/bash
cd $(dirname $0)/..
echo "Testing if html-validate can successfully validate a file"
./bin/html-validate.js test-files/elements/table-valid.html
if [[ $? != 0 ]]; then
echo "Compatibility test failed, expected command to exit with zero status"
exit 1
fi
echo "Testing if html-validate can successfully validate a invalid file"
./bin/html-validate.js test-files/elements/table-invalid.html > /dev/null
if [[ $? = 0 ]]; then
echo "Compatibility test failed, expected command to exit with non-zero status"
exit 1
fi
echo "Testing if html-validate will save report to file"
./bin/html-validate.js -f json=temp/compatibility/report.json test-files/elements/table-valid.html
if [[ $? != 0 ]]; then
echo "Compatibility test failed, expected command to exit with zero status"
exit 1
fi
if [[ "$(cat temp/compatibility/report.json)" != "[]" ]]; then
echo "Compatibility test failed, expected command to write report to file"
exit 1
fi
......@@ -13,9 +13,11 @@ jest.mock("../formatters/json", () => {
return (report: Report) => jsonFormatter(report);
});
const mkdirSync = jest.fn();
const writeFileSync = jest.fn();
jest.mock("fs", () => {
return {
mkdirSync: (...args: any[]) => mkdirSync(...args),
writeFileSync: (...args: any[]) => writeFileSync(...args),
};
});
......@@ -65,8 +67,9 @@ describe("cli/formatters", () => {
});
it("should redirect output", () => {
const wrapped = cli.getFormatter("text=foo.txt");
const wrapped = cli.getFormatter("text=mydir/foo.txt");
wrapped(report);
expect(writeFileSync).toHaveBeenCalledWith("foo.txt", "", "utf-8");
expect(mkdirSync).toHaveBeenCalledWith("mydir", { recursive: true });
expect(writeFileSync).toHaveBeenCalledWith("mydir/foo.txt", "", "utf-8");
});
});
import fs from "fs";
import path from "path";
import { Formatter } from "../formatters";
import { Report, Result } from "../reporter";
......@@ -11,6 +12,7 @@ function wrap(
return (results: Result[]) => {
const output = formatter(results);
if (dst) {
fs.mkdirSync(path.dirname(dst), { recursive: true });
fs.writeFileSync(dst, output, "utf-8");
return null;
} else {
......
import Ajv from "ajv";
import deepmerge from "deepmerge";
import fs from "fs";
import jsonMergePatch from "json-merge-patch";
import { HtmlElement } from "../dom";
import { SchemaValidationError, UserError } from "../error";
......@@ -101,7 +102,8 @@ export class MetaTable {
public loadFromFile(filename: string): void {
let json;
try {
json = require(filename);
const data = fs.readFileSync(filename, "utf-8");
json = JSON.parse(data);
} catch (err) {
throw new UserError(
`Failed to load element metadata from "${filename}"`,
......
import path from "path";
import { Config, Severity } from "./config";
import { Location } from "./context";
import { HtmlElement } from "./dom";
......@@ -27,7 +28,7 @@ describe("rule base class", () => {
reporter = new Reporter();
reporter.add = jest.fn();
meta = new MetaTable();
meta.loadFromFile("../../elements/html5.json");
meta.loadFromFile(path.join(__dirname, "../elements/html5.json"));
rule = new MockRule({});
rule.name = "mock-rule";
......