@angular-eslint/template-parser 13.2.1-alpha.3 → 13.2.1-alpha.4

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/dist/index.js CHANGED
@@ -1 +1 @@
1
- var e=require("@angular-eslint/bundled-angular-compiler"),t=require("eslint-scope");function n(e){return{start:{line:e.start.line+1,column:e.start.col},end:{line:e.end.line+1,column:e.end.col}}}function r(t,r){if("Element$1"!==r.type)throw new Error("convertElementSourceSpanToLoc is intented to be used only with elements.");return e.getHtmlTagDefinition(r.name).isVoid&&(r=function(t,n){const{rootNodes:r}=(s||(s=new e.HtmlParser)).parse(t.getSourceCode().getText(),t.getFilename());return o(r,n.sourceSpan)}(t,r)||r),n(r.sourceSpan)}function o(t,n){for(const r of t){if(r.sourceSpan.start.line===n.start.line&&r.sourceSpan.start.offset===n.start.offset)return r;if(r instanceof e.Element){const e=o(r.children,n);if(null!==e)return e}}return null}let s=null;const a={ASTWithSource:["ast"],Binary:["left","right"],BoundAttribute:["value"],BoundEvent:["handler"],BoundText:["value"],Conditional:["condition","trueExp","falseExp"],Element$1:["children","inputs","outputs","attributes"],Interpolation:["expressions"],PrefixNot:["expression"],Program:["templateNodes"],PropertyRead:["receiver"],Template:["templateAttrs","children","inputs"],BindingPipe:["exp"]};function l(e){let t=null;return"comments"!==e&&"leadingComments"!==e&&"loc"!==e&&"parent"!==e&&"range"!==e&&"tokens"!==e&&"trailingComments"!==e&&null!==(t=this[e])&&"object"==typeof t&&("string"==typeof t.type||Array.isArray(t))}function i(e){return null!==e&&"object"==typeof e&&"string"==typeof e.type}function c(e){let t=0,r=0;const o=a[e.type]||function(e){return Object.keys(e).filter(l,e)}(e);for(!e.loc&&e.sourceSpan&&(e.loc=n(e.sourceSpan)),t=0;t<o.length;++t){const n=e[o[t]],s=Array.isArray(n);if(void 0!==n.type&&(n.__originalType=n.type),s||n.type||(n.type=n.constructor.name),s)for(r=0;r<n.length;++r){const e=n[r];void 0!==e.type&&(e.__originalType=e.type),e.type&&"number"!=typeof e.type||(e.type=e.constructor.name),i(e)&&c(e)}else i(n)&&c(n)}}class u extends Error{constructor(e,t,n,r,o){super(e),this.fileName=void 0,this.index=void 0,this.lineNumber=void 0,this.column=void 0,this.fileName=t,this.index=n,this.lineNumber=r,this.column=o,Object.defineProperty(this,"name",{value:new.target.name,enumerable:!1,configurable:!0})}}function p(e){return new u(e.msg,e.span.start.file.url,e.span.start.offset,e.span.start.line+1,e.span.start.col+1)}function f(o,s){var l;const i=e.parseTemplate(o,s.filePath,{preserveWhitespaces:!0,preserveLineEndings:!0,collectCommentNodes:!0});let u=[];Array.isArray(i.commentNodes)&&(u=i.commentNodes);const f={type:"Program",comments:(m=u,m.map(e=>({type:"Block",value:e.value,loc:n(e.sourceSpan),range:[e.sourceSpan.start.offset,e.sourceSpan.end.offset]})).sort((e,t)=>e.range[0]-t.range[0])),tokens:[],range:[0,0],loc:{start:{line:0,column:0},end:{line:0,column:0}},templateNodes:i.nodes,value:o};var m;const d=new t.ScopeManager({});new t.Scope(d,"module",null,f,!1),c(f);const y=function(e){let t=null;return e.templateNodes.forEach(e=>{const n=e.startSourceSpan||e.sourceSpan;t?n&&n.start.offset<t.start.offset&&(t=n):t=n}),t}(f),g=function(e){let t=null;return e.templateNodes.forEach(e=>{const n=e.endSourceSpan||e.sourceSpan;t?n&&n.end.offset>t.end.offset&&(t=n):t=n}),t}(f);if(y&&g&&(f.range=[y.start.offset,g.end.offset],f.loc={start:n(y).start,end:n(g).end}),null!=(l=i.errors)&&l.length)throw p(i.errors[0]);return{ast:f,scopeManager:d,visitorKeys:a,services:{convertNodeSourceSpanToLoc:n,convertElementSourceSpanToLoc:r}}}exports.TemplateParseError=u,exports.createTemplateParseError=p,exports.parse=function(e,t){return f(e,t).ast},exports.parseForESLint=f;
1
+ var e=require("@angular-eslint/bundled-angular-compiler"),t=require("eslint-scope");function n(e){return{start:{line:e.start.line+1,column:e.start.col},end:{line:e.end.line+1,column:e.end.col}}}function r(t,r){if("Element$1"!==r.type)throw new Error("convertElementSourceSpanToLoc is intented to be used only with elements.");return e.getHtmlTagDefinition(r.name).isVoid&&(r=function(t,n){const{rootNodes:r}=(s||(s=new e.HtmlParser)).parse(t.getSourceCode().getText(),t.getFilename());return o(r,n.sourceSpan)}(t,r)||r),n(r.sourceSpan)}function o(t,n){for(const r of t){if(r.sourceSpan.start.line===n.start.line&&r.sourceSpan.start.offset===n.start.offset)return r;if(r instanceof e.Element){const e=o(r.children,n);if(null!==e)return e}}return null}let s=null;const a={ASTWithSource:["ast"],Binary:["left","right"],BoundAttribute:["value"],BoundEvent:["handler"],BoundText:["value"],Conditional:["condition","trueExp","falseExp"],Element$1:["children","inputs","outputs","attributes"],Interpolation:["expressions"],PrefixNot:["expression"],Program:["templateNodes"],PropertyRead:["receiver"],Template:["templateAttrs","children","inputs"],BindingPipe:["exp"]};function l(e){let t=null;return"comments"!==e&&"leadingComments"!==e&&"loc"!==e&&"parent"!==e&&"range"!==e&&"tokens"!==e&&"trailingComments"!==e&&null!==(t=this[e])&&"object"==typeof t&&("string"==typeof t.type||Array.isArray(t))}function i(e){return null!==e&&"object"==typeof e&&"string"==typeof e.type}function c(e){let t=0,r=0;const o=a[e.type]||function(e){return Object.keys(e).filter(l,e)}(e);for(!e.loc&&e.sourceSpan&&(e.loc=n(e.sourceSpan)),t=0;t<o.length;++t){const n=e[o[t]],s=Array.isArray(n);if(void 0!==n.type&&(n.__originalType=n.type),s||n.type||(n.type=n.constructor.name),s)for(r=0;r<n.length;++r){const e=n[r];void 0!==e.type&&(e.__originalType=e.type),e.type&&"number"!=typeof e.type||(e.type=e.constructor.name),i(e)&&c(e)}else i(n)&&c(n)}}class u extends Error{constructor(e,t,n,r,o){super(e),this.fileName=void 0,this.index=void 0,this.lineNumber=void 0,this.column=void 0,this.fileName=t,this.index=n,this.lineNumber=r,this.column=o,Object.defineProperty(this,"name",{value:new.target.name,enumerable:!1,configurable:!0})}}function p(e){return new u(e.msg,e.span.start.file.url,e.span.start.offset,e.span.start.line+1,e.span.start.col+1)}function f(o,s){var l,i;const u=e.parseTemplate(o,s.filePath,{preserveWhitespaces:!0,preserveLineEndings:!0,collectCommentNodes:!0});let f=[];Array.isArray(u.commentNodes)&&(f=u.commentNodes);const m={type:"Program",comments:(d=f,d.map(e=>({type:"Block",value:e.value,loc:n(e.sourceSpan),range:[e.sourceSpan.start.offset,e.sourceSpan.end.offset]})).sort((e,t)=>e.range[0]-t.range[0])),tokens:[],range:[0,0],loc:{start:{line:0,column:0},end:{line:0,column:0}},templateNodes:u.nodes,value:o};var d;const y=new t.ScopeManager({});new t.Scope(y,"module",null,m,!1),c(m);const g=function(e){let t=null;return e.templateNodes.forEach(e=>{const n=e.startSourceSpan||e.sourceSpan;t?n&&n.start.offset<t.start.offset&&(t=n):t=n}),t}(m),S=function(e){let t=null;return e.templateNodes.forEach(e=>{const n=e.endSourceSpan||e.sourceSpan;t?n&&n.end.offset>t.end.offset&&(t=n):t=n}),t}(m);if(g&&S&&(m.range=[g.start.offset,S.end.offset],m.loc={start:n(g).start,end:n(S).end}),null!=(l=s.suppressParseErrors)&&!l&&null!=(i=u.errors)&&i.length)throw p(u.errors[0]);return{ast:m,scopeManager:y,visitorKeys:a,services:{convertNodeSourceSpanToLoc:n,convertElementSourceSpanToLoc:r}}}exports.TemplateParseError=u,exports.createTemplateParseError=p,exports.parse=function(e,t){return f(e,t).ast},exports.parseForESLint=f;
@@ -27,9 +27,11 @@ export declare class TemplateParseError extends Error {
27
27
  constructor(message: string, fileName: string, index: number, lineNumber: number, column: number);
28
28
  }
