solhint-plugin-mud 2.2.18-f0433092876e2ac9b5b12cd0ecae9c120a2d0368 → 2.2.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs ADDED
@@ -0,0 +1,95 @@
1
+ var __getOwnPropNames = Object.getOwnPropertyNames;
2
+ var __esm = (fn, res) => function __init() {
3
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
4
+ };
5
+ var __commonJS = (cb, mod) => function __require() {
6
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
7
+ };
8
+
9
+ // src/rules/NoMsgSender.ts
10
+ var NoMsgSender;
11
+ var init_NoMsgSender = __esm({
12
+ "src/rules/NoMsgSender.ts"() {
13
+ "use strict";
14
+ NoMsgSender = class {
15
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
16
+ constructor(reporter, config) {
17
+ this.ruleId = "no-msg-sender";
18
+ this.isSystemOrLibrary = false;
19
+ this.reporter = reporter;
20
+ this.config = config;
21
+ }
22
+ ContractDefinition(node) {
23
+ const { name, kind } = node;
24
+ this.isSystemOrLibrary = kind === "library" || kind === "contract" && name.endsWith("System");
25
+ }
26
+ "ContractDefinition:exit"() {
27
+ this.isSystemOrLibrary = false;
28
+ }
29
+ MemberAccess(node) {
30
+ const { expression, memberName } = node;
31
+ if (expression.type === "Identifier" && memberName === "sender") {
32
+ this.reporter.error(
33
+ node,
34
+ this.ruleId,
35
+ `Systems and their libraries should use "_msgSender()" or "_world()" instead of "msg.sender".`
36
+ );
37
+ }
38
+ }
39
+ };
40
+ }
41
+ });
42
+
43
+ // src/rules/SystemFileName.ts
44
+ import path from "path";
45
+ import { visit } from "@solidity-parser/parser";
46
+ var SystemFileName;
47
+ var init_SystemFileName = __esm({
48
+ "src/rules/SystemFileName.ts"() {
49
+ "use strict";
50
+ SystemFileName = class {
51
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
52
+ constructor(reporter, config, inputSrc, fileName) {
53
+ this.ruleId = "system-file-name";
54
+ this.isSystemFile = false;
55
+ this.reporter = reporter;
56
+ this.config = config;
57
+ this.expectedContractName = path.basename(fileName, ".sol");
58
+ if (this.expectedContractName.endsWith("System") && this.expectedContractName !== "System" && !this.expectedContractName.match(/^I[A-Z]/)) {
59
+ this.isSystemFile = true;
60
+ }
61
+ }
62
+ SourceUnit(node) {
63
+ if (!this.isSystemFile) return;
64
+ const expectedContractName = this.expectedContractName;
65
+ let withMatchingContract = false;
66
+ visit(node, {
67
+ ContractDefinition(node2) {
68
+ const { name, kind } = node2;
69
+ if (kind === "contract" && name === expectedContractName) {
70
+ withMatchingContract = true;
71
+ }
72
+ }
73
+ });
74
+ if (!withMatchingContract) {
75
+ this.reporter.error(
76
+ node,
77
+ this.ruleId,
78
+ `System file must contain a contract with a matching name "${expectedContractName}"`
79
+ );
80
+ }
81
+ }
82
+ };
83
+ }
84
+ });
85
+
86
+ // src/index.ts
87
+ var require_src = __commonJS({
88
+ "src/index.ts"(exports, module) {
89
+ init_NoMsgSender();
90
+ init_SystemFileName();
91
+ module.exports = [NoMsgSender, SystemFileName];
92
+ }
93
+ });
94
+ export default require_src();
95
+ //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/rules/NoMsgSender.ts","../src/rules/SystemFileName.ts","../src/index.ts"],"sourcesContent":["import type { ContractDefinition, MemberAccess } from \"@solidity-parser/parser/dist/src/ast-types\";\nimport { SolhintRule } from \"../solhintTypes\";\n\nexport class NoMsgSender implements SolhintRule {\n ruleId = \"no-msg-sender\";\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n reporter: any;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n config: any;\n\n isSystemOrLibrary = false;\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n constructor(reporter: any, config: any) {\n this.reporter = reporter;\n this.config = config;\n }\n\n ContractDefinition(node: ContractDefinition) {\n const { name, kind } = node;\n\n this.isSystemOrLibrary = kind === \"library\" || (kind === \"contract\" && name.endsWith(\"System\"));\n }\n\n \"ContractDefinition:exit\"() {\n this.isSystemOrLibrary = false;\n }\n\n MemberAccess(node: MemberAccess) {\n const { expression, memberName } = node;\n if (expression.type === \"Identifier\" && memberName === \"sender\") {\n this.reporter.error(\n node,\n this.ruleId,\n `Systems and their libraries should use \"_msgSender()\" or \"_world()\" instead of \"msg.sender\".`,\n );\n }\n }\n}\n","import path from \"path\";\nimport { visit } from \"@solidity-parser/parser\";\nimport type { ContractDefinition, SourceUnit } from \"@solidity-parser/parser/dist/src/ast-types\";\nimport { SolhintRule } from \"../solhintTypes\";\n\nexport class SystemFileName implements SolhintRule {\n ruleId = \"system-file-name\";\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n reporter: any;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n config: any;\n\n expectedContractName: string;\n isSystemFile = false;\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n constructor(reporter: any, config: any, inputSrc: string, fileName: string) {\n this.reporter = reporter;\n this.config = config;\n\n this.expectedContractName = path.basename(fileName, \".sol\");\n if (\n this.expectedContractName.endsWith(\"System\") &&\n this.expectedContractName !== \"System\" &&\n !this.expectedContractName.match(/^I[A-Z]/)\n ) {\n this.isSystemFile = true;\n }\n }\n\n SourceUnit(node: SourceUnit) {\n // only systems need a matching contract\n if (!this.isSystemFile) return;\n const expectedContractName = this.expectedContractName;\n\n // search the source file for a matching contract name\n let withMatchingContract = false;\n visit(node, {\n ContractDefinition(node: ContractDefinition) {\n const { name, kind } = node;\n\n if (kind === \"contract\" && name === expectedContractName) {\n withMatchingContract = true;\n }\n },\n });\n\n if (!withMatchingContract) {\n this.reporter.error(\n node,\n this.ruleId,\n `System file must contain a contract with a matching name \"${expectedContractName}\"`,\n );\n }\n }\n}\n","import { NoMsgSender } from \"./rules/NoMsgSender\";\nimport { SystemFileName } from \"./rules/SystemFileName\";\n\nexport =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MsgSender","reporter","config","node","name","kind","expression","memberName","import_path","import_parser","SystemFileName","reporter","config","inputSrc","fileName","path","node","expectedContractName","withMatchingContract","name","kind","NoMsgSender","SystemFileName"]}
1
+ {"version":3,"sources":["../src/rules/NoMsgSender.ts","../src/rules/SystemFileName.ts","../src/index.ts"],"sourcesContent":["import type { ContractDefinition, MemberAccess } from \"@solidity-parser/parser/dist/src/ast-types\";\nimport { SolhintRule } from \"../solhintTypes\";\n\nexport class NoMsgSender implements SolhintRule {\n ruleId = \"no-msg-sender\";\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n reporter: any;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n config: any;\n\n isSystemOrLibrary = false;\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n constructor(reporter: any, config: any) {\n this.reporter = reporter;\n this.config = config;\n }\n\n ContractDefinition(node: ContractDefinition) {\n const { name, kind } = node;\n\n this.isSystemOrLibrary = kind === \"library\" || (kind === \"contract\" && name.endsWith(\"System\"));\n }\n\n \"ContractDefinition:exit\"() {\n this.isSystemOrLibrary = false;\n }\n\n MemberAccess(node: MemberAccess) {\n const { expression, memberName } = node;\n if (expression.type === \"Identifier\" && memberName === \"sender\") {\n this.reporter.error(\n node,\n this.ruleId,\n `Systems and their libraries should use \"_msgSender()\" or \"_world()\" instead of \"msg.sender\".`,\n );\n }\n }\n}\n","import path from \"path\";\nimport { visit } from \"@solidity-parser/parser\";\nimport type { ContractDefinition, SourceUnit } from \"@solidity-parser/parser/dist/src/ast-types\";\nimport { SolhintRule } from \"../solhintTypes\";\n\nexport class SystemFileName implements SolhintRule {\n ruleId = \"system-file-name\";\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n reporter: any;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n config: any;\n\n expectedContractName: string;\n isSystemFile = false;\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n constructor(reporter: any, config: any, inputSrc: string, fileName: string) {\n this.reporter = reporter;\n this.config = config;\n\n this.expectedContractName = path.basename(fileName, \".sol\");\n if (\n this.expectedContractName.endsWith(\"System\") &&\n this.expectedContractName !== \"System\" &&\n !this.expectedContractName.match(/^I[A-Z]/)\n ) {\n this.isSystemFile = true;\n }\n }\n\n SourceUnit(node: SourceUnit) {\n // only systems need a matching contract\n if (!this.isSystemFile) return;\n const expectedContractName = this.expectedContractName;\n\n // search the source file for a matching contract name\n let withMatchingContract = false;\n visit(node, {\n ContractDefinition(node: ContractDefinition) {\n const { name, kind } = node;\n\n if (kind === \"contract\" && name === expectedContractName) {\n withMatchingContract = true;\n }\n },\n });\n\n if (!withMatchingContract) {\n this.reporter.error(\n node,\n this.ruleId,\n `System file must contain a contract with a matching name \"${expectedContractName}\"`,\n );\n }\n }\n}\n","import { NoMsgSender } from \"./rules/NoMsgSender\";\nimport { SystemFileName } from \"./rules/SystemFileName\";\n\nexport = [NoMsgSender, SystemFileName];\n"],"mappings":";;;;;;;;;AAAA,IAGa;AAHb;AAAA;AAAA;AAGO,IAAM,cAAN,MAAyC;AAAA;AAAA,MAU9C,YAAY,UAAe,QAAa;AATxC,sBAAS;AAMT,iCAAoB;AAIlB,aAAK,WAAW;AAChB,aAAK,SAAS;AAAA,MAChB;AAAA,MAEA,mBAAmB,MAA0B;AAC3C,cAAM,EAAE,MAAM,KAAK,IAAI;AAEvB,aAAK,oBAAoB,SAAS,aAAc,SAAS,cAAc,KAAK,SAAS,QAAQ;AAAA,MAC/F;AAAA,MAEA,4BAA4B;AAC1B,aAAK,oBAAoB;AAAA,MAC3B;AAAA,MAEA,aAAa,MAAoB;AAC/B,cAAM,EAAE,YAAY,WAAW,IAAI;AACnC,YAAI,WAAW,SAAS,gBAAgB,eAAe,UAAU;AAC/D,eAAK,SAAS;AAAA,YACZ;AAAA,YACA,KAAK;AAAA,YACL;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA;AAAA;;;ACtCA,OAAO,UAAU;AACjB,SAAS,aAAa;AADtB,IAKa;AALb;AAAA;AAAA;AAKO,IAAM,iBAAN,MAA4C;AAAA;AAAA,MAWjD,YAAY,UAAe,QAAa,UAAkB,UAAkB;AAV5E,sBAAS;AAOT,4BAAe;AAIb,aAAK,WAAW;AAChB,aAAK,SAAS;AAEd,aAAK,uBAAuB,KAAK,SAAS,UAAU,MAAM;AAC1D,YACE,KAAK,qBAAqB,SAAS,QAAQ,KAC3C,KAAK,yBAAyB,YAC9B,CAAC,KAAK,qBAAqB,MAAM,SAAS,GAC1C;AACA,eAAK,eAAe;AAAA,QACtB;AAAA,MACF;AAAA,MAEA,WAAW,MAAkB;AAE3B,YAAI,CAAC,KAAK,aAAc;AACxB,cAAM,uBAAuB,KAAK;AAGlC,YAAI,uBAAuB;AAC3B,cAAM,MAAM;AAAA,UACV,mBAAmBA,OAA0B;AAC3C,kBAAM,EAAE,MAAM,KAAK,IAAIA;AAEvB,gBAAI,SAAS,cAAc,SAAS,sBAAsB;AACxD,qCAAuB;AAAA,YACzB;AAAA,UACF;AAAA,QACF,CAAC;AAED,YAAI,CAAC,sBAAsB;AACzB,eAAK,SAAS;AAAA,YACZ;AAAA,YACA,KAAK;AAAA,YACL,6DAA6D,oBAAoB;AAAA,UACnF;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA;AAAA;;;ACvDA;AAAA;AAAA;AACA;AAEA,qBAAS,CAAC,aAAa,cAAc;AAAA;AAAA;","names":["node"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "solhint-plugin-mud",
3
- "version": "2.2.18-f0433092876e2ac9b5b12cd0ecae9c120a2d0368",
3
+ "version": "2.2.18",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/latticexyz/mud.git",
package/dist/index.js DELETED
@@ -1,2 +0,0 @@
1
- "use strict";var l=Object.create;var a=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var d=Object.getPrototypeOf,S=Object.prototype.hasOwnProperty;var u=(r,t,e,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of y(t))!S.call(r,s)&&s!==e&&a(r,s,{get:()=>t[s],enumerable:!(i=h(t,s))||i.enumerable});return r};var C=(r,t,e)=>(e=r!=null?l(d(r)):{},u(t||!r||!r.__esModule?a(e,"default",{value:r,enumerable:!0}):e,r));var n=class{constructor(t,e){this.ruleId="no-msg-sender";this.isSystemOrLibrary=!1;this.reporter=t,this.config=e}ContractDefinition(t){let{name:e,kind:i}=t;this.isSystemOrLibrary=i==="library"||i==="contract"&&e.endsWith("System")}"ContractDefinition:exit"(){this.isSystemOrLibrary=!1}MemberAccess(t){let{expression:e,memberName:i}=t;e.type==="Identifier"&&i==="sender"&&this.reporter.error(t,this.ruleId,'Systems and their libraries should use "_msgSender()" or "_world()" instead of "msg.sender".')}};var c=C(require("path")),m=require("@solidity-parser/parser"),o=class{constructor(t,e,i,s){this.ruleId="system-file-name";this.isSystemFile=!1;this.reporter=t,this.config=e,this.expectedContractName=c.default.basename(s,".sol"),this.expectedContractName.endsWith("System")&&this.expectedContractName!=="System"&&!this.expectedContractName.match(/^I[A-Z]/)&&(this.isSystemFile=!0)}SourceUnit(t){if(!this.isSystemFile)return;let e=this.expectedContractName,i=!1;(0,m.visit)(t,{ContractDefinition(s){let{name:p,kind:f}=s;f==="contract"&&p===e&&(i=!0)}}),i||this.reporter.error(t,this.ruleId,`System file must contain a contract with a matching name "${e}"`)}};module.exports=[n,o];
2
- //# sourceMappingURL=index.js.map
File without changes