prettier-plugin-solidity 1.0.0 → 1.1.1

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.
Files changed (144) hide show
  1. package/README.md +45 -11
  2. package/dist/standalone.js +3 -0
  3. package/dist/standalone.js.LICENSE.txt +15 -0
  4. package/dist/standalone.js.map +1 -0
  5. package/package.json +38 -12
  6. package/src/clean.js +4 -6
  7. package/src/common/util.js +64 -0
  8. package/src/nodes/BinaryOperation.js +10 -4
  9. package/src/nodes/ExpressionStatement.js +1 -1
  10. package/src/nodes/FunctionDefinition.js +1 -1
  11. package/src/nodes/HexLiteral.js +1 -1
  12. package/src/nodes/ImportDirective.js +5 -4
  13. package/src/nodes/InlineAssemblyStatement.js +1 -1
  14. package/src/nodes/SourceUnit.js +1 -1
  15. package/src/nodes/StringLiteral.js +1 -1
  16. package/src/nodes/print-comments.js +29 -19
  17. package/src/parser.js +7 -6
  18. package/src/prettier-comments/language-js/comments.js +12 -10
  19. package/src/printer.js +5 -4
  20. package/.c8rc +0 -11
  21. package/.eslintignore +0 -5
  22. package/.eslintrc +0 -9
  23. package/.nvmrc +0 -1
  24. package/.prettierignore +0 -4
  25. package/.prettierrc +0 -4
  26. package/CODE_OF_CONDUCT.md +0 -76
  27. package/HOW_TO_PUBLISH.md +0 -39
  28. package/STYLEGUIDE.md +0 -382
  29. package/coverage/clover.xml +0 -1171
  30. package/coverage/coverage-final.json +0 -99
  31. package/coverage/lcov-report/base.css +0 -224
  32. package/coverage/lcov-report/block-navigation.js +0 -87
  33. package/coverage/lcov-report/favicon.png +0 -0
  34. package/coverage/lcov-report/index.html +0 -176
  35. package/coverage/lcov-report/prettify.css +0 -1
  36. package/coverage/lcov-report/prettify.js +0 -2
  37. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  38. package/coverage/lcov-report/sorter.js +0 -196
  39. package/coverage/lcov-report/src/binary-operator-printers/arithmetic.js.html +0 -244
  40. package/coverage/lcov-report/src/binary-operator-printers/assignment.js.html +0 -175
  41. package/coverage/lcov-report/src/binary-operator-printers/bit.js.html +0 -103
  42. package/coverage/lcov-report/src/binary-operator-printers/comparison.js.html +0 -199
  43. package/coverage/lcov-report/src/binary-operator-printers/exponentiation.js.html +0 -148
  44. package/coverage/lcov-report/src/binary-operator-printers/index.html +0 -221
  45. package/coverage/lcov-report/src/binary-operator-printers/index.js.html +0 -124
  46. package/coverage/lcov-report/src/binary-operator-printers/logical.js.html +0 -208
  47. package/coverage/lcov-report/src/binary-operator-printers/shift.js.html +0 -103
  48. package/coverage/lcov-report/src/clean.js.html +0 -109
  49. package/coverage/lcov-report/src/comments/handler.js.html +0 -373
  50. package/coverage/lcov-report/src/comments/handlers/handleContractDefinitionComments.js.html +0 -265
  51. package/coverage/lcov-report/src/comments/handlers/handleModifierInvocationComments.js.html +0 -292
  52. package/coverage/lcov-report/src/comments/handlers/index.html +0 -146
  53. package/coverage/lcov-report/src/comments/handlers/index.js.html +0 -103
  54. package/coverage/lcov-report/src/comments/ignore.js.html +0 -184
  55. package/coverage/lcov-report/src/comments/index.html +0 -161
  56. package/coverage/lcov-report/src/comments/index.js.html +0 -97
  57. package/coverage/lcov-report/src/comments/printer.js.html +0 -277
  58. package/coverage/lcov-report/src/index.html +0 -191
  59. package/coverage/lcov-report/src/index.js.html +0 -268
  60. package/coverage/lcov-report/src/loc.js.html +0 -133
  61. package/coverage/lcov-report/src/nodes/ArrayTypeName.js.html +0 -115
  62. package/coverage/lcov-report/src/nodes/AssemblyAssignment.js.html +0 -130
  63. package/coverage/lcov-report/src/nodes/AssemblyBlock.js.html +0 -160
  64. package/coverage/lcov-report/src/nodes/AssemblyCall.js.html +0 -133
  65. package/coverage/lcov-report/src/nodes/AssemblyCase.js.html +0 -112
  66. package/coverage/lcov-report/src/nodes/AssemblyFor.js.html +0 -139
  67. package/coverage/lcov-report/src/nodes/AssemblyFunctionDefinition.js.html +0 -184
  68. package/coverage/lcov-report/src/nodes/AssemblyIf.js.html +0 -115
  69. package/coverage/lcov-report/src/nodes/AssemblyLocalDefinition.js.html +0 -160
  70. package/coverage/lcov-report/src/nodes/AssemblyMemberAccess.js.html +0 -112
  71. package/coverage/lcov-report/src/nodes/AssemblyStackAssignment.js.html +0 -112
  72. package/coverage/lcov-report/src/nodes/AssemblySwitch.js.html +0 -133
  73. package/coverage/lcov-report/src/nodes/BinaryOperation.js.html +0 -127
  74. package/coverage/lcov-report/src/nodes/Block.js.html +0 -166
  75. package/coverage/lcov-report/src/nodes/BooleanLiteral.js.html +0 -100
  76. package/coverage/lcov-report/src/nodes/Break.js.html +0 -100
  77. package/coverage/lcov-report/src/nodes/BreakStatement.js.html +0 -100
  78. package/coverage/lcov-report/src/nodes/CatchClause.js.html +0 -148
  79. package/coverage/lcov-report/src/nodes/Conditional.js.html +0 -151
  80. package/coverage/lcov-report/src/nodes/Continue.js.html +0 -100
  81. package/coverage/lcov-report/src/nodes/ContinueStatement.js.html +0 -100
  82. package/coverage/lcov-report/src/nodes/ContractDefinition.js.html +0 -226
  83. package/coverage/lcov-report/src/nodes/CustomErrorDefinition.js.html +0 -139
  84. package/coverage/lcov-report/src/nodes/DecimalNumber.js.html +0 -100
  85. package/coverage/lcov-report/src/nodes/DoWhileStatement.js.html +0 -157
  86. package/coverage/lcov-report/src/nodes/ElementaryTypeName.js.html +0 -115
  87. package/coverage/lcov-report/src/nodes/EmitStatement.js.html +0 -100
  88. package/coverage/lcov-report/src/nodes/EnumDefinition.js.html +0 -151
  89. package/coverage/lcov-report/src/nodes/EnumValue.js.html +0 -100
  90. package/coverage/lcov-report/src/nodes/EventDefinition.js.html +0 -145
  91. package/coverage/lcov-report/src/nodes/ExpressionStatement.js.html +0 -181
  92. package/coverage/lcov-report/src/nodes/FileLevelConstant.js.html +0 -121
  93. package/coverage/lcov-report/src/nodes/ForStatement.js.html +0 -223
  94. package/coverage/lcov-report/src/nodes/FunctionCall.js.html +0 -280
  95. package/coverage/lcov-report/src/nodes/FunctionDefinition.js.html +0 -457
  96. package/coverage/lcov-report/src/nodes/FunctionTypeName.js.html +0 -217
  97. package/coverage/lcov-report/src/nodes/HexLiteral.js.html +0 -133
  98. package/coverage/lcov-report/src/nodes/HexNumber.js.html +0 -100
  99. package/coverage/lcov-report/src/nodes/Identifier.js.html +0 -100
  100. package/coverage/lcov-report/src/nodes/IfStatement.js.html +0 -265
  101. package/coverage/lcov-report/src/nodes/ImportDirective.js.html +0 -247
  102. package/coverage/lcov-report/src/nodes/IndexAccess.js.html +0 -199
  103. package/coverage/lcov-report/src/nodes/IndexRangeAccess.js.html +0 -121
  104. package/coverage/lcov-report/src/nodes/InheritanceSpecifier.js.html +0 -130
  105. package/coverage/lcov-report/src/nodes/InlineAssemblyStatement.js.html +0 -148
  106. package/coverage/lcov-report/src/nodes/LabelDefinition.js.html +0 -118
  107. package/coverage/lcov-report/src/nodes/Mapping.js.html +0 -118
  108. package/coverage/lcov-report/src/nodes/MemberAccess.js.html +0 -466
  109. package/coverage/lcov-report/src/nodes/ModifierDefinition.js.html +0 -259
  110. package/coverage/lcov-report/src/nodes/ModifierInvocation.js.html +0 -190
  111. package/coverage/lcov-report/src/nodes/NameValueExpression.js.html +0 -115
  112. package/coverage/lcov-report/src/nodes/NameValueList.js.html +0 -148
  113. package/coverage/lcov-report/src/nodes/NewExpression.js.html +0 -100
  114. package/coverage/lcov-report/src/nodes/NumberLiteral.js.html +0 -109
  115. package/coverage/lcov-report/src/nodes/PragmaDirective.js.html +0 -100
  116. package/coverage/lcov-report/src/nodes/ReturnStatement.js.html +0 -157
  117. package/coverage/lcov-report/src/nodes/RevertStatement.js.html +0 -100
  118. package/coverage/lcov-report/src/nodes/SourceUnit.js.html +0 -133
  119. package/coverage/lcov-report/src/nodes/StateVariableDeclaration.js.html +0 -166
  120. package/coverage/lcov-report/src/nodes/StringLiteral.js.html +0 -148
  121. package/coverage/lcov-report/src/nodes/StructDefinition.js.html +0 -154
  122. package/coverage/lcov-report/src/nodes/ThrowStatement.js.html +0 -100
  123. package/coverage/lcov-report/src/nodes/TryStatement.js.html +0 -214
  124. package/coverage/lcov-report/src/nodes/TupleExpression.js.html +0 -160
  125. package/coverage/lcov-report/src/nodes/TypeDefinition.js.html +0 -100
  126. package/coverage/lcov-report/src/nodes/UnaryOperation.js.html +0 -121
  127. package/coverage/lcov-report/src/nodes/UncheckedStatement.js.html +0 -118
  128. package/coverage/lcov-report/src/nodes/UserDefinedTypeName.js.html +0 -100
  129. package/coverage/lcov-report/src/nodes/UsingForDeclaration.js.html +0 -166
  130. package/coverage/lcov-report/src/nodes/VariableDeclaration.js.html +0 -253
  131. package/coverage/lcov-report/src/nodes/VariableDeclarationStatement.js.html +0 -217
  132. package/coverage/lcov-report/src/nodes/WhileStatement.js.html +0 -154
  133. package/coverage/lcov-report/src/nodes/index.html +0 -1256
  134. package/coverage/lcov-report/src/nodes/index.js.html +0 -319
  135. package/coverage/lcov-report/src/nodes/print-comments.js.html +0 -166
  136. package/coverage/lcov-report/src/nodes/print-preserving-empty-lines.js.html +0 -244
  137. package/coverage/lcov-report/src/nodes/print-separated-item.js.html +0 -148
  138. package/coverage/lcov-report/src/nodes/print-separated-list.js.html +0 -154
  139. package/coverage/lcov-report/src/options.js.html +0 -238
  140. package/coverage/lcov-report/src/parser.js.html +0 -643
  141. package/coverage/lcov-report/src/printer.js.html +0 -214
  142. package/coverage/lcov.info +0 -2672
  143. package/jest.config.js +0 -25
  144. package/src/prettier-comments/common/util.js +0 -684