29
29
  export declare function createTemplateParseError(parseError: ParseError): TemplateParseError;
30
- declare function parseForESLint(code: string, options: {
30
+ export interface ParserOptions {
31
31
  filePath: string;
32
- }): {
32
+ suppressParseErrors?: boolean;
33
+ }
34
+ declare function parseForESLint(code: string, options: ParserOptions): {
33
35
  ast: AST;
34
36
  scopeManager: ScopeManager;
35
37
  visitorKeys: VisitorKeys;
@@ -39,6 +41,4 @@ declare function parseForESLint(code: string, options: {
39
41
  };
40
42
  };
41
43
  export { parseForESLint };
42
- export declare function parse(code: string, options: {
43
- filePath: string;
44
- }): AST;
44
+ export declare function parse(code: string, options: ParserOptions): AST;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@angular-eslint/template-parser",
3
- "version": "13.2.1-alpha.3+c3f3120",
3
+ "version": "13.2.1-alpha.4+417bee6",
4
4
  "description": "Angular Template parser for ESLint",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -17,12 +17,12 @@
17
17
  "LICENSE"
18
18
  ],
19
19
  "dependencies": {
20
- "@angular-eslint/bundled-angular-compiler": "13.2.1-alpha.3+c3f3120",
20
+ "@angular-eslint/bundled-angular-compiler": "13.2.1-alpha.4+417bee6",
21
21
  "eslint-scope": "^5.1.0"
22
22
  },
23
23
  "peerDependencies": {
24
24
  "eslint": "^7.0.0 || ^8.0.0",
25
25
  "typescript": "*"
26
26
  },
27
- "gitHead": "c3f3120b57f7dfe7ff1ff3f3a8791b2cf988e905"
27
+ "gitHead": "417bee66dbae5c55d29966de5ca6e86b52075cb8"
28
28
  }