prettier-plugin-solidity 1.0.0-rc.1 → 1.1.0

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 (138) hide show
  1. package/README.md +47 -13
  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 +42 -11
  6. package/src/common/util.js +59 -0
  7. package/src/nodes/HexLiteral.js +1 -1
  8. package/src/nodes/ImportDirective.js +5 -4
  9. package/src/nodes/InlineAssemblyStatement.js +1 -1
  10. package/src/nodes/SourceUnit.js +1 -1
  11. package/src/nodes/StringLiteral.js +1 -1
  12. package/src/parser.js +6 -5
  13. package/src/prettier-comments/language-js/comments.js +12 -10
  14. package/src/printer.js +3 -3
  15. package/.eslintignore +0 -5
  16. package/.eslintrc +0 -9
  17. package/.nvmrc +0 -1
  18. package/.prettierignore +0 -4
  19. package/.prettierrc +0 -4
  20. package/CODE_OF_CONDUCT.md +0 -76
  21. package/HOW_TO_PUBLISH.md +0 -39
  22. package/STYLEGUIDE.md +0 -382
  23. package/coverage/clover.xml +0 -1171
  24. package/coverage/coverage-final.json +0 -99
  25. package/coverage/lcov-report/base.css +0 -224
  26. package/coverage/lcov-report/block-navigation.js +0 -87
  27. package/coverage/lcov-report/favicon.png +0 -0
  28. package/coverage/lcov-report/index.html +0 -176
  29. package/coverage/lcov-report/prettify.css +0 -1
  30. package/coverage/lcov-report/prettify.js +0 -2
  31. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  32. package/coverage/lcov-report/sorter.js +0 -196
  33. package/coverage/lcov-report/src/binary-operator-printers/arithmetic.js.html +0 -244
  34. package/coverage/lcov-report/src/binary-operator-printers/assignment.js.html +0 -175
  35. package/coverage/lcov-report/src/binary-operator-printers/bit.js.html +0 -103
  36. package/coverage/lcov-report/src/binary-operator-printers/comparison.js.html +0 -199
  37. package/coverage/lcov-report/src/binary-operator-printers/exponentiation.js.html +0 -148
  38. package/coverage/lcov-report/src/binary-operator-printers/index.html +0 -221
  39. package/coverage/lcov-report/src/binary-operator-printers/index.js.html +0 -124
  40. package/coverage/lcov-report/src/binary-operator-printers/logical.js.html +0 -208
  41. package/coverage/lcov-report/src/binary-operator-printers/shift.js.html +0 -103
  42. package/coverage/lcov-report/src/clean.js.html +0 -109
  43. package/coverage/lcov-report/src/comments/handler.js.html +0 -373
  44. package/coverage/lcov-report/src/comments/handlers/handleContractDefinitionComments.js.html +0 -265
  45. package/coverage/lcov-report/src/comments/handlers/handleModifierInvocationComments.js.html +0 -292
  46. package/coverage/lcov-report/src/comments/handlers/index.html +0 -146
  47. package/coverage/lcov-report/src/comments/handlers/index.js.html +0 -103
  48. package/coverage/lcov-report/src/comments/ignore.js.html +0 -184
  49. package/coverage/lcov-report/src/comments/index.html +0 -161
  50. package/coverage/lcov-report/src/comments/index.js.html +0 -97
  51. package/coverage/lcov-report/src/comments/printer.js.html +0 -277
  52. package/coverage/lcov-report/src/index.html +0 -191
  53. package/coverage/lcov-report/src/index.js.html +0 -268
  54. package/coverage/lcov-report/src/loc.js.html +0 -133
  55. package/coverage/lcov-report/src/nodes/ArrayTypeName.js.html +0 -115
  56. package/coverage/lcov-report/src/nodes/AssemblyAssignment.js.html +0 -130
  57. package/coverage/lcov-report/src/nodes/AssemblyBlock.js.html +0 -160
  58. package/coverage/lcov-report/src/nodes/AssemblyCall.js.html +0 -133
  59. package/coverage/lcov-report/src/nodes/AssemblyCase.js.html +0 -112
  60. package/coverage/lcov-report/src/nodes/AssemblyFor.js.html +0 -139
  61. package/coverage/lcov-report/src/nodes/AssemblyFunctionDefinition.js.html +0 -184
  62. package/coverage/lcov-report/src/nodes/AssemblyIf.js.html +0 -115
  63. package/coverage/lcov-report/src/nodes/AssemblyLocalDefinition.js.html +0 -160
  64. package/coverage/lcov-report/src/nodes/AssemblyMemberAccess.js.html +0 -112
  65. package/coverage/lcov-report/src/nodes/AssemblyStackAssignment.js.html +0 -112
  66. package/coverage/lcov-report/src/nodes/AssemblySwitch.js.html +0 -133
  67. package/coverage/lcov-report/src/nodes/BinaryOperation.js.html +0 -127
  68. package/coverage/lcov-report/src/nodes/Block.js.html +0 -166
  69. package/coverage/lcov-report/src/nodes/BooleanLiteral.js.html +0 -100
  70. package/coverage/lcov-report/src/nodes/Break.js.html +0 -100
  71. package/coverage/lcov-report/src/nodes/BreakStatement.js.html +0 -100
  72. package/coverage/lcov-report/src/nodes/CatchClause.js.html +0 -148
  73. package/coverage/lcov-report/src/nodes/Conditional.js.html +0 -151
  74. package/coverage/lcov-report/src/nodes/Continue.js.html +0 -100
  75. package/coverage/lcov-report/src/nodes/ContinueStatement.js.html +0 -100
  76. package/coverage/lcov-report/src/nodes/ContractDefinition.js.html +0 -226
  77. package/coverage/lcov-report/src/nodes/CustomErrorDefinition.js.html +0 -139
  78. package/coverage/lcov-report/src/nodes/DecimalNumber.js.html +0 -100
  79. package/coverage/lcov-report/src/nodes/DoWhileStatement.js.html +0 -157
  80. package/coverage/lcov-report/src/nodes/ElementaryTypeName.js.html +0 -115
  81. package/coverage/lcov-report/src/nodes/EmitStatement.js.html +0 -100
  82. package/coverage/lcov-report/src/nodes/EnumDefinition.js.html +0 -151
  83. package/coverage/lcov-report/src/nodes/EnumValue.js.html +0 -100
  84. package/coverage/lcov-report/src/nodes/EventDefinition.js.html +0 -145
  85. package/coverage/lcov-report/src/nodes/ExpressionStatement.js.html +0 -181
  86. package/coverage/lcov-report/src/nodes/FileLevelConstant.js.html +0 -121
  87. package/coverage/lcov-report/src/nodes/ForStatement.js.html +0 -223
  88. package/coverage/lcov-report/src/nodes/FunctionCall.js.html +0 -280
  89. package/coverage/lcov-report/src/nodes/FunctionDefinition.js.html +0 -457
  90. package/coverage/lcov-report/src/nodes/FunctionTypeName.js.html +0 -217
  91. package/coverage/lcov-report/src/nodes/HexLiteral.js.html +0 -133
  92. package/coverage/lcov-report/src/nodes/HexNumber.js.html +0 -100
  93. package/coverage/lcov-report/src/nodes/Identifier.js.html +0 -100
  94. package/coverage/lcov-report/src/nodes/IfStatement.js.html +0 -265
  95. package/coverage/lcov-report/src/nodes/ImportDirective.js.html +0 -247
  96. package/coverage/lcov-report/src/nodes/IndexAccess.js.html +0 -199
  97. package/coverage/lcov-report/src/nodes/IndexRangeAccess.js.html +0 -121
  98. package/coverage/lcov-report/src/nodes/InheritanceSpecifier.js.html +0 -130
  99. package/coverage/lcov-report/src/nodes/InlineAssemblyStatement.js.html +0 -148
  100. package/coverage/lcov-report/src/nodes/LabelDefinition.js.html +0 -118
  101. package/coverage/lcov-report/src/nodes/Mapping.js.html +0 -118
  102. package/coverage/lcov-report/src/nodes/MemberAccess.js.html +0 -466
  103. package/coverage/lcov-report/src/nodes/ModifierDefinition.js.html +0 -259
  104. package/coverage/lcov-report/src/nodes/ModifierInvocation.js.html +0 -190
  105. package/coverage/lcov-report/src/nodes/NameValueExpression.js.html +0 -115
  106. package/coverage/lcov-report/src/nodes/NameValueList.js.html +0 -148
  107. package/coverage/lcov-report/src/nodes/NewExpression.js.html +0 -100
  108. package/coverage/lcov-report/src/nodes/NumberLiteral.js.html +0 -109
  109. package/coverage/lcov-report/src/nodes/PragmaDirective.js.html +0 -100
  110. package/coverage/lcov-report/src/nodes/ReturnStatement.js.html +0 -157
  111. package/coverage/lcov-report/src/nodes/RevertStatement.js.html +0 -100
  112. package/coverage/lcov-report/src/nodes/SourceUnit.js.html +0 -133
  113. package/coverage/lcov-report/src/nodes/StateVariableDeclaration.js.html +0 -166
  114. package/coverage/lcov-report/src/nodes/StringLiteral.js.html +0 -148
  115. package/coverage/lcov-report/src/nodes/StructDefinition.js.html +0 -154
  116. package/coverage/lcov-report/src/nodes/ThrowStatement.js.html +0 -100
  117. package/coverage/lcov-report/src/nodes/TryStatement.js.html +0 -214
  118. package/coverage/lcov-report/src/nodes/TupleExpression.js.html +0 -160
  119. package/coverage/lcov-report/src/nodes/TypeDefinition.js.html +0 -100
  120. package/coverage/lcov-report/src/nodes/UnaryOperation.js.html +0 -121
  121. package/coverage/lcov-report/src/nodes/UncheckedStatement.js.html +0 -118
  122. package/coverage/lcov-report/src/nodes/UserDefinedTypeName.js.html +0 -100
  123. package/coverage/lcov-report/src/nodes/UsingForDeclaration.js.html +0 -166
  124. package/coverage/lcov-report/src/nodes/VariableDeclaration.js.html +0 -253
  125. package/coverage/lcov-report/src/nodes/VariableDeclarationStatement.js.html +0 -217
  126. package/coverage/lcov-report/src/nodes/WhileStatement.js.html +0 -154
  127. package/coverage/lcov-report/src/nodes/index.html +0 -1256
  128. package/coverage/lcov-report/src/nodes/index.js.html +0 -319
  129. package/coverage/lcov-report/src/nodes/print-comments.js.html +0 -166
  130. package/coverage/lcov-report/src/nodes/print-preserving-empty-lines.js.html +0 -244
  131. package/coverage/lcov-report/src/nodes/print-separated-item.js.html +0 -148
  132. package/coverage/lcov-report/src/nodes/print-separated-list.js.html +0 -154
  133. package/coverage/lcov-report/src/options.js.html +0 -238
  134. package/coverage/lcov-report/src/parser.js.html +0 -643
  135. package/coverage/lcov-report/src/printer.js.html +0 -214
  136. package/coverage/lcov.info +0 -2672
  137. package/jest.config.js +0 -40
  138. package/src/prettier-comments/common/util.js +0 -684
