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.33 to 0.1.0-beta.1

8

dist/index.d.ts

@@ -14,10 +14,10 @@ import { RULE_NAME as bananaInABoxRuleName } from './rules/banana-in-a-box';

rules: {
[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", [{
"banana-in-a-box": import("@typescript-eslint/experimental-utils/dist/ts-eslint/Rule").RuleModule<"bananaInABox", [], import("@typescript-eslint/experimental-utils/dist/ts-eslint/Rule").RuleListener>;
"cyclomatic-complexity": import("@typescript-eslint/experimental-utils/dist/ts-eslint/Rule").RuleModule<"cyclomaticComplexity", [{
maxComplexity: number;
}], import("@typescript-eslint/experimental-utils/dist/ts-eslint/Rule").RuleListener>;
[noCallExpressionRule]: import("@typescript-eslint/experimental-utils/dist/ts-eslint/Rule").RuleModule<"noCallExpression", [], 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>;
"no-call-expression": import("@typescript-eslint/experimental-utils/dist/ts-eslint/Rule").RuleModule<"noCallExpression", [], import("@typescript-eslint/experimental-utils/dist/ts-eslint/Rule").RuleListener>;
"no-negated-async": 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>;
};
};
export default _default;

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

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),o=a.statements.filter(function(e){return t.isClassDeclaration(e)});if(!o||!o.length)return[e];for(var i=[],s=0,c=o;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 d=u[l];t.isCallExpression(d.expression)&&t.isIdentifier(d.expression.expression)&&"Component"===d.expression.expression.text&&i.push(d)}}if(!i||!i.length)return[e];if(i.length>1)throw new Error("@angular-eslint/eslint-plugin-template currently only supports 1 Component per file");var m=i[0];if(!t.isDecorator(m)||!t.isCallExpression(m.expression)||1!==m.expression.arguments.length)return[e];var g=m.expression.arguments[0];if(!t.isObjectLiteralExpression(g))return[e];var f=g.properties.find(function(e){return e&&e.name&&"template"===e.name.getText()});if(g.properties.find(function(e){return e&&e.name&&"templateUrl"===e.name.getText()})||!f)return[e];if(!t.isPropertyAssignment(f)||!t.isStringLiteralLike(f.initializer))return[e];var x=f.initializer.text,y=function(e,t){var n=e.indexOf(t);return[n,n+t.length]}(e,x);return r.set(n,{range:y,lineAndCharacter:{start:a.getLineAndCharacterOfPosition(y[0]),end:a.getLineAndCharacterOfPosition(y[1])}}),[e,{text:x,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 o=r.get(t);return o?n.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 t=o.range[0];return e.fix.range=[t+e.fix.range[0],t+e.fix.range[1]],e})):n},supportsAutofix:!0}},o=n.ESLintUtils.RuleCreator(function(){return""});function i(e){if(!e.parserServices||!e.parserServices.defineTemplateBodyVisitor||!e.parserServices.convertNodeSourceSpanToLoc)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:"error"},fixable:"code",schema:[],messages:{bananaInABox:"Invalid binding syntax. Use [(expr)] instead"}},defaultOptions:[],create:function(e){var t=i(e),n=e.getSourceCode();return t.defineTemplateBodyVisitor({BoundEvent:function(r){var a=r.name.match(c);if(a){var o="[("+a[1]+")]",i=t.convertNodeSourceSpanToLoc(r.sourceSpan),s=n.getIndexFromLoc(i.start);e.report({messageId:"bananaInABox",loc:i,fix:function(e){return e.replaceTextRange([s,"(".length+s+")".length+r.name.length],o)}})}}})}}),l=["ngForOf","ngIf","ngSwitchCase"],u=["ngSwitchDefault"],d=o({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=i(e),o=n.maxComplexity,s=function(t){if(!((r+=1)<=o)){var n=a.convertNodeSourceSpanToLoc(t.sourceSpan);e.report({messageId:"cyclomaticComplexity",loc:n,data:{maxComplexity:o}})}};return a.defineTemplateBodyVisitor({BoundAttribute:function(e){l.includes(e.name)&&s(e)},TextAttribute:function(e){u.includes(e.name)&&s(e)}})}}),m=new Set(["$any"]),g=o({name:"no-call-expression",meta:{type:"suggestion",docs:{description:"Disallows calling expressions in templates, except for output handlers.",category:"Best Practices",recommended:!1},schema:[],messages:{noCallExpression:"Avoid calling expressions in templates."}},defaultOptions:[],create:function(e){var t=i(e),n=e.getSourceCode();return t.defineTemplateBodyVisitor({MethodCall:function(t){if(!m.has(t.name)&&"BoundEvent"!==t.parent.parent.type){var r="Interpolation"===t.parent.type?-1:0,a=n.getLocFromIndex(t.sourceSpan.start),o=n.getLocFromIndex(t.sourceSpan.end+r);e.report({messageId:"noCallExpression",loc:{start:a,end:o}})}}})}}),f=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:"error"},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=i(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)),o=r.getLocFromIndex(t.parent.sourceSpan.end+n);e.report({messageId:"noLooseEquality",loc:{start:a,end:o}})}else{var i="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+i);e.report({messageId:"noNegatedAsync",loc:{start:s,end:c}})}},t))}}),x={processors:a,rules:(s={},s["banana-in-a-box"]=p,s["cyclomatic-complexity"]=d,s["no-call-expression"]=g,s["no-negated-async"]=f,s)};module.exports=x;
var e,t=(e=require("typescript"))&&"object"==typeof e&&"default"in e?e.default:e,n=require("@typescript-eslint/experimental-utils");const r=new Map;var o={"extract-inline-html":{preprocess:function(e,n){if(!n.endsWith(".component.ts"))return[e];try{const o=t.createSourceFile(n,e,t.ScriptTarget.Latest,!0),s=o.statements.filter(e=>t.isClassDeclaration(e));if(!s||!s.length)return[e];const a=[];for(const e of s)if(e.decorators)for(const n of e.decorators)t.isCallExpression(n.expression)&&t.isIdentifier(n.expression.expression)&&"Component"===n.expression.expression.text&&a.push(n);if(!a||!a.length)return[e];if(a.length>1)throw new Error("@angular-eslint/eslint-plugin-template currently only supports 1 Component per file");const i=a[0];if(!t.isDecorator(i)||!t.isCallExpression(i.expression)||1!==i.expression.arguments.length)return[e];const c=i.expression.arguments[0];if(!t.isObjectLiteralExpression(c))return[e];const p=c.properties.find(e=>e&&e.name&&"template"===e.name.getText());if(c.properties.find(e=>e&&e.name&&"templateUrl"===e.name.getText())||!p)return[e];if(!t.isPropertyAssignment(p)||!t.isStringLiteralLike(p.initializer))return[e];const l=p.initializer.text,d=function(e,t){const n=e.indexOf(t);return[n,n+t.length]}(e,l);return r.set(n,{range:d,lineAndCharacter:{start:o.getLineAndCharacterOfPosition(d[0]),end:o.getLineAndCharacterOfPosition(d[1])}}),[e,{text:l,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){const n=e[0],o=e[1];if(!o||!o.length)return n;const s=r.get(t);return s?[...n,...o.map(e=>{e.line=e.line+s.lineAndCharacter.start.line,e.column=e.column,e.endLine=e.endLine+s.lineAndCharacter.start.line,e.endColumn=e.endColumn;const t=s.range[0];return e.fix.range=[t+e.fix.range[0],t+e.fix.range[1]],e})]:n},supportsAutofix:!0}};const s=n.ESLintUtils.RuleCreator(()=>"");function a(e){if(!e.parserServices||!e.parserServices.defineTemplateBodyVisitor||!e.parserServices.convertNodeSourceSpanToLoc)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}const i=/\[(.*)\]/;var c=s({name:"banana-in-a-box",meta:{type:"suggestion",docs:{description:"Ensures that the two-way data binding syntax is correct",category:"Best Practices",recommended:"error"},fixable:"code",schema:[],messages:{bananaInABox:"Invalid binding syntax. Use [(expr)] instead"}},defaultOptions:[],create(e){const t=a(e),n=e.getSourceCode();return t.defineTemplateBodyVisitor({BoundEvent(r){const o=r.name.match(i);if(!o)return;const s=`[(${o[1]})]`,a=t.convertNodeSourceSpanToLoc(r.sourceSpan),c=n.getIndexFromLoc(a.start);e.report({messageId:"bananaInABox",loc:a,fix:e=>e.replaceTextRange([c,"(".length+c+")".length+r.name.length],s)})}})}});const p=["ngForOf","ngIf","ngSwitchCase"],l=["ngSwitchDefault"];var d=s({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(e,[t]){let n=0;const r=a(e),{maxComplexity:o}=t,s=t=>{if(n+=1,n<=o)return;const s=r.convertNodeSourceSpanToLoc(t.sourceSpan);e.report({messageId:"cyclomaticComplexity",loc:s,data:{maxComplexity:o}})};return r.defineTemplateBodyVisitor({BoundAttribute(e){p.includes(e.name)&&s(e)},TextAttribute(e){l.includes(e.name)&&s(e)}})}});const m=new Set(["$any"]);var u=s({name:"no-call-expression",meta:{type:"suggestion",docs:{description:"Disallows calling expressions in templates, except for output handlers.",category:"Best Practices",recommended:!1},schema:[],messages:{noCallExpression:"Avoid calling expressions in templates."}},defaultOptions:[],create(e){const t=a(e),n=e.getSourceCode();return t.defineTemplateBodyVisitor({MethodCall(t){if(m.has(t.name)||"BoundEvent"===t.parent.parent.type)return;const r=n.getLocFromIndex(t.sourceSpan.start),o=n.getLocFromIndex(t.sourceSpan.end);e.report({messageId:"noCallExpression",loc:{start:r,end:o}})}})}}),g=s({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:"error"},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(e){const t=a(e),n=e.getSourceCode();return t.defineTemplateBodyVisitor({"BindingPipe[name=async]"(t){if("PrefixNot"!==t.parent.type)if("Binary"!==t.parent.type||"=="!==t.parent.operation);else{const r="Interpolation"===t.parent.parent.type?-1:0,o=n.getLocFromIndex(t.parent.sourceSpan.start+("Interpolation"===t.parent.parent.type?-2:-1)),s=n.getLocFromIndex(t.parent.sourceSpan.end+r);e.report({messageId:"noLooseEquality",loc:{start:o,end:s}})}else{const r="Interpolation"===t.parent.parent.type?-1:0,o=n.getLocFromIndex(t.parent.sourceSpan.start+r),s=n.getLocFromIndex(t.parent.sourceSpan.end+r);e.report({messageId:"noNegatedAsync",loc:{start:o,end:s}})}}})}});module.exports={processors:o,rules:{"banana-in-a-box":c,"cyclomatic-complexity":d,"no-call-expression":u,"no-negated-async":g}};

@@ -0,6 +1,7 @@

declare type Options = [{
maxComplexity: number;
}];
export declare type MessageIds = 'cyclomaticComplexity';
export declare const RULE_NAME = "cyclomatic-complexity";
declare const _default: import("@typescript-eslint/experimental-utils/dist/ts-eslint/Rule").RuleModule<"cyclomaticComplexity", [{
maxComplexity: number;
}], import("@typescript-eslint/experimental-utils/dist/ts-eslint/Rule").RuleListener>;
declare const _default: import("@typescript-eslint/experimental-utils/dist/ts-eslint/Rule").RuleModule<"cyclomaticComplexity", Options, import("@typescript-eslint/experimental-utils/dist/ts-eslint/Rule").RuleListener>;
export default _default;

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

export declare const createESLintRule: <TOptions extends readonly unknown[], TMessageIds extends string, TRuleListener extends import("@typescript-eslint/experimental-utils/dist/ts-eslint/Rule").RuleListener = import("@typescript-eslint/experimental-utils/dist/ts-eslint/Rule").RuleListener>({ name, meta, defaultOptions, create, }: {
export declare const createESLintRule: <TOptions extends readonly unknown[], TMessageIds extends string, TRuleListener extends import("@typescript-eslint/experimental-utils/dist/ts-eslint/Rule").RuleListener = import("@typescript-eslint/experimental-utils/dist/ts-eslint/Rule").RuleListener>({ name, meta, defaultOptions, create, }: Readonly<{
name: string;
meta: {
docs: Pick<import("@typescript-eslint/experimental-utils/dist/ts-eslint/Rule").RuleMetaDataDocs, "category" | "description" | "recommended" | "requiresTypeChecking" | "extendsBaseRule">;
docs: Pick<import("@typescript-eslint/experimental-utils/dist/ts-eslint/Rule").RuleMetaDataDocs, "category" | "description" | "recommended" | "suggestion" | "requiresTypeChecking" | "extendsBaseRule">;
} & Pick<import("@typescript-eslint/experimental-utils/dist/ts-eslint/Rule").RuleMetaData<TMessageIds>, "deprecated" | "fixable" | "messages" | "type" | "replacedBy" | "schema">;
defaultOptions: TOptions;
create: (context: import("@typescript-eslint/experimental-utils/dist/ts-eslint/Rule").RuleContext<TMessageIds, TOptions>, optionsWithDefault: TOptions) => TRuleListener;
}) => import("@typescript-eslint/experimental-utils/dist/ts-eslint/Rule").RuleModule<TMessageIds, TOptions, TRuleListener>;
defaultOptions: Readonly<TOptions>;
create: (context: Readonly<import("@typescript-eslint/experimental-utils/dist/ts-eslint/Rule").RuleContext<TMessageIds, TOptions>>, optionsWithDefault: Readonly<TOptions>) => TRuleListener;
}>) => import("@typescript-eslint/experimental-utils/dist/ts-eslint/Rule").RuleModule<TMessageIds, TOptions, TRuleListener>;
interface SourceSpan {

@@ -10,0 +10,0 @@ start: {

{
"name": "@angular-eslint/eslint-plugin-template",
"version": "0.0.1-alpha.33",
"version": "0.1.0-beta.1",
"description": "ESLint plugin for Angular Templates",

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

"scripts": {
"build": "rm -rf ./dist && microbundle --no-sourcemap --target=node --compress --format=cjs",
"build": "rm -rf ./dist && microbundle --tsconfig tsconfig.build.json --no-sourcemap --target=node --compress --format=cjs",
"test": "jest --coverage",

@@ -26,6 +26,6 @@ "typecheck": "tsc -p tsconfig.json --noEmit"

"dependencies": {
"@typescript-eslint/experimental-utils": "2.31.0"
"@typescript-eslint/experimental-utils": "3.9.0"
},
"devDependencies": {
"@angular-eslint/utils": "^0.0.1-alpha.33"
"@angular-eslint/utils": "^0.1.0-beta.1"
},

@@ -37,3 +37,3 @@ "peerDependencies": {

},
"gitHead": "dc6fb3ea654a993614b3669b1ca2f17050bf7015"
"gitHead": "6f0c87729812e4f81b9d8b856c5de9eea34f6d43"
}
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