solhint-plugin-mud 2.2.18-90aac1d4acce19ac592d47a090732dd11c1c3e7a → 2.2.18-9fa07c8489f1fbf167d0db01cd9aaa645a29c8e2
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.d.mts +32 -0
- package/dist/index.js +91 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +105 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +11 -2
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { ContractDefinition, MemberAccess, SourceUnit } from '@solidity-parser/parser/dist/src/ast-types';
|
|
2
|
+
|
|
3
|
+
interface SolhintRule {
|
|
4
|
+
ruleId: string;
|
|
5
|
+
reporter: any;
|
|
6
|
+
config: any;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
declare class NoMsgSender implements SolhintRule {
|
|
10
|
+
ruleId: string;
|
|
11
|
+
reporter: any;
|
|
12
|
+
config: any;
|
|
13
|
+
isSystemOrLibrary: boolean;
|
|
14
|
+
constructor(reporter: any, config: any);
|
|
15
|
+
ContractDefinition(node: ContractDefinition): void;
|
|
16
|
+
"ContractDefinition:exit"(): void;
|
|
17
|
+
MemberAccess(node: MemberAccess): void;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
declare class SystemFileName implements SolhintRule {
|
|
21
|
+
ruleId: string;
|
|
22
|
+
reporter: any;
|
|
23
|
+
config: any;
|
|
24
|
+
expectedContractName: string;
|
|
25
|
+
isSystemFile: boolean;
|
|
26
|
+
constructor(reporter: any, config: any, inputSrc: string, fileName: string);
|
|
27
|
+
SourceUnit(node: SourceUnit): void;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
declare const _default: (typeof NoMsgSender | typeof SystemFileName)[];
|
|
31
|
+
|
|
32
|
+
export { _default as default };
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,92 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
+
for (let key of __getOwnPropNames(from))
|
|
11
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
12
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
13
|
+
}
|
|
14
|
+
return to;
|
|
15
|
+
};
|
|
16
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
17
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
18
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
19
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
20
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
+
mod
|
|
23
|
+
));
|
|
24
|
+
|
|
25
|
+
// src/rules/NoMsgSender.ts
|
|
26
|
+
var NoMsgSender = class {
|
|
27
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
28
|
+
constructor(reporter, config) {
|
|
29
|
+
this.ruleId = "no-msg-sender";
|
|
30
|
+
this.isSystemOrLibrary = false;
|
|
31
|
+
this.reporter = reporter;
|
|
32
|
+
this.config = config;
|
|
33
|
+
}
|
|
34
|
+
ContractDefinition(node) {
|
|
35
|
+
const { name, kind } = node;
|
|
36
|
+
this.isSystemOrLibrary = kind === "library" || kind === "contract" && name.endsWith("System");
|
|
37
|
+
}
|
|
38
|
+
"ContractDefinition:exit"() {
|
|
39
|
+
this.isSystemOrLibrary = false;
|
|
40
|
+
}
|
|
41
|
+
MemberAccess(node) {
|
|
42
|
+
const { expression, memberName } = node;
|
|
43
|
+
if (expression.type === "Identifier" && memberName === "sender") {
|
|
44
|
+
this.reporter.error(
|
|
45
|
+
node,
|
|
46
|
+
this.ruleId,
|
|
47
|
+
`Systems and their libraries should use "_msgSender()" or "_world()" instead of "msg.sender".`
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
// src/rules/SystemFileName.ts
|
|
54
|
+
var import_path = __toESM(require("path"));
|
|
55
|
+
var import_parser = require("@solidity-parser/parser");
|
|
56
|
+
var SystemFileName = class {
|
|
57
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
58
|
+
constructor(reporter, config, inputSrc, fileName) {
|
|
59
|
+
this.ruleId = "system-file-name";
|
|
60
|
+
this.isSystemFile = false;
|
|
61
|
+
this.reporter = reporter;
|
|
62
|
+
this.config = config;
|
|
63
|
+
this.expectedContractName = import_path.default.basename(fileName, ".sol");
|
|
64
|
+
if (this.expectedContractName.endsWith("System") && this.expectedContractName !== "System" && !this.expectedContractName.match(/^I[A-Z]/)) {
|
|
65
|
+
this.isSystemFile = true;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
SourceUnit(node) {
|
|
69
|
+
if (!this.isSystemFile) return;
|
|
70
|
+
const expectedContractName = this.expectedContractName;
|
|
71
|
+
let withMatchingContract = false;
|
|
72
|
+
(0, import_parser.visit)(node, {
|
|
73
|
+
ContractDefinition(node2) {
|
|
74
|
+
const { name, kind } = node2;
|
|
75
|
+
if (kind === "contract" && name === expectedContractName) {
|
|
76
|
+
withMatchingContract = true;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
if (!withMatchingContract) {
|
|
81
|
+
this.reporter.error(
|
|
82
|
+
node,
|
|
83
|
+
this.ruleId,
|
|
84
|
+
`System file must contain a contract with a matching name "${expectedContractName}"`
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
// src/index.ts
|
|
91
|
+
module.exports = [NoMsgSender, SystemFileName];
|
|
2
92
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -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 = [NoMsgSender, SystemFileName];\n"],"mappings":"
|
|
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":";;;;;;;;;;;;;;;;;;;;;;;;;AAGO,IAAM,cAAN,MAAyC;AAAA;AAAA,EAU9C,YAAY,UAAe,QAAa;AATxC,kBAAS;AAMT,6BAAoB;AAIlB,SAAK,WAAW;AAChB,SAAK,SAAS;AAAA,EAChB;AAAA,EAEA,mBAAmB,MAA0B;AAC3C,UAAM,EAAE,MAAM,KAAK,IAAI;AAEvB,SAAK,oBAAoB,SAAS,aAAc,SAAS,cAAc,KAAK,SAAS,QAAQ;AAAA,EAC/F;AAAA,EAEA,4BAA4B;AAC1B,SAAK,oBAAoB;AAAA,EAC3B;AAAA,EAEA,aAAa,MAAoB;AAC/B,UAAM,EAAE,YAAY,WAAW,IAAI;AACnC,QAAI,WAAW,SAAS,gBAAgB,eAAe,UAAU;AAC/D,WAAK,SAAS;AAAA,QACZ;AAAA,QACA,KAAK;AAAA,QACL;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;;;ACtCA,kBAAiB;AACjB,oBAAsB;AAIf,IAAM,iBAAN,MAA4C;AAAA;AAAA,EAWjD,YAAY,UAAe,QAAa,UAAkB,UAAkB;AAV5E,kBAAS;AAOT,wBAAe;AAIb,SAAK,WAAW;AAChB,SAAK,SAAS;AAEd,SAAK,uBAAuB,YAAAA,QAAK,SAAS,UAAU,MAAM;AAC1D,QACE,KAAK,qBAAqB,SAAS,QAAQ,KAC3C,KAAK,yBAAyB,YAC9B,CAAC,KAAK,qBAAqB,MAAM,SAAS,GAC1C;AACA,WAAK,eAAe;AAAA,IACtB;AAAA,EACF;AAAA,EAEA,WAAW,MAAkB;AAE3B,QAAI,CAAC,KAAK,aAAc;AACxB,UAAM,uBAAuB,KAAK;AAGlC,QAAI,uBAAuB;AAC3B,6BAAM,MAAM;AAAA,MACV,mBAAmBC,OAA0B;AAC3C,cAAM,EAAE,MAAM,KAAK,IAAIA;AAEvB,YAAI,SAAS,cAAc,SAAS,sBAAsB;AACxD,iCAAuB;AAAA,QACzB;AAAA,MACF;AAAA,IACF,CAAC;AAED,QAAI,CAAC,sBAAsB;AACzB,WAAK,SAAS;AAAA,QACZ;AAAA,QACA,KAAK;AAAA,QACL,6DAA6D,oBAAoB;AAAA,MACnF;AAAA,IACF;AAAA,EACF;AACF;;;ACpDA,iBAAS,CAAC,aAAa,cAAc;","names":["path","node"]}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
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
|
+
// ../../node_modules/.pnpm/tsup@8.3.0_@microsoft+api-extractor@7.47.7_@types+node@20.17.16__jiti@1.21.6_postcss@8.5.1_ts_rihtmhm6tp3cagz6w7ivhbdyn4/node_modules/tsup/assets/esm_shims.js
|
|
10
|
+
var init_esm_shims = __esm({
|
|
11
|
+
"../../node_modules/.pnpm/tsup@8.3.0_@microsoft+api-extractor@7.47.7_@types+node@20.17.16__jiti@1.21.6_postcss@8.5.1_ts_rihtmhm6tp3cagz6w7ivhbdyn4/node_modules/tsup/assets/esm_shims.js"() {
|
|
12
|
+
"use strict";
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
// src/rules/NoMsgSender.ts
|
|
17
|
+
var NoMsgSender;
|
|
18
|
+
var init_NoMsgSender = __esm({
|
|
19
|
+
"src/rules/NoMsgSender.ts"() {
|
|
20
|
+
"use strict";
|
|
21
|
+
init_esm_shims();
|
|
22
|
+
NoMsgSender = class {
|
|
23
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
24
|
+
constructor(reporter, config) {
|
|
25
|
+
this.ruleId = "no-msg-sender";
|
|
26
|
+
this.isSystemOrLibrary = false;
|
|
27
|
+
this.reporter = reporter;
|
|
28
|
+
this.config = config;
|
|
29
|
+
}
|
|
30
|
+
ContractDefinition(node) {
|
|
31
|
+
const { name, kind } = node;
|
|
32
|
+
this.isSystemOrLibrary = kind === "library" || kind === "contract" && name.endsWith("System");
|
|
33
|
+
}
|
|
34
|
+
"ContractDefinition:exit"() {
|
|
35
|
+
this.isSystemOrLibrary = false;
|
|
36
|
+
}
|
|
37
|
+
MemberAccess(node) {
|
|
38
|
+
const { expression, memberName } = node;
|
|
39
|
+
if (expression.type === "Identifier" && memberName === "sender") {
|
|
40
|
+
this.reporter.error(
|
|
41
|
+
node,
|
|
42
|
+
this.ruleId,
|
|
43
|
+
`Systems and their libraries should use "_msgSender()" or "_world()" instead of "msg.sender".`
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
// src/rules/SystemFileName.ts
|
|
52
|
+
import path from "path";
|
|
53
|
+
import { visit } from "@solidity-parser/parser";
|
|
54
|
+
var SystemFileName;
|
|
55
|
+
var init_SystemFileName = __esm({
|
|
56
|
+
"src/rules/SystemFileName.ts"() {
|
|
57
|
+
"use strict";
|
|
58
|
+
init_esm_shims();
|
|
59
|
+
SystemFileName = class {
|
|
60
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
61
|
+
constructor(reporter, config, inputSrc, fileName) {
|
|
62
|
+
this.ruleId = "system-file-name";
|
|
63
|
+
this.isSystemFile = false;
|
|
64
|
+
this.reporter = reporter;
|
|
65
|
+
this.config = config;
|
|
66
|
+
this.expectedContractName = path.basename(fileName, ".sol");
|
|
67
|
+
if (this.expectedContractName.endsWith("System") && this.expectedContractName !== "System" && !this.expectedContractName.match(/^I[A-Z]/)) {
|
|
68
|
+
this.isSystemFile = true;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
SourceUnit(node) {
|
|
72
|
+
if (!this.isSystemFile) return;
|
|
73
|
+
const expectedContractName = this.expectedContractName;
|
|
74
|
+
let withMatchingContract = false;
|
|
75
|
+
visit(node, {
|
|
76
|
+
ContractDefinition(node2) {
|
|
77
|
+
const { name, kind } = node2;
|
|
78
|
+
if (kind === "contract" && name === expectedContractName) {
|
|
79
|
+
withMatchingContract = true;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
if (!withMatchingContract) {
|
|
84
|
+
this.reporter.error(
|
|
85
|
+
node,
|
|
86
|
+
this.ruleId,
|
|
87
|
+
`System file must contain a contract with a matching name "${expectedContractName}"`
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
// src/index.ts
|
|
96
|
+
var require_src = __commonJS({
|
|
97
|
+
"src/index.ts"(exports, module) {
|
|
98
|
+
init_esm_shims();
|
|
99
|
+
init_NoMsgSender();
|
|
100
|
+
init_SystemFileName();
|
|
101
|
+
module.exports = [NoMsgSender, SystemFileName];
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
export default require_src();
|
|
105
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../node_modules/.pnpm/tsup@8.3.0_@microsoft+api-extractor@7.47.7_@types+node@20.17.16__jiti@1.21.6_postcss@8.5.1_ts_rihtmhm6tp3cagz6w7ivhbdyn4/node_modules/tsup/assets/esm_shims.js","../src/rules/NoMsgSender.ts","../src/rules/SystemFileName.ts","../src/index.ts"],"sourcesContent":["// Shim globals in esm bundle\nimport { fileURLToPath } from 'url'\nimport path from 'path'\n\nconst getFilename = () => fileURLToPath(import.meta.url)\nconst getDirname = () => path.dirname(getFilename())\n\nexport const __dirname = /* @__PURE__ */ getDirname()\nexport const __filename = /* @__PURE__ */ getFilename()\n","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;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAGa;AAHb;AAAA;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;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;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-
|
|
3
|
+
"version": "2.2.18-9fa07c8489f1fbf167d0db01cd9aaa645a29c8e2",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/latticexyz/mud.git",
|
|
@@ -8,7 +8,16 @@
|
|
|
8
8
|
},
|
|
9
9
|
"license": "MIT",
|
|
10
10
|
"exports": {
|
|
11
|
-
".":
|
|
11
|
+
".": {
|
|
12
|
+
"import": {
|
|
13
|
+
"import": "./dist/index.js",
|
|
14
|
+
"types": "./dist/index.d.ts"
|
|
15
|
+
},
|
|
16
|
+
"require": {
|
|
17
|
+
"require": "./dist/index.cjs",
|
|
18
|
+
"types": "./dist/index.d.cts"
|
|
19
|
+
}
|
|
20
|
+
}
|
|
12
21
|
},
|
|
13
22
|
"typesVersions": {
|
|
14
23
|
"*": {
|