From 51471a99d2e946c124222f6a74fa3fbd1876ac69 Mon Sep 17 00:00:00 2001 From: Valerii Baleiko Date: Thu, 10 Jun 2021 23:57:06 +0300 Subject: [PATCH] feat(rules): add html-lang-require rule (#632) * added html-lang-require rule * add tests for html-lang-require rule Co-authored-by: David Dias --- src/core/rules/html-lang-require.ts | 66 ++++++++++++++++++++++++++++ src/core/rules/index.ts | 1 + test/rules/html-lang-require.spec.js | 31 +++++++++++++ 3 files changed, 98 insertions(+) create mode 100644 src/core/rules/html-lang-require.ts create mode 100644 test/rules/html-lang-require.spec.js diff --git a/src/core/rules/html-lang-require.ts b/src/core/rules/html-lang-require.ts new file mode 100644 index 000000000..9324a270a --- /dev/null +++ b/src/core/rules/html-lang-require.ts @@ -0,0 +1,66 @@ +import { Rule } from '../types' + +const regular = + '(art-lojban|cel-gaulish|no-bok|no-nyn|zh-guoyu|zh-hakka|zh-min|zh-min-nan|zh-xiang)' +const irregular = + '(en-GB-oed|i-ami|i-bnn|i-default|i-enochian|i-hak|i-klingon|i-lux|i-mingo|i-navajo|i-pwn|i-tao|i-tay|i-tsu|sgn-BE-FR|sgn-BE-NL|sgn-CH-DE)' +const grandfathered = `(?${irregular}|${regular})` +const privateUse = '(?x(-[A-Za-z0-9]{1,8})+)' +const privateUse2 = '(?x(-[A-Za-z0-9]{1,8})+)' +const singleton = '[0-9A-WY-Za-wy-z]' +const extension = `(?${singleton}(-[A-Za-z0-9]{2,8})+)` +const variant = '(?[A-Za-z0-9]{5,8}|[0-9][A-Za-z0-9]{3})' +const region = '(?[A-Za-z]{2}|[0-9]{3})' +const script = '(?