...
 
Commits (7)
# html-validate changelog
## [2.4.2](https://gitlab.com/html-validate/html-validate/compare/v2.4.1...v2.4.2) (2019-12-05)
### Bug Fixes
- **config:** handle exceptions from loading plugin ([3aec3f3](https://gitlab.com/html-validate/html-validate/commit/3aec3f3ff019f5e3815d4b04e66ee610469e815d)), closes [#55](https://gitlab.com/html-validate/html-validate/issues/55)
## [2.4.1](https://gitlab.com/html-validate/html-validate/compare/v2.4.0...v2.4.1) (2019-12-02)
### Bug Fixes
......
{
"name": "html-validate",
"version": "2.4.1",
"version": "2.4.2",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
......@@ -4219,9 +4219,9 @@
}
},
"@semantic-release/release-notes-generator": {
"version": "7.3.4",
"resolved": "https://registry.npmjs.org/@semantic-release/release-notes-generator/-/release-notes-generator-7.3.4.tgz",
"integrity": "sha512-d5YlpzuWrsq1UrFeOgv6vIb11R0ICRRJwNzSM4NpljF8hZBYxaaNOw3FbfSufgOLiyvLznhh3/91QoRVPKVwqw==",
"version": "7.3.5",
"resolved": "https://registry.npmjs.org/@semantic-release/release-notes-generator/-/release-notes-generator-7.3.5.tgz",
"integrity": "sha512-LGjgPBGjjmjap/76O0Md3wc04Y7IlLnzZceLsAkcYRwGQdRPTTFUJKqDQTuieWTs7zfHzQoZqsqPfFxEN+g2+Q==",
"dev": true,
"requires": {
"conventional-changelog-angular": "^5.0.0",
......@@ -4356,9 +4356,9 @@
}
},
"resolve": {
"version": "1.12.2",
"resolved": "https://registry.npmjs.org/resolve/-/resolve-1.12.2.tgz",
"integrity": "sha512-cAVTI2VLHWYsGOirfeYVVQ7ZDejtQ9fp4YhYckWDEkFfqbVjaT11iM8k6xSAfGFMM+gDpZjMnFssPu8we+mqFw==",
"version": "1.13.1",
"resolved": "https://registry.npmjs.org/resolve/-/resolve-1.13.1.tgz",
"integrity": "sha512-CxqObCX8K8YtAhOBRg+lrcdn+LK+WYOS8tSjqSFbjtrI5PnS63QPhZl4+yKfrU9tdsbMu9Anr/amegT87M9Z6w==",
"dev": true,
"requires": {
"path-parse": "^1.0.6"
......@@ -4629,12 +4629,12 @@
"dev": true
},
"@typescript-eslint/eslint-plugin": {
"version": "2.9.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-2.9.0.tgz",
"integrity": "sha512-98rfOt3NYn5Gr9wekTB8TexxN6oM8ZRvYuphPs1Atfsy419SDLYCaE30aJkRiiTCwGEY98vOhFsEVm7Zs4toQQ==",
"version": "2.10.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-2.10.0.tgz",
"integrity": "sha512-rT51fNLW0u3fnDGnAHVC5nu+Das+y2CpW10yqvf6/j5xbuUV3FxA3mBaIbM24CXODXjbgUznNb4Kg9XZOUxKAw==",
"dev": true,
"requires": {
"@typescript-eslint/experimental-utils": "2.9.0",
"@typescript-eslint/experimental-utils": "2.10.0",
"eslint-utils": "^1.4.3",
"functional-red-black-tree": "^1.0.1",
"regexpp": "^3.0.0",
......@@ -4642,20 +4642,20 @@
},
"dependencies": {
"@typescript-eslint/experimental-utils": {
"version": "2.9.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-2.9.0.tgz",
"integrity": "sha512-0lOLFdpdJsCMqMSZT7l7W2ta0+GX8A3iefG3FovJjrX+QR8y6htFlFdU7aOVPL6pDvt6XcsOb8fxk5sq+girTw==",
"version": "2.10.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-2.10.0.tgz",
"integrity": "sha512-FZhWq6hWWZBP76aZ7bkrfzTMP31CCefVIImrwP3giPLcoXocmLTmr92NLZxuIcTL4GTEOE33jQMWy9PwelL+yQ==",
"dev": true,
"requires": {
"@types/json-schema": "^7.0.3",
"@typescript-eslint/typescript-estree": "2.9.0",
"@typescript-eslint/typescript-estree": "2.10.0",
"eslint-scope": "^5.0.0"
}
},
"@typescript-eslint/typescript-estree": {
"version": "2.9.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-2.9.0.tgz",
"integrity": "sha512-v6btSPXEWCP594eZbM+JCXuFoXWXyF/z8kaSBSdCb83DF+Y7+xItW29SsKtSULgLemqJBT+LpT+0ZqdfH7QVmA==",
"version": "2.10.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-2.10.0.tgz",
"integrity": "sha512-oOYnplddQNm/LGVkqbkAwx4TIBuuZ36cAQq9v3nFIU9FmhemHuVzAesMSXNQDdAzCa5bFgCrfD3JWhYVKlRN2g==",
"dev": true,
"requires": {
"debug": "^4.1.1",
......@@ -4759,32 +4759,32 @@
}
},
"@typescript-eslint/parser": {
"version": "2.9.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-2.9.0.tgz",
"integrity": "sha512-fJ+dNs3CCvEsJK2/Vg5c2ZjuQ860ySOAsodDPwBaVlrGvRN+iCNC8kUfLFL8cT49W4GSiLPa/bHiMjYXA7EhKQ==",
"version": "2.10.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-2.10.0.tgz",
"integrity": "sha512-wQNiBokcP5ZsTuB+i4BlmVWq6o+oAhd8en2eSm/EE9m7BgZUIfEeYFd6z3S+T7bgNuloeiHA1/cevvbBDLr98g==",
"dev": true,
"requires": {
"@types/eslint-visitor-keys": "^1.0.0",
"@typescript-eslint/experimental-utils": "2.9.0",
"@typescript-eslint/typescript-estree": "2.9.0",
"@typescript-eslint/experimental-utils": "2.10.0",
"@typescript-eslint/typescript-estree": "2.10.0",
"eslint-visitor-keys": "^1.1.0"
},
"dependencies": {
"@typescript-eslint/experimental-utils": {
"version": "2.9.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-2.9.0.tgz",
"integrity": "sha512-0lOLFdpdJsCMqMSZT7l7W2ta0+GX8A3iefG3FovJjrX+QR8y6htFlFdU7aOVPL6pDvt6XcsOb8fxk5sq+girTw==",
"version": "2.10.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-2.10.0.tgz",
"integrity": "sha512-FZhWq6hWWZBP76aZ7bkrfzTMP31CCefVIImrwP3giPLcoXocmLTmr92NLZxuIcTL4GTEOE33jQMWy9PwelL+yQ==",
"dev": true,
"requires": {
"@types/json-schema": "^7.0.3",
"@typescript-eslint/typescript-estree": "2.9.0",
"@typescript-eslint/typescript-estree": "2.10.0",
"eslint-scope": "^5.0.0"
}
},
"@typescript-eslint/typescript-estree": {
"version": "2.9.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-2.9.0.tgz",
"integrity": "sha512-v6btSPXEWCP594eZbM+JCXuFoXWXyF/z8kaSBSdCb83DF+Y7+xItW29SsKtSULgLemqJBT+LpT+0ZqdfH7QVmA==",
"version": "2.10.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-2.10.0.tgz",
"integrity": "sha512-oOYnplddQNm/LGVkqbkAwx4TIBuuZ36cAQq9v3nFIU9FmhemHuVzAesMSXNQDdAzCa5bFgCrfD3JWhYVKlRN2g==",
"dev": true,
"requires": {
"debug": "^4.1.1",
......@@ -26116,9 +26116,9 @@
"dev": true
},
"typescript": {
"version": "3.7.2",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-3.7.2.tgz",
"integrity": "sha512-ml7V7JfiN2Xwvcer+XAf2csGO1bPBdRbFCkYBczNZggrBZ9c7G3riSUeJmqEU5uOtXNPMhE3n+R4FA/3YOAWOQ==",
"version": "3.7.3",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-3.7.3.tgz",
"integrity": "sha512-Mcr/Qk7hXqFBXMN7p7Lusj1ktCBydylfQM/FZCk5glCNQJrCUKPkMHdo9R0MTFWsC/4kPFvDS0fDPvukfCkFsw==",
"dev": true
},
"uglify-js": {
......
{
"name": "html-validate",
"version": "2.4.1",
"version": "2.4.2",
"description": "html linter",
"keywords": [
"html",
......@@ -152,7 +152,7 @@
"@semantic-release/git": "7.0.18",
"@semantic-release/gitlab": "4.0.4",
"@semantic-release/npm": "5.3.4",
"@semantic-release/release-notes-generator": "7.3.4",
"@semantic-release/release-notes-generator": "7.3.5",
"@types/babel__code-frame": "7.0.1",
"@types/estree": "0.0.40",
"@types/glob": "7.1.1",
......@@ -161,8 +161,8 @@
"@types/json-merge-patch": "0.0.4",
"@types/minimist": "1.2.0",
"@types/node": "11.15.3",
"@typescript-eslint/eslint-plugin": "2.9.0",
"@typescript-eslint/parser": "2.9.0",
"@typescript-eslint/eslint-plugin": "2.10.0",
"@typescript-eslint/parser": "2.10.0",
"autoprefixer": "9.7.3",
"babelify": "10.0.0",
"bootstrap-sass": "3.4.1",
......@@ -204,7 +204,7 @@
"ts-jest": "24.2.0",
"tslint": "5.20.1",
"tslint-config-prettier": "1.18.0",
"typescript": "3.7.2"
"typescript": "3.7.3"
},
"jest": {
"collectCoverage": true,
......
......@@ -312,13 +312,20 @@ export class Config {
private loadPlugins(plugins: string[]): Plugin[] {
return plugins.map((moduleName: string) => {
// eslint-disable-next-line security/detect-non-literal-require
const plugin = require(moduleName.replace(
"<rootDir>",
this.rootDir
)) as Plugin;
plugin.name = plugin.name || moduleName;
return plugin;
try {
// eslint-disable-next-line security/detect-non-literal-require
const plugin = require(moduleName.replace(
"<rootDir>",
this.rootDir
)) as Plugin;
plugin.name = plugin.name || moduleName;
return plugin;
} catch (err) {
throw new ConfigError(
`Failed to load plugin "${moduleName}": ${err}`,
err
);
}
});
}
......
import { Config } from "../config";
import { ConfigError } from "../config/error";
import { Source } from "../context";
import { Engine } from "../engine";
import { EventHandler } from "../event";
......@@ -28,6 +29,15 @@ describe("Plugin", () => {
mockPlugin = require("mock-plugin");
});
it("should throw ConfigError when loading plugin fails", () => {
expect.assertions(2);
const loadConfig = (): void => {
Config.fromObject({ plugins: ["missing-plugin"] });
};
expect(loadConfig).toThrow(ConfigError);
expect(loadConfig).toThrow(/Failed to load plugin "missing-plugin":/);
});
describe("name", () => {
it("should use plugin name if set", () => {
expect.assertions(1);
......