html-validate 6.1.1 → 6.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,31 @@
1
1
  # html-validate changelog
2
2
 
3
+ ### [6.1.5](https://gitlab.com/html-validate/html-validate/compare/v6.1.4...v6.1.5) (2021-12-28)
4
+
5
+ ### Bug Fixes
6
+
7
+ - **config:** dont process extends multiple times ([f014311](https://gitlab.com/html-validate/html-validate/commit/f01431147a74272142dd6ddcfe5d53bf68c80aa9))
8
+ - **config:** elements from extended configs should be loaded first not last ([d19519e](https://gitlab.com/html-validate/html-validate/commit/d19519e5ee97e7b5c375bca80f01dcbaa5eb0373))
9
+
10
+ ### [6.1.4](https://gitlab.com/html-validate/html-validate/compare/v6.1.3...v6.1.4) (2021-12-04)
11
+
12
+ ### Bug Fixes
13
+
14
+ - handle multiline `srcset` attribute ([0bb92a7](https://gitlab.com/html-validate/html-validate/commit/0bb92a7c649d44281f530ea105aba55c9f3191ff)), closes [#138](https://gitlab.com/html-validate/html-validate/issues/138)
15
+
16
+ ### [6.1.3](https://gitlab.com/html-validate/html-validate/compare/v6.1.2...v6.1.3) (2021-11-19)
17
+
18
+ ### Bug Fixes
19
+
20
+ - parse `<style>` content as text instead of markup ([0ab61e6](https://gitlab.com/html-validate/html-validate/commit/0ab61e6f9c875f76d0b7725f615808eedf1531fd)), closes [#137](https://gitlab.com/html-validate/html-validate/issues/137)
21
+ - **rules:** handle malformed `style` attribute in `no-inline-style` rule ([7e12d50](https://gitlab.com/html-validate/html-validate/commit/7e12d507785eaf4fbbacf9b6ad53c31d5c6aece0))
22
+
23
+ ### [6.1.2](https://gitlab.com/html-validate/html-validate/compare/v6.1.1...v6.1.2) (2021-11-13)
24
+
25
+ ### Bug Fixes
26
+
27
+ - fix .d.ts paths in package ([f24c2f4](https://gitlab.com/html-validate/html-validate/commit/f24c2f4752680edc6624d173599032cc5ed9830b))
28
+
3
29
  ### [6.1.1](https://gitlab.com/html-validate/html-validate/compare/v6.1.0...v6.1.1) (2021-11-10)
4
30
 
5
31
  ### Dependency upgrades
@@ -1,3 +1,3 @@
1
- export { A as AttributeData, X as AttributeEvent, Z as ConditionalEvent, C as Config, a as ConfigData, b as ConfigError, c as ConfigLoader, F as ConfigReadyEvent, a0 as DOMLoadEvent, a1 as DOMReadyEvent, _ as DirectiveEvent, $ as DoctypeEvent, D as DynamicValue, W as ElementReadyEvent, B as Event, z as EventCallback, E as EventDump, y as EventHandler, e as HtmlElement, H as HtmlValidate, a3 as ListenEventMap, L as Location, o as Message, j as MetaCopyableProperty, M as MetaData, h as MetaElement, i as MetaTable, N as NodeClosed, w as Parser, u as Plugin, P as ProcessElementContext, m as Report, n as Reporter, q as Result, R as Rule, k as RuleDocumentation, g as SchemaValidationError, S as Severity, l as Source, G as SourceReadyEvent, d as StaticConfigLoader, Q as TagCloseEvent, O as TagEndEvent, K as TagOpenEvent, V as TagReadyEvent, J as TagStartEvent, t as TemplateExtractor, T as TextNode, f as TokenDump, I as TokenEvent, r as TransformContext, s as Transformer, a2 as TriggerEventMap, U as UserError, Y as WhitespaceEvent, p as configPresets, x as ruleExists, v as version } from '../../core';
1
+ export { A as AttributeData, X as AttributeEvent, Z as ConditionalEvent, C as Config, a as ConfigData, b as ConfigError, c as ConfigLoader, F as ConfigReadyEvent, a0 as DOMLoadEvent, a1 as DOMReadyEvent, _ as DirectiveEvent, $ as DoctypeEvent, D as DynamicValue, W as ElementReadyEvent, B as Event, z as EventCallback, E as EventDump, y as EventHandler, e as HtmlElement, H as HtmlValidate, a3 as ListenEventMap, L as Location, o as Message, j as MetaCopyableProperty, M as MetaData, h as MetaElement, i as MetaTable, N as NodeClosed, w as Parser, u as Plugin, P as ProcessElementContext, m as Report, n as Reporter, q as Result, R as Rule, k as RuleDocumentation, g as SchemaValidationError, S as Severity, l as Source, G as SourceReadyEvent, d as StaticConfigLoader, Q as TagCloseEvent, O as TagEndEvent, K as TagOpenEvent, V as TagReadyEvent, J as TagStartEvent, t as TemplateExtractor, T as TextNode, f as TokenDump, I as TokenEvent, r as TransformContext, s as Transformer, a2 as TriggerEventMap, U as UserError, Y as WhitespaceEvent, p as configPresets, x as ruleExists, v as version } from './core';
2
2
  import 'ajv';
3
3
  import 'ajv/dist/types';
@@ -51,10 +51,11 @@ declare enum TokenType {
51
51
  TEXT = 11,
52
52
  TEMPLATING = 12,
53
53
  SCRIPT = 13,
54
- COMMENT = 14,
55
- CONDITIONAL = 15,
56
- DIRECTIVE = 16,
57
- EOF = 17
54
+ STYLE = 14,
55
+ COMMENT = 15,
56
+ CONDITIONAL = 16,
57
+ DIRECTIVE = 17,
58
+ EOF = 18
58
59
  }
59
60
  interface Token {
60
61
  type: TokenType;
package/dist/cjs/core.js CHANGED
@@ -1242,12 +1242,14 @@ var State;
1242
1242
  State[State["ATTR"] = 5] = "ATTR";
1243
1243
  State[State["CDATA"] = 6] = "CDATA";
1244
1244
  State[State["SCRIPT"] = 7] = "SCRIPT";
1245
+ State[State["STYLE"] = 8] = "STYLE";
1245
1246
  })(State || (State = {}));
1246
1247
 
1247
1248
  var ContentModel;
1248
1249
  (function (ContentModel) {
1249
1250
  ContentModel[ContentModel["TEXT"] = 1] = "TEXT";
1250
1251
  ContentModel[ContentModel["SCRIPT"] = 2] = "SCRIPT";
1252
+ ContentModel[ContentModel["STYLE"] = 3] = "STYLE";
1251
1253
  })(ContentModel || (ContentModel = {}));
1252
1254
  class Context {
1253
1255
  constructor(source) {
@@ -2927,7 +2929,7 @@ var TRANSFORMER_API;
2927
2929
  /** @public */
2928
2930
  const name = "html-validate";
2929
2931
  /** @public */
2930
- const version = "6.1.1";
2932
+ const version = "6.1.5";
2931
2933
  /** @public */
2932
2934
  const homepage = "https://html-validate.org";
2933
2935
  /** @public */
@@ -3613,10 +3615,11 @@ exports.TokenType = void 0;
3613
3615
  TokenType[TokenType["TEXT"] = 11] = "TEXT";
3614
3616
  TokenType[TokenType["TEMPLATING"] = 12] = "TEMPLATING";
3615
3617
  TokenType[TokenType["SCRIPT"] = 13] = "SCRIPT";
3616
- TokenType[TokenType["COMMENT"] = 14] = "COMMENT";
3617
- TokenType[TokenType["CONDITIONAL"] = 15] = "CONDITIONAL";
3618
- TokenType[TokenType["DIRECTIVE"] = 16] = "DIRECTIVE";
3619
- TokenType[TokenType["EOF"] = 17] = "EOF";
3618
+ TokenType[TokenType["STYLE"] = 14] = "STYLE";
3619
+ TokenType[TokenType["COMMENT"] = 15] = "COMMENT";
3620
+ TokenType[TokenType["CONDITIONAL"] = 16] = "CONDITIONAL";
3621
+ TokenType[TokenType["DIRECTIVE"] = 17] = "DIRECTIVE";
3622
+ TokenType[TokenType["EOF"] = 18] = "EOF";
3620
3623
  })(exports.TokenType || (exports.TokenType = {}));
3621
3624
 
3622
3625
  /* eslint-disable no-useless-escape */
@@ -3639,6 +3642,8 @@ const MATCH_CDATA_BEGIN = /^<!\[CDATA\[/;
3639
3642
  const MATCH_CDATA_END = /^[^]*?]]>/;
3640
3643
  const MATCH_SCRIPT_DATA = /^[^]*?(?=<\/script)/;
3641
3644
  const MATCH_SCRIPT_END = /^<(\/)(script)/;
3645
+ const MATCH_STYLE_DATA = /^[^]*?(?=<\/style)/;
3646
+ const MATCH_STYLE_END = /^<(\/)(style)/;
3642
3647
  const MATCH_DIRECTIVE = /^<!--\s*\[html-validate-(.*?)]\s*-->/;
3643
3648
  const MATCH_COMMENT = /^<!--([^]*?)-->/;
3644
3649
  const MATCH_CONDITIONAL = /^<!\[([^\]]*?)\]>/;
@@ -3678,6 +3683,9 @@ class Lexer {
3678
3683
  case State.SCRIPT:
3679
3684
  yield* this.tokenizeScript(context);
3680
3685
  break;
3686
+ case State.STYLE:
3687
+ yield* this.tokenizeStyle(context);
3688
+ break;
3681
3689
  /* istanbul ignore next: sanity check: should not happen unless adding new states */
3682
3690
  default:
3683
3691
  this.unhandled(context);
@@ -3746,11 +3754,14 @@ class Lexer {
3746
3754
  * Called when entering a new state.
3747
3755
  */
3748
3756
  enter(context, state, data) {
3749
- /* script tags require a different content model */
3757
+ /* script/style tags require a different content model */
3750
3758
  if (state === State.TAG && data && data[0][0] === "<") {
3751
3759
  if (data[0] === "<script") {
3752
3760
  context.contentModel = ContentModel.SCRIPT;
3753
3761
  }
3762
+ else if (data[0] === "<style") {
3763
+ context.contentModel = ContentModel.STYLE;
3764
+ }
3754
3765
  else {
3755
3766
  context.contentModel = ContentModel.TEXT;
3756
3767
  }
@@ -3776,6 +3787,7 @@ class Lexer {
3776
3787
  ], "expected doctype name");
3777
3788
  }
3778
3789
  *tokenizeTag(context) {
3790
+ /* eslint-disable-next-line consistent-return -- exhaustive switch handled by typescript */
3779
3791
  function nextState(token) {
3780
3792
  switch (context.contentModel) {
3781
3793
  case ContentModel.TEXT:
@@ -3787,11 +3799,14 @@ class Lexer {
3787
3799
  else {
3788
3800
  return State.TEXT; /* <script/> (not legal but handle it anyway so the lexer doesn't choke on it) */
3789
3801
  }
3802
+ case ContentModel.STYLE:
3803
+ if (token && token.data[0][0] !== "/") {
3804
+ return State.STYLE;
3805
+ }
3806
+ else {
3807
+ return State.TEXT; /* <style/> */
3808
+ }
3790
3809
  }
3791
- /* istanbul ignore next: not covered by a test as there is currently no
3792
- * way to trigger this unless new content models are added but this will
3793
- * add a saner default if anyone ever does */
3794
- return context.contentModel !== ContentModel.SCRIPT ? State.TEXT : State.SCRIPT;
3795
3810
  }
3796
3811
  yield* this.match(context, [
3797
3812
  [MATCH_TAG_CLOSE, nextState, exports.TokenType.TAG_CLOSE],
@@ -3829,6 +3844,12 @@ class Lexer {
3829
3844
  [MATCH_SCRIPT_DATA, State.SCRIPT, exports.TokenType.SCRIPT],
3830
3845
  ], "expected </script>");
3831
3846
  }
3847
+ *tokenizeStyle(context) {
3848
+ yield* this.match(context, [
3849
+ [MATCH_STYLE_END, State.TAG, exports.TokenType.TAG_OPEN],
3850
+ [MATCH_STYLE_DATA, State.STYLE, exports.TokenType.STYLE],
3851
+ ], "expected </style>");
3852
+ }
3832
3853
  }
3833
3854
 
3834
3855
  const whitespace = /(\s+)/;
@@ -6079,7 +6100,7 @@ function getCSSDeclarations(value) {
6079
6100
  .filter(Boolean)
6080
6101
  .map((it) => {
6081
6102
  const [property, value] = it.split(":", 2);
6082
- return { property: property.trim(), value: value.trim() };
6103
+ return { property: property.trim(), value: value ? value.trim() : undefined };
6083
6104
  });
6084
6105
  }
6085
6106
  class NoInlineStyle extends Rule {
@@ -9769,9 +9790,11 @@ class Config {
9769
9790
  this.configurations = this.loadConfigurations(this.plugins);
9770
9791
  this.extendMeta(this.plugins);
9771
9792
  /* process extended configs */
9772
- for (const extend of (_a = this.config.extends) !== null && _a !== void 0 ? _a : []) {
9773
- this.config = this.extendConfig(extend);
9774
- }
9793
+ this.config = this.extendConfig((_a = this.config.extends) !== null && _a !== void 0 ? _a : []);
9794
+ /* reset extends as we already processed them, this prevents the next config
9795
+ * from reapplying config from extended config as well as duplicate entries
9796
+ * when merging arrays */
9797
+ this.config.extends = [];
9775
9798
  /* rules explicitly set by passed options should have precedence over any
9776
9799
  * extended rules, not the other way around. */
9777
9800
  if (options && options.rules) {
@@ -9869,15 +9892,23 @@ class Config {
9869
9892
  merge(rhs) {
9870
9893
  return new Config(mergeInternal(this.config, rhs.config));
9871
9894
  }
9872
- extendConfig(entry) {
9873
- let base;
9874
- if (this.configurations.has(entry)) {
9875
- base = this.configurations.get(entry);
9895
+ extendConfig(entries) {
9896
+ if (entries.length === 0) {
9897
+ return this.config;
9876
9898
  }
9877
- else {
9878
- base = Config.fromFile(entry).config;
9899
+ let base = {};
9900
+ for (let i = 0; i < entries.length; i++) {
9901
+ const entry = entries[i];
9902
+ let extended;
9903
+ if (this.configurations.has(entry)) {
9904
+ extended = this.configurations.get(entry);
9905
+ }
9906
+ else {
9907
+ extended = Config.fromFile(entry).config;
9908
+ }
9909
+ base = mergeInternal(base, extended);
9879
9910
  }
9880
- return mergeInternal(this.config, base);
9911
+ return mergeInternal(base, this.config);
9881
9912
  }
9882
9913
  /**
9883
9914
  * Get element metadata.
@@ -9952,6 +9983,7 @@ class Config {
9952
9983
  }
9953
9984
  });
9954
9985
  }
9986
+ delete config.extends;
9955
9987
  return config;
9956
9988
  }
9957
9989
  /**