package/README.md CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  [![Telegram](/assets/telegram-badge.svg)](https://t.me/+kgTgkFgIwJkwMjcx)
4
4
  [![Twitter Follow](https://img.shields.io/twitter/follow/PrettierSol.svg?style=social)](https://twitter.com/PrettierSol)
5
+ [![GitPOAP Badge](https://public-api.gitpoap.io/v1/repo/prettier-solidity/prettier-plugin-solidity/badge)](https://www.gitpoap.io/gh/prettier-solidity/prettier-plugin-solidity)
5
6
 
6
7
  <p align="center">
7
8
  <img width="375" height="375" src="https://user-images.githubusercontent.com/1022054/59317198-f1149b80-8d15-11e9-9b0f-0c5e7d4b8b81.png">
@@ -13,6 +14,8 @@ If you like this project, please consider contributing to our [Gitcoin grant](ht
13
14
 
14
15
  ## Installation and usage
15
16
 
17
+ ### Using in NodeJS
18
+
16
19
  Install both `prettier` and `prettier-plugin-solidity`:
17
20
 
18
21
  ```Bash
@@ -37,19 +40,36 @@ Or you can use it as part of your linting to check that all your code is prettif
37
40
  "lint": "prettier --list-different 'contracts/**/*.sol'"
38
41
  ```
39
42
 
40
- ## Who's using it?
43
+ > Prettier Solidity only works with valid code. If there is a syntax error, nothing will be done and a parser error will be thrown.
41
44
 
42
- These are some of the projects using Prettier Solidity:
45
+ ### Using in the Browser
43
46
 
44
- - [Bancor](https://app.bancor.network)
45
- - [Gelato](https://gelato.network/)
46
- - [Gnosis Protocol](https://docs.gnosis.io/protocol/)
47
- - [PieDAO](https://www.piedao.org/)
48
- - [Sablier](https://sablier.finance/)
49
- - [Synthetix](https://www.synthetix.io)
50
- - [The Sandbox](https://www.sandbox.game/en/)
51
- - [UMA](https://umaproject.org/)
52
- - [Uniswap](https://uniswap.org)
47
+ _Added in v1.1.0_
48
+
49
+ To use this package in the browser, you need to load Prettier's standalone bundle before loading the build provided in this package.
50
+
51
+ ```html
52
+ <script src="https://unpkg.com/prettier@latest"></script>
53
+ <script src="https://unpkg.com/prettier-plugin-solidity@latest"></script>
54
+ ```
55
+
56
+ Prettier's unpkg field points to `https://unpkg.com/prettier/standalone.js`, in a similar way this plugin points to `https://unpkg.com/prettier-plugin-solidity/dist/standalone.js`.
57
+
58
+ Once the scripts are loaded you will have access the globals `prettier` and `prettierPlugins`.
59
+
60
+ We follow Prettier's strategy for populating their plugins in the object `prettierPlugins`, you can load other plugins like `https://unpkg.com/prettier@2.8.0/parser-markdown.js` and Prettier will have access to multiple parsers.
61
+
62
+ ```html
63
+ <script>
64
+ const originalCode = 'contract Foo {}';
65
+ const formattedCode = prettier.format(originalCode, {
66
+ parser: 'solidity-parse',
67
+ plugins: prettierPlugins
68
+ });
69
+ </script>
70
+ ```
71
+
72
+ For more details and please have a look at [Prettier's documentation](https://prettier.io/docs/en/browser.html).
53
73
 
54
74
  ## Configuration File
55
75
 
@@ -77,9 +97,9 @@ Note the use of the [overrides property](https://prettier.io/docs/en/configurati
77
97
 
78
98
  Most options are described in Prettier's [documentation](https://prettier.io/docs/en/options.html).
79
99
 
80
- ### Compiler (experimental)
100
+ ### Compiler
81
101
 
82
- Many versions of the Solidity compiler have changes that affect how the code should be formatted. This plugin, by default, tries to format the code in the most compatible way that it's possible, but you can use the experimental `compiler` option to nudge it in the right direction.
102
+ Many versions of the Solidity compiler have changes that affect how the code should be formatted. This plugin, by default, tries to format the code in the most compatible way that it's possible, but you can use the `compiler` option to nudge it in the right direction.
83
103
 
84
104
  One example of this is import directives. Before `0.7.4`, the compiler didn't accept multi-line import statements, so we always format them in a single line. But if you use the `compiler` option to indicate that you are using a version greater or equal than `0.7.4`, the plugin will use multi-line imports when it makes sense.
85
105
 
@@ -314,6 +334,20 @@ Notice that the unnecessary parentheses in `modifier2` were removed in the funct
314
334
  5. Push to the branch (`git push origin feature/fooBar`)
315
335
  6. Create a new Pull Request
316
336
 
337
+ ## Who's using it?
338
+
339
+ These are some of the projects using Prettier Solidity:
340
+
341
+ - [Bancor](https://app.bancor.network)
342
+ - [Gelato](https://gelato.network/)
343
+ - [Gnosis Protocol](https://docs.gnosis.io/protocol/)
344
+ - [PieDAO](https://www.piedao.org/)
345
+ - [Sablier](https://sablier.finance/)
346
+ - [Synthetix](https://www.synthetix.io)
347
+ - [The Sandbox](https://www.sandbox.game/en/)
348
+ - [UMA](https://umaproject.org/)
349
+ - [Uniswap](https://uniswap.org)
350
+
317
351
  ## License
318
352
 
319
353
  Distributed under the MIT license. See [LICENSE](LICENSE) for more information.