Socket
Socket
Sign inDemoInstall

@angular-eslint/eslint-plugin-template

Package Overview
Dependencies
Maintainers
1
Versions
764
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@angular-eslint/eslint-plugin-template - npm Package Compare versions

Comparing version 0.0.1-alpha.27 to 0.0.1-alpha.28

dist/rules/cyclomatic-complexity.d.ts

10

dist/index.d.ts
import { RULE_NAME as bananaInABoxRuleName } from './rules/banana-in-a-box';
import { RULE_NAME as cyclomaticComplexityRuleName } from './rules/cyclomatic-complexity';
import { RULE_NAME as noNegatedAsyncRuleName } from './rules/no-negated-async';
declare const _default: {
processors: {
'.ts': {
preprocess: typeof import("./processors").preprocessTSFile;
postprocess: typeof import("./processors").postprocessTSFile;
'extract-inline-html': {
preprocess: typeof import("./processors").preprocessComponentFile;
postprocess: typeof import("./processors").postprocessComponentFile;
supportsAutofix: boolean;

@@ -13,2 +14,5 @@ };

[bananaInABoxRuleName]: import("@typescript-eslint/experimental-utils/dist/ts-eslint/Rule").RuleModule<"bananaInABox", [], import("@typescript-eslint/experimental-utils/dist/ts-eslint/Rule").RuleListener>;
[cyclomaticComplexityRuleName]: import("@typescript-eslint/experimental-utils/dist/ts-eslint/Rule").RuleModule<"cyclomaticComplexity", [{
maxComplexity: number;
}], import("@typescript-eslint/experimental-utils/dist/ts-eslint/Rule").RuleListener>;
[noNegatedAsyncRuleName]: import("@typescript-eslint/experimental-utils/dist/ts-eslint/Rule").RuleModule<import("./rules/no-negated-async").MessageIds, [], import("@typescript-eslint/experimental-utils/dist/ts-eslint/Rule").RuleListener>;

@@ -15,0 +19,0 @@ };

@@ -1,1 +0,1 @@

var e,n=(e=require("typescript"))&&"object"==typeof e&&"default"in e?e.default:e,t=require("@typescript-eslint/experimental-utils"),r=new Map,a={"extract-inline-html":{preprocess:function(e,t){if(!t.endsWith(".component.ts"))return[e];var a=function(e){var n=e.match(/@Component\({(\s.*\s)*}\)/);return n&&n.length?n[0]:null}(e);if(!a)return[e];if(a.includes("templateUrl")||!a.includes("template"))return[e];try{var o=function(e){return e.slice(0,e.length-1).replace("@Component(","")}(a).split(",").map(function(e){return e.split(":").map(function(e){return e.trim()})}).reduce(function(e,n){return e[n[0]]=n[1],e},{}),i=function(e,n){var t=e.indexOf(n);return[t,t+n.length]}(e,o.template),s=n.createSourceFile(t,e,n.ScriptTarget.Latest,!1);return r.set(t,{range:i,lineAndCharacter:{start:s.getLineAndCharacterOfPosition(i[0]),end:s.getLineAndCharacterOfPosition(i[1])}}),[e,{text:o.template,filename:"inline-template.component.html"}]}catch(n){return console.log(n),console.error("preprocess: ERROR could not parse @Component() metadata",t),[e]}},postprocess:function(e,n){var t=e[0],a=e[1];if(!a||!a.length)return t;var o=r.get(n);return o?t.concat(a.map(function(e){e.line=e.line+o.lineAndCharacter.start.line,e.column=e.column,e.endLine=e.endLine+o.lineAndCharacter.start.line,e.endColumn=e.endColumn;var n=o.range[0];return e.fix.range=[n+e.fix.range[0],n+e.fix.range[1]],e})):t},supportsAutofix:!0}},o=t.ESLintUtils.RuleCreator(function(){return""});function i(e){if(!e.parserServices||!e.parserServices.defineTemplateBodyVisitor)throw new Error("You have used a rule which requires '@angular-eslint/template-parser' to be used as the 'parser' in your ESLint config.");return e.parserServices}var s,c=/\[(.*)\]/,p=o({name:"banana-in-a-box",meta:{type:"suggestion",docs:{description:"Ensures that the two-way data binding syntax is correct",category:"Best Practices",recommended:!1},fixable:"code",schema:[],messages:{bananaInABox:"Invalid binding syntax. Use [(expr)] instead"}},defaultOptions:[],create:function(e){var n=i(e),t=e.getSourceCode();return n.defineTemplateBodyVisitor({BoundEvent:function(r){var a=r.name.match(c);if(a){var o="[("+a[1]+")]",i=n.convertNodeSourceSpanToLoc(r.sourceSpan),s=t.getIndexFromLoc(i.start);e.report({messageId:"bananaInABox",loc:i,fix:function(e){return e.replaceTextRange([s,"(".length+s+")".length+r.name.length],o)}})}}})}}),u=o({name:"no-negated-async",meta:{type:"suggestion",docs:{description:"Ensures that strict equality is used when evaluating negations on async pipe output",category:"Best Practices",recommended:!1},fixable:"code",schema:[],messages:{noNegatedAsync:"Async pipes should not be negated. Use (observable | async) === (false | null | undefined) to check its value instead",noLooseEquality:"Async pipes must use strict equality `===` when comparing with `false`"}},defaultOptions:[],create:function(e){var n,t=i(e),r=e.getSourceCode();return t.defineTemplateBodyVisitor(((n={})["BindingPipe[name=async]"]=function(n){if("PrefixNot"!==n.parent.type)if("Binary"!==n.parent.type||"=="!==n.parent.operation);else{var t="Interpolation"===n.parent.parent.type?-2:0,a=r.getLocFromIndex(n.parent.sourceSpan.start+("Interpolation"===n.parent.parent.type?-2:-1)),o=r.getLocFromIndex(n.parent.sourceSpan.end+t);e.report({messageId:"noLooseEquality",loc:{start:a,end:o}})}else{var i="Interpolation"===n.parent.parent.type?-2:0,s=r.getLocFromIndex(n.parent.sourceSpan.start+("Interpolation"===n.parent.parent.type?-1:-0)),c=r.getLocFromIndex(n.parent.sourceSpan.end+i);e.report({messageId:"noNegatedAsync",loc:{start:s,end:c}})}},n))}}),l={processors:a,rules:(s={},s["banana-in-a-box"]=p,s["no-negated-async"]=u,s)};module.exports=l;
var e,t=(e=require("typescript"))&&"object"==typeof e&&"default"in e?e.default:e,n=require("@typescript-eslint/experimental-utils"),r=new Map,a={"extract-inline-html":{preprocess:function(e,n){if(!n.endsWith(".component.ts"))return[e];try{var a=t.createSourceFile(n,e,t.ScriptTarget.Latest,!0),i=a.statements.filter(function(e){return t.isClassDeclaration(e)});if(!i||!i.length)return[e];for(var o=[],s=0,c=i;s<c.length;s+=1){var p=c[s];if(p.decorators)for(var l=0,u=p.decorators;l<u.length;l+=1){var m=u[l];t.isCallExpression(m)&&t.isIdentifier(m.expression)&&m.expression.getText(),o.push(m)}}if(!o||!o.length)return[e];if(o.length>1)throw new Error("@angular-eslint/eslint-plugin-template currently only supports 1 Component per file");var d=o[0];if(!t.isDecorator(d)||!t.isCallExpression(d.expression)||1!==d.expression.arguments.length)return[e];var f=d.expression.arguments[0];if(!t.isObjectLiteralExpression(f))return[e];var g=f.properties.find(function(e){return e&&e.name&&"template"===e.name.getText()});if(f.properties.find(function(e){return e&&e.name&&"templateUrl"===e.name.getText()})||!g)return[e];if(!t.isPropertyAssignment(g)||!t.isStringLiteralLike(g.initializer))return[e];var y=g.initializer.text,x=function(e,t){var n=e.indexOf(t);return[n,n+t.length]}(e,y);return r.set(n,{range:x,lineAndCharacter:{start:a.getLineAndCharacterOfPosition(x[0]),end:a.getLineAndCharacterOfPosition(x[1])}}),[e,{text:y,filename:"inline-template.component.html"}]}catch(t){if("@angular-eslint/eslint-plugin-template currently only supports 1 Component per file"===t.message)throw t;return console.log(t),console.error("preprocess: ERROR could not parse @Component() metadata",n),[e]}},postprocess:function(e,t){var n=e[0],a=e[1];if(!a||!a.length)return n;var i=r.get(t);return i?n.concat(a.map(function(e){e.line=e.line+i.lineAndCharacter.start.line,e.column=e.column,e.endLine=e.endLine+i.lineAndCharacter.start.line,e.endColumn=e.endColumn;var t=i.range[0];return e.fix.range=[t+e.fix.range[0],t+e.fix.range[1]],e})):n},supportsAutofix:!0}},i=n.ESLintUtils.RuleCreator(function(){return""});function o(e){if(!e.parserServices||!e.parserServices.defineTemplateBodyVisitor)throw new Error("You have used a rule which requires '@angular-eslint/template-parser' to be used as the 'parser' in your ESLint config.");return e.parserServices}var s,c=/\[(.*)\]/,p=i({name:"banana-in-a-box",meta:{type:"suggestion",docs:{description:"Ensures that the two-way data binding syntax is correct",category:"Best Practices",recommended:!1},fixable:"code",schema:[],messages:{bananaInABox:"Invalid binding syntax. Use [(expr)] instead"}},defaultOptions:[],create:function(e){var t=o(e),n=e.getSourceCode();return t.defineTemplateBodyVisitor({BoundEvent:function(r){var a=r.name.match(c);if(a){var i="[("+a[1]+")]",o=t.convertNodeSourceSpanToLoc(r.sourceSpan),s=n.getIndexFromLoc(o.start);e.report({messageId:"bananaInABox",loc:o,fix:function(e){return e.replaceTextRange([s,"(".length+s+")".length+r.name.length],i)}})}}})}}),l=["ngForOf","ngIf","ngSwitchCase"],u=["ngSwitchDefault"],m=i({name:"cyclomatic-complexity",meta:{type:"suggestion",docs:{description:"Checks cyclomatic complexity against a specified limit. It is a quantitative measure of the number of linearly independent paths through a program's source code",category:"Best Practices",recommended:!1},fixable:"code",schema:[{type:"object",properties:{maxComplexity:{type:"number",minimum:1}},additionalProperties:!1}],messages:{cyclomaticComplexity:"The cyclomatic complexity exceeded the defined limit of {{maxComplexity}}. Your template should be refactored."}},defaultOptions:[{maxComplexity:5}],create:function(e,t){var n=t[0],r=0,a=o(e),i=n.maxComplexity,s=function(t){if(!((r+=1)<=i)){var n=a.convertNodeSourceSpanToLoc(t.sourceSpan);e.report({messageId:"cyclomaticComplexity",loc:n,data:{maxComplexity:i}})}};return a.defineTemplateBodyVisitor({BoundAttribute:function(e){l.includes(e.name)&&s(e)},TextAttribute:function(e){u.includes(e.name)&&s(e)}})}}),d=i({name:"no-negated-async",meta:{type:"suggestion",docs:{description:"Ensures that strict equality is used when evaluating negations on async pipe output",category:"Best Practices",recommended:!1},fixable:"code",schema:[],messages:{noNegatedAsync:"Async pipes should not be negated. Use (observable | async) === (false | null | undefined) to check its value instead",noLooseEquality:"Async pipes must use strict equality `===` when comparing with `false`"}},defaultOptions:[],create:function(e){var t,n=o(e),r=e.getSourceCode();return n.defineTemplateBodyVisitor(((t={})["BindingPipe[name=async]"]=function(t){if("PrefixNot"!==t.parent.type)if("Binary"!==t.parent.type||"=="!==t.parent.operation);else{var n="Interpolation"===t.parent.parent.type?-2:0,a=r.getLocFromIndex(t.parent.sourceSpan.start+("Interpolation"===t.parent.parent.type?-2:-1)),i=r.getLocFromIndex(t.parent.sourceSpan.end+n);e.report({messageId:"noLooseEquality",loc:{start:a,end:i}})}else{var o="Interpolation"===t.parent.parent.type?-2:0,s=r.getLocFromIndex(t.parent.sourceSpan.start+("Interpolation"===t.parent.parent.type?-1:-0)),c=r.getLocFromIndex(t.parent.sourceSpan.end+o);e.report({messageId:"noNegatedAsync",loc:{start:s,end:c}})}},t))}}),f={processors:a,rules:(s={},s["banana-in-a-box"]=p,s["cyclomatic-complexity"]=m,s["no-negated-async"]=d,s)};module.exports=f;
export declare function preprocessComponentFile(text: string, filename: string): (string | {
text: any;
text: string;
filename: string;

@@ -4,0 +4,0 @@ })[];

{
"name": "@angular-eslint/eslint-plugin-template",
"version": "0.0.1-alpha.27",
"version": "0.0.1-alpha.28",
"description": "ESLint plugin for Angular Templates",

@@ -33,3 +33,3 @@ "license": "MIT",

},
"gitHead": "59b10e390149d62aae77eae8ae14316caadc71e5"
"gitHead": "d7e2961a22905c291c83af56f1647256f22c8444"
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc