prettier-plugin-solidity 1.4.2 → 1.4.3
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "prettier-plugin-solidity",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.3",
|
|
4
4
|
"description": "A Prettier Plugin for automatically formatting your Solidity code.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.js",
|
|
@@ -90,27 +90,27 @@
|
|
|
90
90
|
"@babel/code-frame": "^7.26.2",
|
|
91
91
|
"c8": "^10.1.3",
|
|
92
92
|
"cross-env": "^7.0.3",
|
|
93
|
-
"eslint": "^8.
|
|
93
|
+
"eslint": "^8.57.1",
|
|
94
94
|
"eslint-config-airbnb-base": "^15.0.0",
|
|
95
|
-
"eslint-config-prettier": "^
|
|
95
|
+
"eslint-config-prettier": "^10.1.2",
|
|
96
96
|
"eslint-plugin-import": "^2.31.0",
|
|
97
97
|
"esm-utils": "^4.3.0",
|
|
98
|
-
"esmock": "^2.
|
|
98
|
+
"esmock": "^2.7.0",
|
|
99
99
|
"jest": "^29.7.0",
|
|
100
|
-
"jest-light-runner": "^0.
|
|
101
|
-
"jest-snapshot-serializer-ansi": "^2.1
|
|
100
|
+
"jest-light-runner": "^0.7.8",
|
|
101
|
+
"jest-snapshot-serializer-ansi": "^2.2.1",
|
|
102
102
|
"jest-snapshot-serializer-raw": "^2.0.0",
|
|
103
103
|
"jest-watch-typeahead": "^2.2.2",
|
|
104
104
|
"lines-and-columns": "^2.0.4",
|
|
105
|
-
"prettier": "^3.
|
|
105
|
+
"prettier": "^3.5.3",
|
|
106
106
|
"proxyquire": "^2.1.3",
|
|
107
|
-
"solc": "^0.8.
|
|
108
|
-
"webpack": "^5.
|
|
107
|
+
"solc": "^0.8.29",
|
|
108
|
+
"webpack": "^5.99.7",
|
|
109
109
|
"webpack-cli": "^6.0.1"
|
|
110
110
|
},
|
|
111
111
|
"dependencies": {
|
|
112
|
-
"@solidity-parser/parser": "^0.
|
|
113
|
-
"semver": "^7.
|
|
112
|
+
"@solidity-parser/parser": "^0.20.1",
|
|
113
|
+
"semver": "^7.7.1"
|
|
114
114
|
},
|
|
115
115
|
"peerDependencies": {
|
|
116
116
|
"prettier": ">=2.3.0"
|
|
@@ -27,10 +27,19 @@ function handleContractDefinitionComments({
|
|
|
27
27
|
);
|
|
28
28
|
|
|
29
29
|
// The comment is behind the start of the Block `{}` or behind a base contract
|
|
30
|
-
if (
|
|
30
|
+
if (
|
|
31
|
+
(followingNode &&
|
|
32
|
+
(followingNode.type === 'InheritanceSpecifier' ||
|
|
33
|
+
followingNode === enclosingNode.storageLayout)) ||
|
|
34
|
+
nextCharacter === '{'
|
|
35
|
+
) {
|
|
31
36
|
// In this scenario the comment belongs to a base contract.
|
|
32
37
|
// contract A is B, /* comment for B */ C /* comment for C */ {}
|
|
33
|
-
if (
|
|
38
|
+
if (
|
|
39
|
+
precedingNode &&
|
|
40
|
+
(precedingNode.type === 'InheritanceSpecifier' ||
|
|
41
|
+
precedingNode === enclosingNode.storageLayout)
|
|
42
|
+
) {
|
|
34
43
|
addTrailingComment(precedingNode, comment);
|
|
35
44
|
return true;
|
|
36
45
|
}
|
|
@@ -6,17 +6,37 @@ import {
|
|
|
6
6
|
printSeparatedList
|
|
7
7
|
} from '../common/printer-helpers.js';
|
|
8
8
|
|
|
9
|
-
const { group, line,
|
|
9
|
+
const { group, hardline, ifBreak, line, softline } = doc.builders;
|
|
10
10
|
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
11
|
+
const specifiers = (node, path, print) => {
|
|
12
|
+
const document = [];
|
|
13
|
+
if (node.baseContracts.length > 0) {
|
|
14
|
+
document.push([
|
|
15
|
+
'is',
|
|
16
|
+
printSeparatedList(path.map(print, 'baseContracts'), {
|
|
17
|
+
firstSeparator: line
|
|
18
|
+
})
|
|
19
|
+
]);
|
|
20
|
+
}
|
|
21
|
+
if (node.storageLayout) {
|
|
22
|
+
document.push([
|
|
23
|
+
'layout at',
|
|
24
|
+
printSeparatedItem(path.call(print, 'storageLayout'), {
|
|
25
|
+
firstSeparator: line
|
|
26
|
+
})
|
|
27
|
+
]);
|
|
28
|
+
}
|
|
29
|
+
if (document.length === 0) return line;
|
|
30
|
+
if (document.length === 1) return [' ', document];
|
|
31
|
+
const groupId = Symbol('ContractSpecifiers.inheritance');
|
|
32
|
+
return printSeparatedList(
|
|
33
|
+
[group(document[0], { id: groupId }), document[1]],
|
|
34
|
+
{
|
|
35
|
+
firstSeparator: line,
|
|
36
|
+
separator: ifBreak('', softline, { groupId })
|
|
37
|
+
}
|
|
38
|
+
);
|
|
39
|
+
};
|
|
20
40
|
|
|
21
41
|
const body = (node, path, options, print) => {
|
|
22
42
|
const comments = printComments(node, path, options);
|
|
@@ -34,7 +54,7 @@ export const ContractDefinition = {
|
|
|
34
54
|
node.kind === 'abstract' ? 'abstract contract' : node.kind,
|
|
35
55
|
' ',
|
|
36
56
|
node.name,
|
|
37
|
-
|
|
57
|
+
specifiers(node, path, print),
|
|
38
58
|
'{'
|
|
39
59
|
]),
|
|
40
60
|
body(node, path, options, print),
|