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.
@@ -1,5 +1,5 @@
1
- import { m as Report, c as ConfigLoader, H as HtmlValidate, a as ConfigData } from '../../core';
2
- export { A as AttributeData, X as AttributeEvent, a8 as CompatibilityOptions, 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, a4 as FileSystemConfigLoader, a5 as Formatter, 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, a7 as compatibilityCheck, p as configPresets, a6 as formatterFactory, x as ruleExists, v as version } from '../../core';
1
+ import { m as Report, c as ConfigLoader, H as HtmlValidate, a as ConfigData } from './core';
2
+ export { A as AttributeData, X as AttributeEvent, a8 as CompatibilityOptions, 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, a4 as FileSystemConfigLoader, a5 as Formatter, 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, a7 as compatibilityCheck, p as configPresets, a6 as formatterFactory, x as ruleExists, v as version } from './core';
3
3
  import 'ajv';
4
4
  import 'ajv/dist/types';
5
5
 
@@ -0,0 +1,4 @@
1
+ import './jest-lib';
2
+ import './core';
3
+ import 'ajv';
4
+ import 'ajv/dist/types';
@@ -1,4 +1,4 @@
1
- import { s as Transformer, l as Source } from '../../../core';
1
+ import { s as Transformer, l as Source } from './core';
2
2
  import 'ajv';
3
3
  import 'ajv/dist/types';
4
4
 
@@ -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';
package/dist/es/core.d.ts CHANGED
@@ -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/es/core.js CHANGED
@@ -1230,12 +1230,14 @@ var State;
1230
1230
  State[State["ATTR"] = 5] = "ATTR";
1231
1231
  State[State["CDATA"] = 6] = "CDATA";
1232
1232
  State[State["SCRIPT"] = 7] = "SCRIPT";
1233
+ State[State["STYLE"] = 8] = "STYLE";
1233
1234
  })(State || (State = {}));
1234
1235
 
1235
1236
  var ContentModel;
1236
1237
  (function (ContentModel) {
1237
1238
  ContentModel[ContentModel["TEXT"] = 1] = "TEXT";
1238
1239
  ContentModel[ContentModel["SCRIPT"] = 2] = "SCRIPT";
1240
+ ContentModel[ContentModel["STYLE"] = 3] = "STYLE";
1239
1241
  })(ContentModel || (ContentModel = {}));
1240
1242
  class Context {
1241
1243
  constructor(source) {
@@ -2915,7 +2917,7 @@ var TRANSFORMER_API;
2915
2917
  /** @public */
2916
2918
  const name = "html-validate";
2917
2919
  /** @public */
2918
- const version = "6.1.1";
2920
+ const version = "6.1.5";
2919
2921
  /** @public */
2920
2922
  const homepage = "https://html-validate.org";
2921
2923
  /** @public */
@@ -3601,10 +3603,11 @@ var TokenType;
3601
3603
  TokenType[TokenType["TEXT"] = 11] = "TEXT";
3602
3604
  TokenType[TokenType["TEMPLATING"] = 12] = "TEMPLATING";
3603
3605
  TokenType[TokenType["SCRIPT"] = 13] = "SCRIPT";
3604
- TokenType[TokenType["COMMENT"] = 14] = "COMMENT";
3605
- TokenType[TokenType["CONDITIONAL"] = 15] = "CONDITIONAL";
3606
- TokenType[TokenType["DIRECTIVE"] = 16] = "DIRECTIVE";
3607
- TokenType[TokenType["EOF"] = 17] = "EOF";
3606
+ TokenType[TokenType["STYLE"] = 14] = "STYLE";
3607
+ TokenType[TokenType["COMMENT"] = 15] = "COMMENT";
3608
+ TokenType[TokenType["CONDITIONAL"] = 16] = "CONDITIONAL";
3609
+ TokenType[TokenType["DIRECTIVE"] = 17] = "DIRECTIVE";
3610
+ TokenType[TokenType["EOF"] = 18] = "EOF";
3608
3611
  })(TokenType || (TokenType = {}));
3609
3612
 
3610
3613
  /* eslint-disable no-useless-escape */
@@ -3627,6 +3630,8 @@ const MATCH_CDATA_BEGIN = /^<!\[CDATA\[/;
3627
3630
  const MATCH_CDATA_END = /^[^]*?]]>/;
3628
3631
  const MATCH_SCRIPT_DATA = /^[^]*?(?=<\/script)/;
3629
3632
  const MATCH_SCRIPT_END = /^<(\/)(script)/;
3633
+ const MATCH_STYLE_DATA = /^[^]*?(?=<\/style)/;
3634
+ const MATCH_STYLE_END = /^<(\/)(style)/;
3630
3635
  const MATCH_DIRECTIVE = /^<!--\s*\[html-validate-(.*?)]\s*-->/;
3631
3636
  const MATCH_COMMENT = /^<!--([^]*?)-->/;
3632
3637
  const MATCH_CONDITIONAL = /^<!\[([^\]]*?)\]>/;
