Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

eslint-plugin-vue-2-object-reactivity

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-plugin-vue-2-object-reactivity - npm Package Compare versions

Comparing version 1.3.1 to 1.4.0

2

dist/index.js

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

var d=require("@typescript-eslint/experimental-utils"),e=require("eslint-etc"),p=require("typescript"),o=(...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)&&(o(`Mutation name: ${i.name.getText()}`),i.parameters.length>=1)){let g=i.parameters[0].name.getText();o(`State parameter name: ${g}`);let b=i.body;if(b!==void 0){let v=n.getScope(),x=y.get(b),u=v.childScopes.find(c=>(0,e.isFunctionExpression)(c.block)&&c.block.body===x);if(u!==void 0){let c=u.variables.find(E=>E.name===g);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 s=l.parent;if(s!==void 0&&(0,e.isCallExpression)(s)&&(0,e.isMemberExpression)(s.callee)&&(0,e.isIdentifier)(s.callee.object)&&(0,e.isIdentifier)(s.callee.property)){s.callee.object.name==="Vue"&&s.callee.property.name,o("Yay, Vue.set(state) found!");return}else o("Vue.set not found...");let t=l,T=0;do{if(t.parent===void 0)break;(0,e.isMemberExpression)(t)&&T++,t=t.parent,o({assignmentExpression:t})}while(t!==null&&(0,e.isMemberExpression)(t)&&!(0,e.isAssignmentExpression)(t));if(T<=1){o("assignment to prop, not prop of prop, which is fine");return}if(t===null||!(0,e.isAssignmentExpression)(t)){o("most likely `const something = state.prop.prop`");return}o("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 k(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]":k}}});module.exports={rules:{"require-vue-set":h}};
var f=require("@typescript-eslint/experimental-utils"),e=require("eslint-etc"),p=require("typescript"),o=(...n)=>process.env.DEBUG&&console.log(...n),y=f.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",recommended:"error"},messages:{useVueSet:"Use `Vue.set()` for changing objects in state"},schema:[]},defaultOptions:[],create:n=>{let{esTreeNodeToTSNodeMap:S,tsNodeToESTreeNodeMap:V}=f.ESLintUtils.getParserServices(n),g=(r,a)=>{if((0,p.isObjectLiteralExpression)(r)){let u=r.properties;u==null||u.map(i=>{if((0,p.isMethodDeclaration)(i)&&(o(`Mutation name: ${i.name.getText()}`),i.parameters.length>=1)){let b=i.parameters[0].name.getText();o(`State parameter name: ${b}`);let T=i.body;if(T!==void 0){let x=n.getScope(),N=V.get(T),d=x.childScopes.find(c=>(0,e.isFunctionExpression)(c.block)&&c.block.body===N);if(d!==void 0){let c=d.variables.find(h=>h.name===b);c!==void 0&&d.references.filter(m=>m.resolved===c).forEach(m=>{let l=m.identifier.parent;if(l!==void 0&&(0,e.isMemberExpression)(l)){let s=l.parent;if(s!==void 0&&(0,e.isCallExpression)(s)&&(0,e.isMemberExpression)(s.callee)&&(0,e.isIdentifier)(s.callee.object)&&(0,e.isIdentifier)(s.callee.property)){s.callee.object.name==="Vue"&&s.callee.property.name,o("Yay, Vue.set(state) found!");return}else o("Vue.set not found...");let t=l,E=0;do{if(t.parent===void 0)break;(0,e.isMemberExpression)(t)&&E++,t=t.parent,o({assignmentExpression:t})}while(t!==null&&(0,e.isMemberExpression)(t)&&!(0,e.isAssignmentExpression)(t));if(E<=1){o("assignment to prop, not prop of prop, which is fine");return}if(t===null||!(0,e.isAssignmentExpression)(t)){o("most likely `const something = state.prop.prop`");return}o("Oh-oh, state.object.something = ... found!"),n.report({node:a,loc:{start:l.loc.start,end:t.loc.end},messageId:"useVueSet"})}})}}}})}};function k(r){let a=S.get(r.value);g(a,r)}function v(r){let a=S.get(r.init);g(a,r)}return{'Property[key.name="mutations"][value.type="ObjectExpression"][value.properties.length!=0]':k,"VariableDeclaration > [id.name=mutations]":v}}});module.exports={rules:{"require-vue-set":y}};
{
"name": "eslint-plugin-vue-2-object-reactivity",
"version": "1.3.1",
"version": "1.4.0",
"description": "These rules aim to solve the problem with Vue 2 Object Reactivity",

@@ -32,12 +32,12 @@ "main": "./dist/index.js",

"devDependencies": {
"@types/eslint": "^7.28.0",
"@types/estree": "^0.0.50",
"@types/node": "^16.9.6",
"@typescript-eslint/parser": "^4.31.2",
"ts-node": "^10.2.1",
"typescript": "^4.4.3"
"@types/eslint": "^8.21.1",
"@types/estree": "^1.0.0",
"@types/node": "^18.13.0",
"@typescript-eslint/parser": "^5.52.0",
"ts-node": "^10.9.1",
"typescript": "^4.9.5"
},
"dependencies": {
"@typescript-eslint/experimental-utils": "^4.31.2",
"eslint-etc": "^4.2.5"
"@typescript-eslint/experimental-utils": "^5.52.0",
"eslint-etc": "^5.2.0"
},

@@ -44,0 +44,0 @@ "peerDependencies": {

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