diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index bfb70d39738976c22c102bb3517235007a3d5b4a..1a4d449b9d961de370ea97d0811999c23c09bdfb 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -59,7 +59,7 @@ Cypress: needs: ["NPM", "Build"] script: - npm rebuild cypress - - npm test -- --no-coverage + - npm test -- --no-coverage tests HTML-validate 2.x: <<: *compat @@ -79,6 +79,12 @@ HTML-validate 4.x: - npm install -g npm@latest - npm install --no-save "html-validate@4.0.0" +HTML-validate 5.x: + <<: *compat + before_script: + - npm install -g npm@latest + - npm install --no-save "html-validate@5.0.0" + Cypress 3.5: <<: *compat before_script: diff --git a/package-lock.json b/package-lock.json index 8c206ad45b000602ba6db6ee49146f06616777df..815a7518d876277cf8dc65b4c94155e678d05fa0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,7 +8,8 @@ "version": "2.0.0", "license": "MIT", "dependencies": { - "deepmerge": "^4.2.2" + "deepmerge": "^4.0.0", + "kleur": "^4.0.0" }, "devDependencies": { "@commitlint/cli": "12.1.4", @@ -28,7 +29,7 @@ "eslint": "7.29.0", "eslint-plugin-cypress": "2.11.3", "express": "4.17.1", - "html-validate": "4.14.0", + "html-validate": "5.0.1", "husky": "6.0.0", "jest": "27.0.5", "lint-staged": "11.0.0", @@ -47,7 +48,7 @@ }, "peerDependencies": { "cypress": "^3.5.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0", - "html-validate": "^2.17.0 || ^3.0.0 || ^4.0.0" + "html-validate": "^2.17 || ^3 || ^4 || ^5" } }, "node_modules/@babel/code-frame": { @@ -8854,16 +8855,16 @@ "dev": true }, "node_modules/html-validate": { - "version": "4.14.0", - "resolved": "https://registry.npmjs.org/html-validate/-/html-validate-4.14.0.tgz", - "integrity": "sha512-+QXML6W1ulLl6F98PqnBvscm1kqmfYzPpB2WgBsRHEKI5J6xDGvoyrPC7nb3yS5fKL354wHRZ0vQDCp6s50cVg==", + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/html-validate/-/html-validate-5.0.1.tgz", + "integrity": "sha512-s2sHskOlobnhim2seVTkAvt0MPMDSetJLUuARgqSiSxF5J3yYzGIeN3+wgpw1XlpYdNRBs7C2EM1wZJtzHlhNg==", "dev": true, "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": "^7.0.0", + "ajv": "^8.0.0", "deepmerge": "^4.2.0", "espree": "^7.3.0", "glob": "^7.1.0", @@ -8871,13 +8872,14 @@ "json-merge-patch": "^1.0.0", "kleur": "^4.1.0", "minimist": "^1.2.0", - "prompts": "^2.0.0" + "prompts": "^2.0.0", + "semver": "^7.0.0" }, "bin": { "html-validate": "bin/html-validate.js" }, "engines": { - "node": ">= 10.0" + "node": ">= 12.0" }, "peerDependencies": { "jest": "^24 || ^25 || ^26 || ^27" @@ -8888,6 +8890,19 @@ } } }, + "node_modules/html-validate/node_modules/@html-validate/stylish": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@html-validate/stylish/-/stylish-2.0.0.tgz", + "integrity": "sha512-lmI4sUZGHpxfWyPtKKrcIbwBbDLXSb+XPEYS1USc46ZzXx/VsnsVqbk3pPIUdEPhd4v72xGS8HDAy/+8wZzlbQ==", + "dev": true, + "dependencies": { + "kleur": "^4.0.0", + "text-table": "^0.2.0" + }, + "engines": { + "node": ">= 12.0" + } + }, "node_modules/html-validate/node_modules/acorn-walk": { "version": "8.0.2", "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.0.2.tgz", @@ -8898,15 +8913,19 @@ } }, "node_modules/html-validate/node_modules/ajv": { - "version": "7.1.0", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-7.1.0.tgz", - "integrity": "sha512-svS9uILze/cXbH0z2myCK2Brqprx/+JJYK5pHicT/GQiBfzzhUVAIT6MwqJg8y4xV/zoGsUeuPuwtoiKSGE15g==", + "version": "8.6.0", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.6.0.tgz", + "integrity": "sha512-cnUG4NSBiM4YFBxgZIj/In3/6KX+rQ2l2YPRVcvAMQGWEPKuXoPIhxzwqh31jA3IPbI4qEOp/5ILI4ynioXsGQ==", "dev": true, "dependencies": { "fast-deep-equal": "^3.1.1", "json-schema-traverse": "^1.0.0", "require-from-string": "^2.0.2", "uri-js": "^4.2.2" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/epoberezkin" } }, "node_modules/html-validate/node_modules/glob": { @@ -8941,13 +8960,19 @@ "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==", "dev": true }, - "node_modules/html-validate/node_modules/kleur": { - "version": "4.1.4", - "resolved": "https://registry.npmjs.org/kleur/-/kleur-4.1.4.tgz", - "integrity": "sha512-8QADVssbrFjivHWQU7KkMgptGTl6WAcSdlbBPY4uNF+mWr6DGcKrvY2w4FQJoXch7+fKMjj0dRrL75vk3k23OA==", + "node_modules/html-validate/node_modules/semver": { + "version": "7.3.5", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz", + "integrity": "sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ==", "dev": true, + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, "engines": { - "node": ">=6" + "node": ">=10" } }, "node_modules/http-cache-semantics": { @@ -13255,10 +13280,9 @@ } }, "node_modules/kleur": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/kleur/-/kleur-3.0.3.tgz", - "integrity": "sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w==", - "dev": true, + "version": "4.1.4", + "resolved": "https://registry.npmjs.org/kleur/-/kleur-4.1.4.tgz", + "integrity": "sha512-8QADVssbrFjivHWQU7KkMgptGTl6WAcSdlbBPY4uNF+mWr6DGcKrvY2w4FQJoXch7+fKMjj0dRrL75vk3k23OA==", "engines": { "node": ">=6" } @@ -18609,6 +18633,15 @@ "node": ">= 6" } }, + "node_modules/prompts/node_modules/kleur": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/kleur/-/kleur-3.0.3.tgz", + "integrity": "sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w==", + "dev": true, + "engines": { + "node": ">=6" + } + }, "node_modules/protocols": { "version": "1.4.8", "resolved": "https://registry.npmjs.org/protocols/-/protocols-1.4.8.tgz", @@ -28273,16 +28306,16 @@ "dev": true }, "html-validate": { - "version": "4.14.0", - "resolved": "https://registry.npmjs.org/html-validate/-/html-validate-4.14.0.tgz", - "integrity": "sha512-+QXML6W1ulLl6F98PqnBvscm1kqmfYzPpB2WgBsRHEKI5J6xDGvoyrPC7nb3yS5fKL354wHRZ0vQDCp6s50cVg==", + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/html-validate/-/html-validate-5.0.1.tgz", + "integrity": "sha512-s2sHskOlobnhim2seVTkAvt0MPMDSetJLUuARgqSiSxF5J3yYzGIeN3+wgpw1XlpYdNRBs7C2EM1wZJtzHlhNg==", "dev": true, "requires": { "@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": "^7.0.0", + "ajv": "^8.0.0", "deepmerge": "^4.2.0", "espree": "^7.3.0", "glob": "^7.1.0", @@ -28290,9 +28323,20 @@ "json-merge-patch": "^1.0.0", "kleur": "^4.1.0", "minimist": "^1.2.0", - "prompts": "^2.0.0" + "prompts": "^2.0.0", + "semver": "^7.0.0" }, "dependencies": { + "@html-validate/stylish": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@html-validate/stylish/-/stylish-2.0.0.tgz", + "integrity": "sha512-lmI4sUZGHpxfWyPtKKrcIbwBbDLXSb+XPEYS1USc46ZzXx/VsnsVqbk3pPIUdEPhd4v72xGS8HDAy/+8wZzlbQ==", + "dev": true, + "requires": { + "kleur": "^4.0.0", + "text-table": "^0.2.0" + } + }, "acorn-walk": { "version": "8.0.2", "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.0.2.tgz", @@ -28300,9 +28344,9 @@ "dev": true }, "ajv": { - "version": "7.1.0", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-7.1.0.tgz", - "integrity": "sha512-svS9uILze/cXbH0z2myCK2Brqprx/+JJYK5pHicT/GQiBfzzhUVAIT6MwqJg8y4xV/zoGsUeuPuwtoiKSGE15g==", + "version": "8.6.0", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.6.0.tgz", + "integrity": "sha512-cnUG4NSBiM4YFBxgZIj/In3/6KX+rQ2l2YPRVcvAMQGWEPKuXoPIhxzwqh31jA3IPbI4qEOp/5ILI4ynioXsGQ==", "dev": true, "requires": { "fast-deep-equal": "^3.1.1", @@ -28337,11 +28381,14 @@ "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==", "dev": true }, - "kleur": { - "version": "4.1.4", - "resolved": "https://registry.npmjs.org/kleur/-/kleur-4.1.4.tgz", - "integrity": "sha512-8QADVssbrFjivHWQU7KkMgptGTl6WAcSdlbBPY4uNF+mWr6DGcKrvY2w4FQJoXch7+fKMjj0dRrL75vk3k23OA==", - "dev": true + "semver": { + "version": "7.3.5", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz", + "integrity": "sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ==", + "dev": true, + "requires": { + "lru-cache": "^6.0.0" + } } } }, @@ -31647,10 +31694,9 @@ "dev": true }, "kleur": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/kleur/-/kleur-3.0.3.tgz", - "integrity": "sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w==", - "dev": true + "version": "4.1.4", + "resolved": "https://registry.npmjs.org/kleur/-/kleur-4.1.4.tgz", + "integrity": "sha512-8QADVssbrFjivHWQU7KkMgptGTl6WAcSdlbBPY4uNF+mWr6DGcKrvY2w4FQJoXch7+fKMjj0dRrL75vk3k23OA==" }, "lazy-ass": { "version": "1.6.0", @@ -35493,6 +35539,14 @@ "requires": { "kleur": "^3.0.3", "sisteransi": "^1.0.5" + }, + "dependencies": { + "kleur": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/kleur/-/kleur-3.0.3.tgz", + "integrity": "sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w==", + "dev": true + } } }, "protocols": { diff --git a/package.json b/package.json index 6ff0c400998b8003d1ab48683b2f6ba1f632710b..44beb3e73600f2535ed16d0bc6b4f835c7d652bf 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,7 @@ "digest": "scripts/digest", "eslint": "eslint .", "eslint:fix": "eslint --fix .", - "prepare": "husky install && git config commit.template ./node_modules/@html-validate/commitlint-config/gitmessage", + "prepare": "husky install", "prettier:check": "prettier --check .", "prettier:write": "prettier --write .", "semantic-release": "semantic-release", @@ -59,7 +59,8 @@ "testRunner": "jest-jasmine2" }, "dependencies": { - "deepmerge": "^4.2.2" + "deepmerge": "^4.0.0", + "kleur": "^4.0.0" }, "devDependencies": { "@commitlint/cli": "12.1.4", @@ -79,7 +80,7 @@ "eslint": "7.29.0", "eslint-plugin-cypress": "2.11.3", "express": "4.17.1", - "html-validate": "4.14.0", + "html-validate": "5.0.1", "husky": "6.0.0", "jest": "27.0.5", "lint-staged": "11.0.0", @@ -95,7 +96,7 @@ }, "peerDependencies": { "cypress": "^3.5.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0", - "html-validate": "^2.17.0 || ^3.0.0 || ^4.0.0" + "html-validate": "^2.17 || ^3 || ^4 || ^5" }, "engines": { "node": ">= 12.0" diff --git a/src/config.ts b/src/config.ts index cc8ecce4fc1f7fd2a1ab595cf1c2a118cfc7c273..ce8eb5b4bf6d13dbe6b10bde2d72cbfe74ffd24c 100644 --- a/src/config.ts +++ b/src/config.ts @@ -1,4 +1,4 @@ -import { ConfigData } from "html-validate"; +import { ConfigData, ruleExists } from "html-validate"; import deepmerge from "deepmerge"; function overwriteMerge<T>(a: T[], b: T[]): T[] { @@ -57,6 +57,7 @@ function canResolve(pkg: string): boolean { /* use legacy void rule if the new rules dont exist */ const haveVoidContent = + (ruleExists && ruleExists("void-content")) || canResolve("html-validate/build/rules/void-content") /* html-validate < 4.x */ || canResolve("html-validate/dist/rules/void-content"); /* html-validate >= 4.x */ const useLegacyVoid = !haveVoidContent; diff --git a/src/plugin.ts b/src/plugin.ts index fcd523a6a1f23e9677ece50c445298b04cab4f23..05af5e42b7de9d925a21ad1ac9775018b9e389b4 100644 --- a/src/plugin.ts +++ b/src/plugin.ts @@ -1,13 +1,29 @@ -import { HtmlValidate, ConfigData, Report, Message } from "html-validate"; +import { HtmlValidate, ConfigData, Report, Message, compatibilityCheck } from "html-validate"; +import kleur from "kleur"; import defaultConfig, { mergeConfig } from "./config"; import defaultOptions, { CypressHtmlValidateOptions } from "./options"; +/* eslint-disable-next-line @typescript-eslint/no-var-requires */ +const pkg = require("../package.json"); + export function install( /* eslint-disable-next-line @typescript-eslint/ban-types --- should accept any function prototype */ on: (action: string, arg: Record<string, Function>) => void, userConfig?: ConfigData, userOptions?: Partial<CypressHtmlValidateOptions> ): void { + if (compatibilityCheck) { + const range = pkg.peerDependencies["html-validate"]; + compatibilityCheck(pkg.name, range, { + logger(text: string): void { + /* default logger uses console.error but cypress swallows those in + * headles smode */ + /* eslint-disable-next-line no-console */ + console.log(kleur.red(text)); + }, + }); + } + const config = mergeConfig(defaultConfig, userConfig); const htmlvalidate = new HtmlValidate(config);