Commits (10)
# html-validate changelog
### [5.0.1](https://gitlab.com/html-validate/html-validate/compare/v5.0.0...v5.0.1) (2021-06-27)
### Bug Fixes
- custom log callback for `compatibilityCheck` ([cbd2226](https://gitlab.com/html-validate/html-validate/commit/cbd22269ce2a5debb87c785b9db8740d4874ab4e))
### Dependency upgrades
- **deps:** update dependency @html-validate/stylish to v2 ([ab0b1f9](https://gitlab.com/html-validate/html-validate/commit/ab0b1f9d394c7b97350e6c1826fc8ee94d065015))
## [5.0.0](https://gitlab.com/html-validate/html-validate/compare/v4.14.0...v5.0.0) (2021-06-27)
### ⚠ BREAKING CHANGES
......
{
"name": "html-validate",
"version": "5.0.0",
"version": "5.0.1",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"version": "5.0.0",
"version": "5.0.1",
"license": "MIT",
"dependencies": {
"@babel/code-frame": "^7.10.0",
"@html-validate/stylish": "^1.0.0",
"@html-validate/stylish": "^2.0.0",
"@sidvind/better-ajv-errors": "^0.9.0",
"acorn-walk": "^8.0.0",
"ajv": "^8.0.0",
......@@ -30,13 +30,13 @@
"@babel/core": "7.14.6",
"@babel/preset-env": "7.14.7",
"@commitlint/cli": "12.1.4",
"@html-validate/commitlint-config": "1.3.1",
"@html-validate/commitlint-config": "2.0.0",
"@html-validate/eslint-config": "4.4.3",
"@html-validate/eslint-config-jest": "4.4.2",
"@html-validate/eslint-config-typescript": "4.4.0",
"@html-validate/jest-config": "2.2.0",
"@html-validate/prettier-config": "1.1.0",
"@html-validate/semantic-release-config": "2.0.0",
"@html-validate/prettier-config": "2.0.0",
"@html-validate/semantic-release-config": "2.0.1",
"@lodder/grunt-postcss": "3.0.1",
"@rollup/plugin-json": "4.1.0",
"@rollup/plugin-replace": "2.4.2",
......@@ -82,7 +82,7 @@
"minimatch": "3.0.4",
"npm-pkg-lint": "1.4.0",
"postcss": "8.3.5",
"prettier": "2.3.1",
"prettier": "2.3.2",
"rollup": "2.52.3",
"rollup-plugin-copy": "3.4.0",
"rollup-plugin-dts": "3.0.2",
......@@ -2247,9 +2247,9 @@
}
},
"node_modules/@html-validate/commitlint-config": {
"version": "1.3.1",
"resolved": "https://registry.npmjs.org/@html-validate/commitlint-config/-/commitlint-config-1.3.1.tgz",
"integrity": "sha512-FsKUdCvbi4dFDZtRAdGphp8P/X5nxMfCjJOcxcAYeWa11IT9fLICDB2hhHSg8F9V3jyOB6XmmQecdrOqNIAadg==",
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/@html-validate/commitlint-config/-/commitlint-config-2.0.0.tgz",
"integrity": "sha512-ykYlM2qvVYWe57xqa3muo3nsipfj7TDa/Q0qtw5n3PIDzEQ8YfuSIAHKQ6R8jCO1eblMbbwd4CgWme7sRMTfpQ==",
"dev": true,
"hasInstallScript": true,
"dependencies": {
......@@ -2260,7 +2260,7 @@
"commitlint-config": "install.js"
},
"engines": {
"node": ">= 10.0"
"node": ">= 12.0"
}
},
"node_modules/@html-validate/eslint-config": {
......@@ -2412,27 +2412,27 @@
}
},
"node_modules/@html-validate/prettier-config": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/@html-validate/prettier-config/-/prettier-config-1.1.0.tgz",
"integrity": "sha512-EQYg74yXM4Q+YJKY4cWDyDIa3qDLJ8y/v+Fo6I+K1rGQRKGZytQ07JguYqF7E2URytd5srJIj1i6+Y+xAtj0XA==",
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/@html-validate/prettier-config/-/prettier-config-2.0.0.tgz",
"integrity": "sha512-TjQg4SgL7cCJCG+lIvzLCHrNvF22zdILXKCzoJDOl4HqRGbz563hAh/I8yIrVpvlLJpMwov2W58i83dlyxw/Ww==",
"dev": true,
"engines": {
"node": ">= 8.5"
"node": ">= 12.0"
},
"peerDependencies": {
"prettier": ">= 1 || >= 2"
}
},
"node_modules/@html-validate/semantic-release-config": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/@html-validate/semantic-release-config/-/semantic-release-config-2.0.0.tgz",
"integrity": "sha512-IzCPx07w9/FezHLw4GqHJtBPJrQx689U+ZDMspLUxTuX4NZzeg/UjtkJ1yUNA5ykEMK7t+BqdcFCftcaSVjIKA==",
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/@html-validate/semantic-release-config/-/semantic-release-config-2.0.1.tgz",
"integrity": "sha512-EudAGAbuQqQ7GqsJmcBABJbw+H4iJt0P5jxlgSi1otORMOuHPXE/WVgiarUPw412UNRZr78GZwoCE2HRmwWS1Q==",
"dev": true,
"dependencies": {
"@semantic-release/changelog": "5.0.1",
"@semantic-release/exec": "5.0.0",
"@semantic-release/git": "9.0.0",
"@semantic-release/gitlab": "6.2.0",
"@semantic-release/gitlab": "6.2.1",
"@semantic-release/npm": "7.1.3",
"@semantic-release/release-notes-generator": "9.0.3",
"conventional-changelog-conventionalcommits": "4.6.0",
......@@ -2507,16 +2507,15 @@
}
},
"node_modules/@html-validate/stylish": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/@html-validate/stylish/-/stylish-1.0.0.tgz",
"integrity": "sha512-NW6TZ7/GA+Z+1fNGDqkxutHQEsDivuN6ZM9ALMqSsDuO1QHJ4Ws1hAecwzvDezwSEXArLcqXd1RqZCYi3GA6KQ==",
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/@html-validate/stylish/-/stylish-2.0.0.tgz",
"integrity": "sha512-lmI4sUZGHpxfWyPtKKrcIbwBbDLXSb+XPEYS1USc46ZzXx/VsnsVqbk3pPIUdEPhd4v72xGS8HDAy/+8wZzlbQ==",
"dependencies": {
"chalk": "^4.0.0",
"strip-ansi": "^6.0.0",
"kleur": "^4.0.0",
"text-table": "^0.2.0"
},
"engines": {
"node": ">= 10.0"
"node": ">= 12.0"
}
},
"node_modules/@istanbuljs/load-nyc-config": {
......@@ -3440,9 +3439,9 @@
"dev": true
},
"node_modules/@semantic-release/gitlab": {
"version": "6.2.0",
"resolved": "https://registry.npmjs.org/@semantic-release/gitlab/-/gitlab-6.2.0.tgz",
"integrity": "sha512-yobNW2YpQScmmuAUQGkSY9y3NXINaB7IOM11Qod4ewIKhNRQoRkHf7mjKKYmCJY+COFEu0RCt4xvBo7hlYfihw==",
"version": "6.2.1",
"resolved": "https://registry.npmjs.org/@semantic-release/gitlab/-/gitlab-6.2.1.tgz",
"integrity": "sha512-hbUzMRf9/ZsHRoWCNYs1NM9Au8X2DQzBexnWavU24GVWZw3r15aEZl+lY0fTbcRdQtgXZxOH3TDiW5fuTbvb9A==",
"dev": true,
"dependencies": {
"@semantic-release/error": "^2.2.0",
......@@ -13682,6 +13681,19 @@
"node": ">= 12.0"
}
},
"node_modules/npm-pkg-lint/node_modules/@html-validate/stylish": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/@html-validate/stylish/-/stylish-1.0.1.tgz",
"integrity": "sha512-fx1eJv6N00JYxYXxR3yP53jm33ZBoLGEwv2x6Q2KIg7Uz3I9/+Bpl5tJtja7CdxD+ueq1SDNhsiYZ4KDwuHe8Q==",
"dev": true,
"dependencies": {
"kleur": "^4.0.0",
"text-table": "^0.2.0"
},
"engines": {
"node": ">= 10.0"
}
},
"node_modules/npm-pkg-lint/node_modules/argparse": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz",
......@@ -17768,9 +17780,9 @@
}
},
"node_modules/prettier": {
"version": "2.3.1",
"resolved": "https://registry.npmjs.org/prettier/-/prettier-2.3.1.tgz",
"integrity": "sha512-p+vNbgpLjif/+D+DwAZAbndtRrR0md0MwfmOVN9N+2RgyACMT+7tfaRnT+WDPkqnuVwleyuBIG2XBxKDme3hPA==",
"version": "2.3.2",
"resolved": "https://registry.npmjs.org/prettier/-/prettier-2.3.2.tgz",
"integrity": "sha512-lnJzDfJ66zkMy58OL5/NY5zp70S7Nz6KqcKkXYzn2tMVrNxvbqaBpg7H3qHaLxCJ5lNMsGuM8+ohS7cZrthdLQ==",
"dev": true,
"bin": {
"prettier": "bin-prettier.js"
......@@ -19614,6 +19626,7 @@
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.0.tgz",
"integrity": "sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w==",
"dev": true,
"dependencies": {
"ansi-regex": "^5.0.0"
},
......@@ -19625,6 +19638,7 @@
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.0.tgz",
"integrity": "sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==",
"dev": true,
"engines": {
"node": ">=8"
}
......@@ -22586,9 +22600,9 @@
}
},
"@html-validate/commitlint-config": {
"version": "1.3.1",
"resolved": "https://registry.npmjs.org/@html-validate/commitlint-config/-/commitlint-config-1.3.1.tgz",
"integrity": "sha512-FsKUdCvbi4dFDZtRAdGphp8P/X5nxMfCjJOcxcAYeWa11IT9fLICDB2hhHSg8F9V3jyOB6XmmQecdrOqNIAadg==",
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/@html-validate/commitlint-config/-/commitlint-config-2.0.0.tgz",
"integrity": "sha512-ykYlM2qvVYWe57xqa3muo3nsipfj7TDa/Q0qtw5n3PIDzEQ8YfuSIAHKQ6R8jCO1eblMbbwd4CgWme7sRMTfpQ==",
"dev": true,
"requires": {
"@commitlint/config-conventional": "^12.0.0",
......@@ -22691,22 +22705,22 @@
}
},
"@html-validate/prettier-config": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/@html-validate/prettier-config/-/prettier-config-1.1.0.tgz",
"integrity": "sha512-EQYg74yXM4Q+YJKY4cWDyDIa3qDLJ8y/v+Fo6I+K1rGQRKGZytQ07JguYqF7E2URytd5srJIj1i6+Y+xAtj0XA==",
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/@html-validate/prettier-config/-/prettier-config-2.0.0.tgz",
"integrity": "sha512-TjQg4SgL7cCJCG+lIvzLCHrNvF22zdILXKCzoJDOl4HqRGbz563hAh/I8yIrVpvlLJpMwov2W58i83dlyxw/Ww==",
"dev": true,
"requires": {}
},
"@html-validate/semantic-release-config": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/@html-validate/semantic-release-config/-/semantic-release-config-2.0.0.tgz",
"integrity": "sha512-IzCPx07w9/FezHLw4GqHJtBPJrQx689U+ZDMspLUxTuX4NZzeg/UjtkJ1yUNA5ykEMK7t+BqdcFCftcaSVjIKA==",
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/@html-validate/semantic-release-config/-/semantic-release-config-2.0.1.tgz",
"integrity": "sha512-EudAGAbuQqQ7GqsJmcBABJbw+H4iJt0P5jxlgSi1otORMOuHPXE/WVgiarUPw412UNRZr78GZwoCE2HRmwWS1Q==",
"dev": true,
"requires": {
"@semantic-release/changelog": "5.0.1",
"@semantic-release/exec": "5.0.0",
"@semantic-release/git": "9.0.0",
"@semantic-release/gitlab": "6.2.0",
"@semantic-release/gitlab": "6.2.1",
"@semantic-release/npm": "7.1.3",
"@semantic-release/release-notes-generator": "9.0.3",
"conventional-changelog-conventionalcommits": "4.6.0",
......@@ -22753,12 +22767,11 @@
}
},
"@html-validate/stylish": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/@html-validate/stylish/-/stylish-1.0.0.tgz",
"integrity": "sha512-NW6TZ7/GA+Z+1fNGDqkxutHQEsDivuN6ZM9ALMqSsDuO1QHJ4Ws1hAecwzvDezwSEXArLcqXd1RqZCYi3GA6KQ==",
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/@html-validate/stylish/-/stylish-2.0.0.tgz",
"integrity": "sha512-lmI4sUZGHpxfWyPtKKrcIbwBbDLXSb+XPEYS1USc46ZzXx/VsnsVqbk3pPIUdEPhd4v72xGS8HDAy/+8wZzlbQ==",
"requires": {
"chalk": "^4.0.0",
"strip-ansi": "^6.0.0",
"kleur": "^4.0.0",
"text-table": "^0.2.0"
}
},
......@@ -23486,9 +23499,9 @@
}
},
"@semantic-release/gitlab": {
"version": "6.2.0",
"resolved": "https://registry.npmjs.org/@semantic-release/gitlab/-/gitlab-6.2.0.tgz",
"integrity": "sha512-yobNW2YpQScmmuAUQGkSY9y3NXINaB7IOM11Qod4ewIKhNRQoRkHf7mjKKYmCJY+COFEu0RCt4xvBo7hlYfihw==",
"version": "6.2.1",
"resolved": "https://registry.npmjs.org/@semantic-release/gitlab/-/gitlab-6.2.1.tgz",
"integrity": "sha512-hbUzMRf9/ZsHRoWCNYs1NM9Au8X2DQzBexnWavU24GVWZw3r15aEZl+lY0fTbcRdQtgXZxOH3TDiW5fuTbvb9A==",
"dev": true,
"requires": {
"@semantic-release/error": "^2.2.0",
......@@ -33323,6 +33336,16 @@
"tmp": "^0.2.0"
},
"dependencies": {
"@html-validate/stylish": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/@html-validate/stylish/-/stylish-1.0.1.tgz",
"integrity": "sha512-fx1eJv6N00JYxYXxR3yP53jm33ZBoLGEwv2x6Q2KIg7Uz3I9/+Bpl5tJtja7CdxD+ueq1SDNhsiYZ4KDwuHe8Q==",
"dev": true,
"requires": {
"kleur": "^4.0.0",
"text-table": "^0.2.0"
}
},
"argparse": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz",
......@@ -34332,9 +34355,9 @@
"dev": true
},
"prettier": {
"version": "2.3.1",
"resolved": "https://registry.npmjs.org/prettier/-/prettier-2.3.1.tgz",
"integrity": "sha512-p+vNbgpLjif/+D+DwAZAbndtRrR0md0MwfmOVN9N+2RgyACMT+7tfaRnT+WDPkqnuVwleyuBIG2XBxKDme3hPA==",
"version": "2.3.2",
"resolved": "https://registry.npmjs.org/prettier/-/prettier-2.3.2.tgz",
"integrity": "sha512-lnJzDfJ66zkMy58OL5/NY5zp70S7Nz6KqcKkXYzn2tMVrNxvbqaBpg7H3qHaLxCJ5lNMsGuM8+ohS7cZrthdLQ==",
"dev": true
},
"prettier-linter-helpers": {
......@@ -35790,6 +35813,7 @@
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.0.tgz",
"integrity": "sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w==",
"dev": true,
"requires": {
"ansi-regex": "^5.0.0"
},
......@@ -35797,7 +35821,8 @@
"ansi-regex": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.0.tgz",
"integrity": "sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg=="
"integrity": "sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==",
"dev": true
}
}
},
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`stylish formatter should generate output 1`] = `
"</></>
</>first.html</>
</> <dim>1:6</> <red>error</> An error <dim>foo</></>
</> <dim>2:5</> <yellow>warning</> A warning <dim>bar</></>
</></>
</>second.html</>
</> <dim>1:4</> <red>error</> Lorem ipsum is not allowed <dim>no-lorem-ipsum</></>
</></>
</><red><bold>✖ 3 problems (2 errors, 1 warning)</></></>
</><red><bold></></></>
"</>
first.html
<dim>1:6</> <red>error</> An error <dim>foo</>
<dim>2:5</> <yellow>warning</> A warning <dim>bar</>
second.html
<dim>1:4</> <red>error</> Lorem ipsum is not allowed <dim>no-lorem-ipsum</>
<red><bold>✖ 3 problems (2 errors, 1 warning)
</></></>
<bold>More information</>:
https://example.net/rule/foo.html
https://example.net/rule/bar.html
......@@ -20,13 +20,13 @@ exports[`stylish formatter should generate output 1`] = `
`;
exports[`stylish formatter should handle edge cases 1`] = `
"</></>
</>edge-cases.html</>
</> <dim>1:1</> <yellow>warning</> Has invalid severity <dim>invalid-severity</></>
</> <dim>2:2</> <red>error</> Escape <script language=\\"jabbascript\\"> & <span id='foo'> <dim>special-characters</></>
</></>
</><red><bold>✖ 2 problems (1 error, 1 warning)</></></>
</><red><bold></></></>"
"</>
edge-cases.html
<dim>1:1</> <yellow>warning</> Has invalid severity <dim>invalid-severity</>
<dim>2:2</> <red>error</> Escape <script language=\\"jabbascript\\"> & <span id='foo'> <dim>special-characters</>
<red><bold>✖ 2 problems (1 error, 1 warning)
</></></>"
`;
exports[`stylish formatter should handle empty messages 1`] = `""`;
......@@ -34,23 +34,23 @@ exports[`stylish formatter should handle empty messages 1`] = `""`;
exports[`stylish formatter should handle empty result 1`] = `""`;
exports[`stylish formatter should handle missing rule url 1`] = `
"</></>
</>missing-url.html</>
</> <dim>1:6</> <red>error</> An error <dim>foo</></>
</> <dim>2:5</> <yellow>warning</> A warning <dim>bar</></>
</></>
</><red><bold>✖ 2 problems (2 errors, 0 warnings)</></></>
</><red><bold></></></>"
"</>
missing-url.html
<dim>1:6</> <red>error</> An error <dim>foo</>
<dim>2:5</> <yellow>warning</> A warning <dim>bar</>
<red><bold>✖ 2 problems (2 errors, 0 warnings)
</></></>"
`;
exports[`stylish formatter should handle missing source 1`] = `
"</></>
</>missing-source.html</>
</> <dim>1:6</> <red>error</> An error <dim>foo</></>
</> <dim>2:5</> <yellow>warning</> A warning <dim>bar</></>
</></>
</><red><bold>✖ 2 problems (2 errors, 0 warnings)</></></>
</><red><bold></></></>
"</>
missing-source.html
<dim>1:6</> <red>error</> An error <dim>foo</>
<dim>2:5</> <yellow>warning</> A warning <dim>bar</>
<red><bold>✖ 2 problems (2 errors, 0 warnings)
</></></>
<bold>More information</>:
https://example.net/rule/foo.html
https://example.net/rule/bar.html
......
......@@ -36,6 +36,14 @@ it("should not warn when using supported html-validate version", () => {
expect(log).not.toHaveBeenCalled();
});
it("should use custom callback", () => {
expect.assertions(2);
const spy = jest.fn();
compatibilityCheck("my-plugin", peerDependency, { version: "1.2.3", logger: spy });
expect(spy).toHaveBeenCalledWith(expect.stringContaining("my-plugin requires"));
expect(log).not.toHaveBeenCalled();
});
it("should return true if version is supported", () => {
expect.assertions(1);
const result = compatibilityCheck("my-plugin", peerDependency, {
......
......@@ -8,11 +8,18 @@ export interface CompatibilityOptions {
/** Use this version number instead of running version. Default: running version */
version: string;
/** Use custom logging callback. Default: `console.error` */
logger(message: string): void;
}
const defaults: CompatibilityOptions = {
silent: false,
version,
logger(text: string): void {
/* eslint-disable-next-line no-console */
console.error(kleur.red(text));
},
};
/**
......@@ -28,7 +35,7 @@ export function compatibilityCheck(
declared: string,
options?: Partial<CompatibilityOptions>
): boolean {
const { silent, version: current } = { ...defaults, ...options };
const { silent, version: current, logger } = { ...defaults, ...options };
const valid = satisfies(current, declared);
if (valid || silent) {
return valid;
......@@ -41,8 +48,7 @@ export function compatibilityCheck(
"-----------------------------------------------------------------------------------------------------",
].join("\n");
/* eslint-disable-next-line no-console */
console.error(kleur.red(text));
logger(text);
return false;
}