@angular-eslint/eslint-plugin-template
Advanced tools
Comparing version 0.0.1-alpha.19 to 0.0.1-alpha.20
import { RULE_NAME as bananaInABoxRuleName } from './rules/banana-in-a-box'; | ||
import { RULE_NAME as noNegatedAsyncRuleName } from './rules/no-negated-async'; | ||
declare const _default: { | ||
@@ -12,4 +13,5 @@ processors: { | ||
[bananaInABoxRuleName]: import("@typescript-eslint/experimental-utils/dist/ts-eslint/Rule").RuleModule<"bananaInABox", [], 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>; | ||
}; | ||
}; | ||
export default _default; |
@@ -1,1 +0,1 @@ | ||
var e,n,t=(e=require("typescript"))&&"object"==typeof e&&"default"in e?e.default:e,r=require("@typescript-eslint/experimental-utils"),a=new Map,i={".ts":{preprocess:function(e,n){if(!n.endsWith(".component.ts"))return[""];var r=function(e){var n=e.match(/@Component\({(\s.*\s)*}\)/);return n&&n.length?n[0]:null}(e);if(!r)return[""];if(r.includes("templateUrl"))return[""];if(!r.includes("template"))return[""];try{var i=function(e){return e.slice(0,e.length-1).replace("@Component(","")}(r).split(",").map(function(e){return e.split(":").map(function(e){return e.trim()})}).reduce(function(e,n){return e[n[0]]=n[1],e},{}),o=function(e,n){var t=e.indexOf(n);return[t,t+n.length]}(e,i.template),s=t.createSourceFile(n,e,t.ScriptTarget.Latest,!1);return a.set(n,{range:o,lineAndCharacter:{start:s.getLineAndCharacterOfPosition(o[0]),end:s.getLineAndCharacterOfPosition(o[1])}}),[i.template]}catch(e){return console.log(e),console.error("preprocess: ERROR could not parse @Component() metadata",n),[""]}},postprocess:function(e,n){var t=e[0];if(!t.length)return t;var r=a.get(n);return r?t.map(function(e){e.line=e.line+r.lineAndCharacter.start.line,e.column=e.column,e.endLine=e.endLine+r.lineAndCharacter.start.line,e.endColumn=e.endColumn;var n=r.range[0];return e.fix.range=[n+e.fix.range[0],n+e.fix.range[1]],e}):t},supportsAutofix:!0}},o=r.ESLintUtils.RuleCreator(function(){return""}),s=/\[(.*)\]/,c=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=function(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}(e),t=e.getSourceCode();return n.defineTemplateBodyVisitor({BoundEvent:function(r){var a=r.name.match(s);if(a){var i="[("+a[1]+")]",o=n.convertNodeSourceSpanToLoc(r.sourceSpan),c=t.getIndexFromLoc(o.start);e.report({messageId:"bananaInABox",loc:o,fix:function(e){return e.replaceTextRange([c,"(".length+c+")".length+r.name.length],i)}})}}})}}),u={processors:i,rules:(n={},n["banana-in-a-box"]=c,n)};module.exports=u; | ||
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={".ts":{preprocess:function(e,t){if(!t.endsWith(".component.ts"))return[""];var a=function(e){var n=e.match(/@Component\({(\s.*\s)*}\)/);return n&&n.length?n[0]:null}(e);if(!a)return[""];if(a.includes("templateUrl"))return[""];if(!a.includes("template"))return[""];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])}}),[o.template]}catch(e){return console.log(e),console.error("preprocess: ERROR could not parse @Component() metadata",t),[""]}},postprocess:function(e,n){var t=e[0];if(!t.length)return t;var a=r.get(n);return a?t.map(function(e){e.line=e.line+a.lineAndCharacter.start.line,e.column=e.column,e.endLine=e.endLine+a.lineAndCharacter.start.line,e.endColumn=e.endColumn;var n=a.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; |
{ | ||
"name": "@angular-eslint/eslint-plugin-template", | ||
"version": "0.0.1-alpha.19", | ||
"version": "0.0.1-alpha.20", | ||
"description": "ESLint plugin for Angular Templates", | ||
@@ -28,3 +28,3 @@ "license": "MIT", | ||
}, | ||
"gitHead": "94ce0202f8135cb91cd20f1668fffe760741925a" | ||
"gitHead": "3dc94bb4e3ccdd8b0a24c3d312b21ae2348f9a3b" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
8874
75