@@ -3666,6 +3671,9 @@ class Lexer {
3666
3671
  case State.SCRIPT:
3667
3672
  yield* this.tokenizeScript(context);
3668
3673
  break;
3674
+ case State.STYLE:
3675
+ yield* this.tokenizeStyle(context);
3676
+ break;
3669
3677
  /* istanbul ignore next: sanity check: should not happen unless adding new states */
3670
3678
  default:
3671
3679
  this.unhandled(context);
@@ -3734,11 +3742,14 @@ class Lexer {
3734
3742
  * Called when entering a new state.
3735
3743
  */
3736
3744
  enter(context, state, data) {
3737
- /* script tags require a different content model */
3745
+ /* script/style tags require a different content model */
3738
3746
  if (state === State.TAG && data && data[0][0] === "<") {
3739
3747
  if (data[0] === "<script") {
3740
3748
  context.contentModel = ContentModel.SCRIPT;
3741
3749
  }
3750
+ else if (data[0] === "<style") {
3751
+ context.contentModel = ContentModel.STYLE;
3752
+ }
3742
3753
  else {
3743
3754
  context.contentModel = ContentModel.TEXT;
3744
3755
  }
@@ -3764,6 +3775,7 @@ class Lexer {
3764
3775
  ], "expected doctype name");
3765
3776
  }
3766
3777
  *tokenizeTag(context) {
3778
+ /* eslint-disable-next-line consistent-return -- exhaustive switch handled by typescript */
3767
3779
  function nextState(token) {
3768
3780
  switch (context.contentModel) {
3769
3781
  case ContentModel.TEXT:
@@ -3775,11 +3787,14 @@ class Lexer {
3775
3787
  else {
3776
3788
  return State.TEXT; /* <script/> (not legal but handle it anyway so the lexer doesn't choke on it) */
3777
3789
  }
3790
+ case ContentModel.STYLE:
3791
+ if (token && token.data[0][0] !== "/") {
3792
+ return State.STYLE;
3793
+ }
3794
+ else {
3795
+ return State.TEXT; /* <style/> */
3796
+ }
3778
3797
  }
3779
- /* istanbul ignore next: not covered by a test as there is currently no
3780
- * way to trigger this unless new content models are added but this will
3781
- * add a saner default if anyone ever does */
3782
- return context.contentModel !== ContentModel.SCRIPT ? State.TEXT : State.SCRIPT;
3783
3798
  }
3784
3799
  yield* this.match(context, [
3785
3800
  [MATCH_TAG_CLOSE, nextState, TokenType.TAG_CLOSE],
@@ -3817,6 +3832,12 @@ class Lexer {
3817
3832
  [MATCH_SCRIPT_DATA, State.SCRIPT, TokenType.SCRIPT],
3818
3833
  ], "expected </script>");
3819
3834
  }
3835
+ *tokenizeStyle(context) {
3836
+ yield* this.match(context, [
3837
+ [MATCH_STYLE_END, State.TAG, TokenType.TAG_OPEN],
3838
+ [MATCH_STYLE_DATA, State.STYLE, TokenType.STYLE],
3839
+ ], "expected </style>");
3840
+ }
3820
3841
  }
3821
3842
 
3822
3843
  const whitespace = /(\s+)/;
@@ -6067,7 +6088,7 @@ function getCSSDeclarations(value) {
6067
6088
  .filter(Boolean)
6068
6089
  .map((it) => {
6069
6090
  const [property, value] = it.split(":", 2);
6070
- return { property: property.trim(), value: value.trim() };
6091
+ return { property: property.trim(), value: value ? value.trim() : undefined };
6071
6092
  });
6072
6093
  }
6073
6094
  class NoInlineStyle extends Rule {
@@ -9757,9 +9778,11 @@ class Config {
9757
9778
  this.configurations = this.loadConfigurations(this.plugins);
9758
9779
  this.extendMeta(this.plugins);
9759
9780
  /* process extended configs */
9760
- for (const extend of (_a = this.config.extends) !== null && _a !== void 0 ? _a : []) {
9761
- this.config = this.extendConfig(extend);
9762
- }
9781
+ this.config = this.extendConfig((_a = this.config.extends) !== null && _a !== void 0 ? _a : []);
9782
+ /* reset extends as we already processed them, this prevents the next config
9783
+ * from reapplying config from extended config as well as duplicate entries
9784
+ * when merging arrays */
9785
+ this.config.extends = [];
9763
9786
  /* rules explicitly set by passed options should have precedence over any
9764
9787
  * extended rules, not the other way around. */
9765
9788
  if (options && options.rules) {
@@ -9857,15 +9880,23 @@ class Config {
9857
9880
  merge(rhs) {
9858
9881
  return new Config(mergeInternal(this.config, rhs.config));
9859
9882
  }
9860
- extendConfig(entry) {
9861
- let base;
9862
- if (this.configurations.has(entry)) {
9863
- base = this.configurations.get(entry);
9883
+ extendConfig(entries) {
9884
+ if (entries.length === 0) {
9885
+ return this.config;
9864
9886
  }
9865
- else {
9866
- base = Config.fromFile(entry).config;
9887
+ let base = {};
9888
+ for (let i = 0; i < entries.length; i++) {
9889
+ const entry = entries[i];
9890
+ let extended;
9891
+ if (this.configurations.has(entry)) {
9892
+ extended = this.configurations.get(entry);
9893
+ }
9894
+ else {
9895
+ extended = Config.fromFile(entry).config;
9896
+ }
9897
+ base = mergeInternal(base, extended);
9867
9898
  }
9868
- return mergeInternal(this.config, base);
9899
+ return mergeInternal(base, this.config);
9869
9900
  }
9870
9901
  /**
9871
9902
  * Get element metadata.
@@ -9940,6 +9971,7 @@ class Config {
9940
9971
  }
9941
9972
  });
9942
9973
  }
9974
+ delete config.extends;
9943
9975
  return config;
9944
9976
  }
9945
9977
  /**