eslint-plugin-vue-2-object-reactivity
Advanced tools
Comparing version 1.3.1 to 1.4.0
@@ -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": { |
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
5887
3
+ Added@eslint/eslintrc@2.1.4(transitive)
+ Added@eslint/js@8.57.1(transitive)
+ Added@humanwhocodes/config-array@0.13.0(transitive)
+ Added@humanwhocodes/object-schema@2.0.3(transitive)
+ Added@types/semver@7.5.8(transitive)
+ Added@typescript-eslint/experimental-utils@5.62.0(transitive)
+ Added@typescript-eslint/scope-manager@5.62.0(transitive)
+ Added@typescript-eslint/types@5.62.0(transitive)
+ Added@typescript-eslint/typescript-estree@5.62.0(transitive)
+ Added@typescript-eslint/utils@5.62.0(transitive)
+ Added@typescript-eslint/visitor-keys@5.62.0(transitive)
+ Added@ungap/structured-clone@1.2.0(transitive)
+ Addedeslint@8.57.1(transitive)
+ Addedeslint-etc@5.2.1(transitive)
+ Addedeslint-scope@7.2.2(transitive)
+ Addedespree@9.6.1(transitive)
+ Addedgraphemer@1.4.0(transitive)
+ Addedis-path-inside@3.0.3(transitive)
- Removed@babel/code-frame@7.12.11(transitive)
- Removed@babel/helper-validator-identifier@7.25.9(transitive)
- Removed@babel/highlight@7.25.9(transitive)
- Removed@eslint/config-array@0.18.0(transitive)
- Removed@eslint/core@0.7.0(transitive)
- Removed@eslint/eslintrc@0.4.33.1.0(transitive)
- Removed@eslint/js@9.14.0(transitive)
- Removed@eslint/object-schema@2.1.4(transitive)
- Removed@eslint/plugin-kit@0.2.2(transitive)
- Removed@humanfs/core@0.19.1(transitive)
- Removed@humanfs/node@0.16.6(transitive)
- Removed@humanwhocodes/config-array@0.5.0(transitive)
- Removed@humanwhocodes/object-schema@1.2.1(transitive)
- Removed@humanwhocodes/retry@0.3.10.4.1(transitive)
- Removed@types/estree@1.0.6(transitive)
- Removed@typescript-eslint/experimental-utils@4.33.0(transitive)
- Removed@typescript-eslint/scope-manager@4.33.0(transitive)
- Removed@typescript-eslint/types@4.33.0(transitive)
- Removed@typescript-eslint/typescript-estree@4.33.0(transitive)
- Removed@typescript-eslint/visitor-keys@4.33.0(transitive)
- Removedacorn@7.4.1(transitive)
- Removedajv@8.17.1(transitive)
- Removedansi-colors@4.1.3(transitive)
- Removedansi-styles@3.2.1(transitive)
- Removedargparse@1.0.10(transitive)
- Removedastral-regex@2.0.0(transitive)
- Removedchalk@2.4.2(transitive)
- Removedcolor-convert@1.9.3(transitive)
- Removedcolor-name@1.1.3(transitive)
- Removedenquirer@2.4.1(transitive)
- Removedescape-string-regexp@1.0.5(transitive)
- Removedeslint@7.32.09.14.0(transitive)
- Removedeslint-etc@4.2.6(transitive)
- Removedeslint-scope@8.2.0(transitive)
- Removedeslint-utils@2.1.03.0.0(transitive)
- Removedeslint-visitor-keys@1.3.02.1.04.2.0(transitive)
- Removedespree@10.3.07.3.1(transitive)
- Removedesprima@4.0.1(transitive)
- Removedfast-uri@3.0.3(transitive)
- Removedfile-entry-cache@8.0.0(transitive)
- Removedflat-cache@4.0.1(transitive)
- Removedfunctional-red-black-tree@1.0.1(transitive)
- Removedglobals@14.0.0(transitive)
- Removedhas-flag@3.0.0(transitive)
- Removedignore@4.0.6(transitive)
- Removedjs-tokens@4.0.0(transitive)
- Removedjs-yaml@3.14.1(transitive)
- Removedjson-schema-traverse@1.0.0(transitive)
- Removedlodash.truncate@4.4.2(transitive)
- Removedpicocolors@1.1.1(transitive)
- Removedprogress@2.0.3(transitive)
- Removedregexpp@3.2.0(transitive)
- Removedrequire-from-string@2.0.2(transitive)
- Removedslice-ansi@4.0.0(transitive)
- Removedsprintf-js@1.0.3(transitive)
- Removedsupports-color@5.5.0(transitive)
- Removedtable@6.8.2(transitive)
- Removedv8-compile-cache@2.4.0(transitive)
Updatedeslint-etc@^5.2.0