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.
- package/README.md +47 -13
- package/dist/standalone.js +3 -0
- package/dist/standalone.js.LICENSE.txt +15 -0
- package/dist/standalone.js.map +1 -0
- package/package.json +42 -11
- package/src/common/util.js +59 -0
- package/src/nodes/HexLiteral.js +1 -1
- package/src/nodes/ImportDirective.js +5 -4
- package/src/nodes/InlineAssemblyStatement.js +1 -1
- package/src/nodes/SourceUnit.js +1 -1
- package/src/nodes/StringLiteral.js +1 -1
- package/src/parser.js +6 -5
- package/src/prettier-comments/language-js/comments.js +12 -10
- package/src/printer.js +3 -3
- package/.eslintignore +0 -5
- package/.eslintrc +0 -9
- package/.nvmrc +0 -1
- package/.prettierignore +0 -4
- package/.prettierrc +0 -4
- package/CODE_OF_CONDUCT.md +0 -76
- package/HOW_TO_PUBLISH.md +0 -39
- package/STYLEGUIDE.md +0 -382
- package/coverage/clover.xml +0 -1171
- package/coverage/coverage-final.json +0 -99
- package/coverage/lcov-report/base.css +0 -224
- package/coverage/lcov-report/block-navigation.js +0 -87
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +0 -176
- package/coverage/lcov-report/prettify.css +0 -1
- package/coverage/lcov-report/prettify.js +0 -2
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +0 -196
- package/coverage/lcov-report/src/binary-operator-printers/arithmetic.js.html +0 -244
- package/coverage/lcov-report/src/binary-operator-printers/assignment.js.html +0 -175
- package/coverage/lcov-report/src/binary-operator-printers/bit.js.html +0 -103
- package/coverage/lcov-report/src/binary-operator-printers/comparison.js.html +0 -199
- package/coverage/lcov-report/src/binary-operator-printers/exponentiation.js.html +0 -148
- package/coverage/lcov-report/src/binary-operator-printers/index.html +0 -221
- package/coverage/lcov-report/src/binary-operator-printers/index.js.html +0 -124
- package/coverage/lcov-report/src/binary-operator-printers/logical.js.html +0 -208
- package/coverage/lcov-report/src/binary-operator-printers/shift.js.html +0 -103
- package/coverage/lcov-report/src/clean.js.html +0 -109
- package/coverage/lcov-report/src/comments/handler.js.html +0 -373
- package/coverage/lcov-report/src/comments/handlers/handleContractDefinitionComments.js.html +0 -265
- package/coverage/lcov-report/src/comments/handlers/handleModifierInvocationComments.js.html +0 -292
- package/coverage/lcov-report/src/comments/handlers/index.html +0 -146
- package/coverage/lcov-report/src/comments/handlers/index.js.html +0 -103
- package/coverage/lcov-report/src/comments/ignore.js.html +0 -184
- package/coverage/lcov-report/src/comments/index.html +0 -161
- package/coverage/lcov-report/src/comments/index.js.html +0 -97
- package/coverage/lcov-report/src/comments/printer.js.html +0 -277
- package/coverage/lcov-report/src/index.html +0 -191
- package/coverage/lcov-report/src/index.js.html +0 -268
- package/coverage/lcov-report/src/loc.js.html +0 -133
- package/coverage/lcov-report/src/nodes/ArrayTypeName.js.html +0 -115
- package/coverage/lcov-report/src/nodes/AssemblyAssignment.js.html +0 -130
- package/coverage/lcov-report/src/nodes/AssemblyBlock.js.html +0 -160
- package/coverage/lcov-report/src/nodes/AssemblyCall.js.html +0 -133
- package/coverage/lcov-report/src/nodes/AssemblyCase.js.html +0 -112
- package/coverage/lcov-report/src/nodes/AssemblyFor.js.html +0 -139
- package/coverage/lcov-report/src/nodes/AssemblyFunctionDefinition.js.html +0 -184
- package/coverage/lcov-report/src/nodes/AssemblyIf.js.html +0 -115
- package/coverage/lcov-report/src/nodes/AssemblyLocalDefinition.js.html +0 -160
- package/coverage/lcov-report/src/nodes/AssemblyMemberAccess.js.html +0 -112
- package/coverage/lcov-report/src/nodes/AssemblyStackAssignment.js.html +0 -112
- package/coverage/lcov-report/src/nodes/AssemblySwitch.js.html +0 -133
- package/coverage/lcov-report/src/nodes/BinaryOperation.js.html +0 -127
- package/coverage/lcov-report/src/nodes/Block.js.html +0 -166
- package/coverage/lcov-report/src/nodes/BooleanLiteral.js.html +0 -100
- package/coverage/lcov-report/src/nodes/Break.js.html +0 -100
- package/coverage/lcov-report/src/nodes/BreakStatement.js.html +0 -100
- package/coverage/lcov-report/src/nodes/CatchClause.js.html +0 -148
- package/coverage/lcov-report/src/nodes/Conditional.js.html +0 -151
- package/coverage/lcov-report/src/nodes/Continue.js.html +0 -100
- package/coverage/lcov-report/src/nodes/ContinueStatement.js.html +0 -100
- package/coverage/lcov-report/src/nodes/ContractDefinition.js.html +0 -226
- package/coverage/lcov-report/src/nodes/CustomErrorDefinition.js.html +0 -139
- package/coverage/lcov-report/src/nodes/DecimalNumber.js.html +0 -100
- package/coverage/lcov-report/src/nodes/DoWhileStatement.js.html +0 -157
- package/coverage/lcov-report/src/nodes/ElementaryTypeName.js.html +0 -115
- package/coverage/lcov-report/src/nodes/EmitStatement.js.html +0 -100
- package/coverage/lcov-report/src/nodes/EnumDefinition.js.html +0 -151
- package/coverage/lcov-report/src/nodes/EnumValue.js.html +0 -100
- package/coverage/lcov-report/src/nodes/EventDefinition.js.html +0 -145
- package/coverage/lcov-report/src/nodes/ExpressionStatement.js.html +0 -181
- package/coverage/lcov-report/src/nodes/FileLevelConstant.js.html +0 -121
- package/coverage/lcov-report/src/nodes/ForStatement.js.html +0 -223
- package/coverage/lcov-report/src/nodes/FunctionCall.js.html +0 -280
- package/coverage/lcov-report/src/nodes/FunctionDefinition.js.html +0 -457
- package/coverage/lcov-report/src/nodes/FunctionTypeName.js.html +0 -217
- package/coverage/lcov-report/src/nodes/HexLiteral.js.html +0 -133
- package/coverage/lcov-report/src/nodes/HexNumber.js.html +0 -100
- package/coverage/lcov-report/src/nodes/Identifier.js.html +0 -100
- package/coverage/lcov-report/src/nodes/IfStatement.js.html +0 -265
- package/coverage/lcov-report/src/nodes/ImportDirective.js.html +0 -247
- package/coverage/lcov-report/src/nodes/IndexAccess.js.html +0 -199
- package/coverage/lcov-report/src/nodes/IndexRangeAccess.js.html +0 -121
- package/coverage/lcov-report/src/nodes/InheritanceSpecifier.js.html +0 -130
- package/coverage/lcov-report/src/nodes/InlineAssemblyStatement.js.html +0 -148
- package/coverage/lcov-report/src/nodes/LabelDefinition.js.html +0 -118
- package/coverage/lcov-report/src/nodes/Mapping.js.html +0 -118
- package/coverage/lcov-report/src/nodes/MemberAccess.js.html +0 -466
- package/coverage/lcov-report/src/nodes/ModifierDefinition.js.html +0 -259
- package/coverage/lcov-report/src/nodes/ModifierInvocation.js.html +0 -190
- package/coverage/lcov-report/src/nodes/NameValueExpression.js.html +0 -115
- package/coverage/lcov-report/src/nodes/NameValueList.js.html +0 -148
- package/coverage/lcov-report/src/nodes/NewExpression.js.html +0 -100
- package/coverage/lcov-report/src/nodes/NumberLiteral.js.html +0 -109
- package/coverage/lcov-report/src/nodes/PragmaDirective.js.html +0 -100
- package/coverage/lcov-report/src/nodes/ReturnStatement.js.html +0 -157
- package/coverage/lcov-report/src/nodes/RevertStatement.js.html +0 -100
- package/coverage/lcov-report/src/nodes/SourceUnit.js.html +0 -133
- package/coverage/lcov-report/src/nodes/StateVariableDeclaration.js.html +0 -166
- package/coverage/lcov-report/src/nodes/StringLiteral.js.html +0 -148
- package/coverage/lcov-report/src/nodes/StructDefinition.js.html +0 -154
- package/coverage/lcov-report/src/nodes/ThrowStatement.js.html +0 -100
- package/coverage/lcov-report/src/nodes/TryStatement.js.html +0 -214
- package/coverage/lcov-report/src/nodes/TupleExpression.js.html +0 -160
- package/coverage/lcov-report/src/nodes/TypeDefinition.js.html +0 -100
- package/coverage/lcov-report/src/nodes/UnaryOperation.js.html +0 -121
- package/coverage/lcov-report/src/nodes/UncheckedStatement.js.html +0 -118
- package/coverage/lcov-report/src/nodes/UserDefinedTypeName.js.html +0 -100
- package/coverage/lcov-report/src/nodes/UsingForDeclaration.js.html +0 -166
- package/coverage/lcov-report/src/nodes/VariableDeclaration.js.html +0 -253
- package/coverage/lcov-report/src/nodes/VariableDeclarationStatement.js.html +0 -217
- package/coverage/lcov-report/src/nodes/WhileStatement.js.html +0 -154
- package/coverage/lcov-report/src/nodes/index.html +0 -1256
- package/coverage/lcov-report/src/nodes/index.js.html +0 -319
- package/coverage/lcov-report/src/nodes/print-comments.js.html +0 -166
- package/coverage/lcov-report/src/nodes/print-preserving-empty-lines.js.html +0 -244
- package/coverage/lcov-report/src/nodes/print-separated-item.js.html +0 -148
- package/coverage/lcov-report/src/nodes/print-separated-list.js.html +0 -154
- package/coverage/lcov-report/src/options.js.html +0 -238
- package/coverage/lcov-report/src/parser.js.html +0 -643
- package/coverage/lcov-report/src/printer.js.html +0 -214
- package/coverage/lcov.info +0 -2672
- package/jest.config.js +0 -40
- package/src/prettier-comments/common/util.js +0 -684
package/README.md
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://t.me/+kgTgkFgIwJkwMjcx)
|
|
4
4
|
[](https://twitter.com/PrettierSol)
|
|
5
|
+
[](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
|
-
|
|
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
|
-
|
|
45
|
+
### Using in the Browser
|
|
43
46
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
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
|
|
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
|
|
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.
|