@angular-eslint/template-parser 13.1.1-alpha.12 → 13.1.1-alpha.19
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
|
|
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,3 +1,4 @@
|
|
|
1
|
+
import type { ParseError } from '@angular-eslint/bundled-angular-compiler';
|
|
1
2
|
import type { TSESTree } from '@typescript-eslint/types';
|
|
2
3
|
import { ScopeManager } from 'eslint-scope';
|
|
3
4
|
import { convertElementSourceSpanToLoc, convertNodeSourceSpanToLoc } from './convert-source-span-to-loc';
|
|
@@ -18,6 +19,14 @@ interface AST extends Node, Token {
|
|
|
18
19
|
tokens: Token[];
|
|
19
20
|
templateNodes: any[];
|
|
20
21
|
}
|
|
22
|
+
export declare class TemplateParseError extends Error {
|
|
23
|
+
readonly fileName: string;
|
|
24
|
+
readonly index: number;
|
|
25
|
+
readonly lineNumber: number;
|
|
26
|
+
readonly column: number;
|
|
27
|
+
constructor(message: string, fileName: string, index: number, lineNumber: number, column: number);
|
|
28
|
+
}
|
|
29
|
+
export declare function createTemplateParseError(parseError: ParseError): TemplateParseError;
|
|
21
30
|
declare function parseForESLint(code: string, options: {
|
|
22
31
|
filePath: string;
|
|
23
32
|
}): {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@angular-eslint/template-parser",
|
|
3
|
-
"version": "13.1.1-alpha.
|
|
3
|
+
"version": "13.1.1-alpha.19+ab9b496",
|
|
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.1.1-alpha.
|
|
20
|
+
"@angular-eslint/bundled-angular-compiler": "13.1.1-alpha.19+ab9b496",
|
|
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": "
|
|
27
|
+
"gitHead": "ab9b496095c7194d614394c04548f6848c0d6aff"
|
|
28
28
|
}
|