eslint-plugin-vue-2-object-reactivity
Advanced tools
Comparing version 1.2.0 to 1.3.0
@@ -1,1 +0,1 @@ | ||
var m=require("@typescript-eslint/experimental-utils"),e=require("eslint-etc"),p=require("typescript"),s=(...n)=>process.env.DEBUG&&console.log(...n),E=m.ESLintUtils.RuleCreator(()=>"https://github.com/Maxim-Mazurok/eslint-plugin-vue-2-object-reactivity")({name:"require-vue-set",meta:{type:"problem",docs:{description:"Require `Vue.set()` for object changes",category:"Possible Errors",recommended:"error"},messages:{useVueSet:"Use `Vue.set()` for changing objects in state"},schema:[]},defaultOptions:[],create:n=>{let{esTreeNodeToTSNodeMap:f,tsNodeToESTreeNodeMap:h}=m.ESLintUtils.getParserServices(n),S=(t,a)=>{(0,p.isObjectLiteralExpression)(t)&&t.properties.map(i=>{if((0,p.isMethodDeclaration)(i)&&(s(`Mutation name: ${i.name.getText()}`),i.parameters.length>=1)){let b=i.parameters[0].name.getText();s(`State parameter name: ${b}`);let g=i.body;if(g!==void 0){let v=n.getScope(),k=h.get(g),u=v.childScopes.find(c=>(0,e.isFunctionExpression)(c.block)&&c.block.body===k);if(u!==void 0){let c=u.variables.find(T=>T.name===b);c!==void 0&&u.references.filter(d=>d.resolved===c).forEach(d=>{let l=d.identifier.parent;if(l!==void 0&&(0,e.isMemberExpression)(l)){let o=l.parent;if(o!==void 0&&(0,e.isCallExpression)(o)&&(0,e.isMemberExpression)(o.callee)&&(0,e.isIdentifier)(o.callee.object)&&(0,e.isIdentifier)(o.callee.property)){o.callee.object.name==="Vue"&&o.callee.property.name,s("Yay, Vue.set(state) found!");return}else s("Vue.set not found...");let r=l;do{if(r.parent===void 0)break;r=r.parent,s({assignmentExpression:r})}while(r!==null&&(0,e.isMemberExpression)(r)&&!(0,e.isAssignmentExpression)(r));s("Oh-oh, state.object.something = ... found!"),n.report({node:a,loc:{start:l.loc.start,end:r.loc.end},messageId:"useVueSet"})}})}}}})};function y(t){let a=f.get(t.value);S(a,t)}function V(t){let a=f.get(t.init);S(a,t)}return{'Property[key.name="mutations"][value.type="ObjectExpression"][value.properties.length!=0]':y,"VariableDeclaration > [id.name=mutations]":V}}});module.exports={rules:{"require-vue-set":E}}; | ||
var d=require("@typescript-eslint/experimental-utils"),e=require("eslint-etc"),p=require("typescript"),s=(...n)=>process.env.DEBUG&&console.log(...n),h=d.ESLintUtils.RuleCreator(()=>"https://github.com/Maxim-Mazurok/eslint-plugin-vue-2-object-reactivity")({name:"require-vue-set",meta:{type:"problem",docs:{description:"Require `Vue.set()` for object changes",category:"Possible Errors",recommended:"error"},messages:{useVueSet:"Use `Vue.set()` for changing objects in state"},schema:[]},defaultOptions:[],create:n=>{let{esTreeNodeToTSNodeMap:f,tsNodeToESTreeNodeMap:y}=d.ESLintUtils.getParserServices(n),S=(r,a)=>{(0,p.isObjectLiteralExpression)(r)&&r.properties.map(i=>{if((0,p.isMethodDeclaration)(i)&&(s(`Mutation name: ${i.name.getText()}`),i.parameters.length>=1)){let b=i.parameters[0].name.getText();s(`State parameter name: ${b}`);let g=i.body;if(g!==void 0){let k=n.getScope(),x=y.get(g),u=k.childScopes.find(c=>(0,e.isFunctionExpression)(c.block)&&c.block.body===x);if(u!==void 0){let c=u.variables.find(E=>E.name===b);c!==void 0&&u.references.filter(m=>m.resolved===c).forEach(m=>{let l=m.identifier.parent;if(l!==void 0&&(0,e.isMemberExpression)(l)){let o=l.parent;if(o!==void 0&&(0,e.isCallExpression)(o)&&(0,e.isMemberExpression)(o.callee)&&(0,e.isIdentifier)(o.callee.object)&&(0,e.isIdentifier)(o.callee.property)){o.callee.object.name==="Vue"&&o.callee.property.name,s("Yay, Vue.set(state) found!");return}else s("Vue.set not found...");let t=l,T=0;do{if(t.parent===void 0)break;(0,e.isMemberExpression)(t)&&T++,t=t.parent,s({assignmentExpression:t})}while(t!==null&&(0,e.isMemberExpression)(t)&&!(0,e.isAssignmentExpression)(t));if(T<=1){s("assignment to prop, nor prop of prop, which is fine");return}s("Oh-oh, state.object.something = ... found!"),n.report({node:a,loc:{start:l.loc.start,end:t.loc.end},messageId:"useVueSet"})}})}}}})};function V(r){let a=f.get(r.value);S(a,r)}function v(r){let a=f.get(r.init);S(a,r)}return{'Property[key.name="mutations"][value.type="ObjectExpression"][value.properties.length!=0]':V,"VariableDeclaration > [id.name=mutations]":v}}});module.exports={rules:{"require-vue-set":h}}; |
{ | ||
"name": "eslint-plugin-vue-2-object-reactivity", | ||
"version": "1.2.0", | ||
"version": "1.3.0", | ||
"description": "These rules aim to solve the problem with Vue 2 Object Reactivity", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
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
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
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
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Found 1 instance in 1 package
14214
4
9