package/STYLEGUIDE.md DELETED
@@ -1,382 +0,0 @@
1
- # Style Guide
2
-
3
- ## Indentation
4
-
5
- - [x] Use 4 spaces per indentation level.
6
-
7
- ## Tabs or Spaces
8
-
9
- - [x] Spaces are the preferred indentation method.
10
- - [x] Mixing tabs and spaces should be avoided.
11
-
12
- ## Blank Lines
13
-
14
- - [ ] Surround top level declarations in solidity source with two blank lines.
15
-
16
- ```Solidity
17
- pragma solidity >=0.4.0 <0.7.0;
18
-
19
- contract A {
20
- // ...
21
- }
22
-
23
-
24
- contract B {
25
- // ...
26
- }
27
-
28
-
29
- contract C {
30
- // ...
31
- }
32
- ```
33
-
34
- - [ ] Within a contract surround function declarations with a single blank line.
35
-
36
- Blank lines may be omitted between groups of related one-liners (such as stub functions for an abstract contract)
37
-
38
- ```Solidity
39
- pragma solidity >=0.4.0 <0.7.0;
40
-
41
- contract A {
42
- function spam() public pure;
43
- function ham() public pure;
44
- }
45
-
46
-
47
- contract B is A {
48
- function spam() public pure {
49
- // ...
50
- }
51
-
52
- function ham() public pure {
53
- // ...
54
- }
55
- }
56
- ```
57
-
58
- ## Maximum Line Length
59
-
60
- Keeping lines under the [PEP 8 recommendation](https://www.python.org/dev/peps/pep-0008/#maximum-line-length) to a maximum of 79 (or 99) characters helps readers easily parse the code.
61
-
62
- Wrapped lines should conform to the following guidelines.
63
-
64
- 1. The first argument should not be attached to the opening parenthesis.
65
- 2. One, and only one, indent should be used.
66
- 3. Each argument should fall on its own line.
67
- 4. The terminating element, :code:`);`, should be placed on the final line by itself.
68
-
69
- - [x] Function Calls
70
-
71
- ```Solidity
72
- thisFunctionCallIsReallyLong(
73
- longArgument1,
74
- longArgument2,
75
- longArgument3
76
- );
77
- ```
78
-
79
- - [x] Assignment Statements
80
-
81
- ```Solidity
82
- thisIsALongNestedMapping[being][set][to_some_value] = someFunction(
83
- argument1,
84
- argument2,
85
- argument3,
86
- argument4
87
- );
88
- ```
89
-
90
- - [x] Event Definitions and Event Emitters
91
-
92
- ```Solidity
93
- event LongAndLotsOfArgs(
94
- address sender,
95
- address recipient,
96
- uint256 publicKey,
97
- uint256 amount,
98
- bytes32[] options
99
- );
100
-
101
- LongAndLotsOfArgs(
102
- sender,
103
- recipient,
104
- publicKey,
105
- amount,
106
- options
107
- );
108
- ```
109
-
110
- ## Source File Encoding
111
-
112
- - [x] UTF-8 or ASCII encoding is preferred.
113
-
114
- ## Whitespace in Expressions
115
-
116
- Avoid extraneous whitespace in the following situations:
117
-
118
- - [x] Immediately inside parenthesis, brackets or braces, with the exception of single line function declarations.
119
-
120
- ```Solidity
121
- spam(ham[1], Coin({name: "ham"}));
122
- ```
123
-
124
- - [x] Immediately before a comma, semicolon:
125
-
126
- ```Solidity
127
- function spam(uint i, Coin coin) public;
128
- ```
129
-
130
- - [x] More than one space around an assignment or other operator to align with another:
131
-
132
- ```Solidity
133
- x = 1;
134
- y = 2;
135
- long_variable = 3;
136
- ```
137
-
138
- - [x] Don't include a whitespace in the fallback function:
139
-
140
- ```Solidity
141
- function() external {
142
- ...
143
- }
144
- ```
145
-
146
- ## Control Structures
147
-
148
- - [x] The braces denoting the body of a contract, library, functions and structs should:
149
-
150
- - open on the same line as the declaration
151
- - close on their own line at the same indentation level as the beginning of the declaration.
152
- - The opening brace should be proceeded by a single space.
153
-
154
- ```Solidity
155
- pragma solidity >=0.4.0 <0.7.0;
156
-
157
- contract Coin {
158
- struct Bank {
159
- address owner;
160
- uint balance;
161
- }
162
- }
163
- ```
164
-
165
- - [x] The same recommendations apply to the control structures `if`, `else`, `while`, and `for`.
166
-
167
- Additionally there should be a single space between the control structures `if`, `while`, and `for` and the parenthetic block representing the conditional, as well as a single space between the conditional parenthetic block and the opening brace.
168
-
169
- ```Solidity
170
- if (...) {
171
- ...
172
- }
173
-
174
- for (...) {
175
- ...
176
- }
177
- ```
178
-
179
- - [ ] For control structures whose body contains a single statement, omitting the braces is ok _if_ the statement is contained on a single line.
180
-
181
- ```Solidity
182
- if (x < 10)
183
- x += 1;
184
- ```
185
-
186
- - [x] For `if` blocks which have an `else` or `else if` clause, the `else` should be placed on the same line as the `if`'s closing brace. This is an exception compared to the rules of other block-like structures.
187
-
188
- ```Solidity
189
- if (x < 3) {
190
- x += 1;
191
- } else if (x > 7) {
192
- x -= 1;
193
- } else {
194
- x = 5;
195
- }
196
-
197
-
198
- if (x < 3)
199
- x += 1;
200
- else
201
- x -= 1;
202
- ```
203
-
204
- ## Function Declaration
205
-
206
- - [x] For short function declarations, it is recommended for the opening brace of the function body to be kept on the same line as the function declaration.
207
-
208
- The closing brace should be at the same indentation level as the function declaration.
209
-
210
- The opening brace should be preceded by a single space.
211
-
212
- ```Solidity
213
- function increment(uint x) public pure returns (uint) {
214
- return x + 1;
215
- }
216
-
217
- function increment(uint x) public pure onlyowner returns (uint) {
218
- return x + 1;
219
- }
220
- ```
221
-
222
- - [x] The visibility modifier for a function should come before any custom modifiers.
223
-
224
- ```Solidity
225
- function kill() public onlyowner {
226
- selfdestruct(owner);
227
- }
228
- ```
229
-
230
- - [x] For long function declarations, it is recommended to drop each argument onto it's own line at the same indentation level as the function body. The closing parenthesis and opening bracket should be placed on their own line as well at the same indentation level as the function declaration.
231
-
232
- ```Solidity
233
- function thisFunctionHasLotsOfArguments(
234
- address a,
235
- address b,
236
- address c,
237
- address d,
238
- address e,
239
- address f
240
- )
241
- public
242
- {
243
- doSomething();
244
- }
245
- ```
246
-
247
- - [x] If a long function declaration has modifiers, then each modifier should be dropped to its own line.
248
-
249
- ```Solidity
250
- function thisFunctionNameIsReallyLong(address x, address y, address z)
251
- public
252
- onlyowner
253
- priced
254
- returns (address)
255
- {
256
- doSomething();
257
- }
258
-
259
- function thisFunctionNameIsReallyLong(
260
- address x,
261
- address y,
262
- address z,
263
- )
264
- public
265
- onlyowner
266
- priced
267
- returns (address)
268
- {
269
- doSomething();
270
- }
271
- ```
272
-
273
- - [x] Multiline output parameters and return statements should follow the same style recommended for wrapping long lines found in the [Maximum Line Length](#maximum_line_length) section.
274
-
275
- ```Solidity
276
- function thisFunctionNameIsReallyLong(
277
- address a,
278
- address b,
279
- address c
280
- )
281
- public
282
- returns (
283
- address someAddressName,
284
- uint256 LongArgument,
285
- uint256 Argument
286
- )
287
- {
288
- doSomething()
289
-
290
- return (
291
- veryLongReturnArg1,
292
- veryLongReturnArg2,
293
- veryLongReturnArg3
294
- );
295
- }
296
- ```
297
-
298
- - [ ] For constructor functions on inherited contracts whose bases require arguments, it is recommended to drop the base constructors onto new lines in the same manner as modifiers if the function declaration is long or hard to read.
299
-
300
- ```Solidity
301
- pragma solidity >=0.4.0 <0.7.0;
302
-
303
- // Base contracts just to make this compile
304
- contract B {
305
- constructor(uint) public {
306
- }
307
- }
308
-
309
-
310
- contract C {
311
- constructor(uint, uint) public {
312
- }
313
- }
314
-
315
-
316
- contract D {
317
- constructor(uint) public {
318
- }
319
- }
320
-
321
-
322
- contract A is B, C, D {
323
- uint x;
324
-
325
- constructor(uint param1, uint param2, uint param3, uint param4, uint param5)
326
- B(param1)
327
- C(param2, param3)
328
- D(param4)
329
- public
330
- {
331
- // do something with param5
332
- x = param5;
333
- }
334
- }
335
- ```
336
-
337
- These guidelines for function declarations are intended to improve readability. Authors should use their best judgement as this guide does not try to cover all possible permutations for function declarations.
338
-
339
- ## Mappings
340
-
341
- - [x] In variable declarations, do not separate the keyword `mapping` from its type by a space. Do not separate any nested `mapping` keyword from its type by whitespace.
342
-
343
- ```Solidity
344
- mapping(uint => uint) map;
345
- mapping(address => bool) registeredAddresses;
346
- mapping(uint => mapping(bool => Data[])) public data;
347
- mapping(uint => mapping(uint => s)) data;
348
- ```
349
-
350
- ## Variable Declarations
351
-
352
- - [x] Declarations of array variables should not have a space between the type and the brackets.
353
-
354
- ```Solidity
355
- uint[] x;
356
- ```
357
-
358
- ## Other Recommendations
359
-
360
- - [ ] Strings should be quoted with double-quotes instead of single-quotes.
361
-
362
- ```Solidity
363
- str = "foo";
364
- str = "Hamlet says, 'To be or not to be...'";
365
- ```
366
-
367
- - [x] Surround operators with a single space on either side.
368
-
369
- ```Solidity
370
- x = 3;
371
- x = 100 / 10;
372
- x += 3 + 4;
373
- x |= y && z;
374
- ```
375
-
376
- - [ ] Operators with a higher priority than others can exclude surrounding whitespace in order to denote precedence. This is meant to allow for improved readability for complex statement. You should always use the same amount of whitespace on either side of an operator:
377
-
378
- ```Solidity
379
- x = 2**3 + 5;
380
- x = 2*y + 3*z;
381
- x = (a+b) * (a-b);
382
- ```