Skip to content

Commit 7a4d4bd

Browse files
authored
alpha (#34)
* ready to alpha * moar lines * s/default/ * reorg test * fix indentation
1 parent b1c31b2 commit 7a4d4bd

13 files changed

Lines changed: 66 additions & 25 deletions

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,5 @@ typings/
6363
.DS_Store
6464

6565
package-lock.json
66+
67+
yarn.lock

.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
registry=https://registry.npmjs.org

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,9 @@ node_modules/.bin/prettier --write **/*.sol --plugin=./src
1717
```bash
1818
node_modules/.bin/prettier --write **/*.sol --plugin=./node_modules/prettier-plugin-solidity
1919
```
20+
21+
## Install
22+
23+
```bash
24+
npm install mattiaerre/prettier-plugin-solidity
25+
```

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "prettier-plugin-solidity",
3-
"version": "0.0.2",
3+
"version": "1.0.0-alpha.1",
44
"description": "prettier plugin for solidity",
55
"main": "src",
66
"scripts": {

src/printer.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ function genericPrint(path, options, print) {
4949
indent(line),
5050
indent(join(hardline, path.map(print, 'subNodes'))),
5151
line,
52-
'}'
52+
'}',
53+
line
5354
]);
5455
case 'InheritanceSpecifier':
5556
return path.call(print, 'baseName');
@@ -91,7 +92,7 @@ function genericPrint(path, options, print) {
9192
]);
9293
}
9394
if (node.body) {
94-
return join(' ', [doc, path.call(print, 'body')]);
95+
return concat([line, join(' ', [doc, path.call(print, 'body')])]);
9596
}
9697
return concat([doc, ';']);
9798
case 'ParameterList':
@@ -254,6 +255,9 @@ function genericPrint(path, options, print) {
254255
if (node.isIndexed) {
255256
doc = join(' ', [doc, 'indexed']);
256257
}
258+
if (node.visibility === 'default') {
259+
return join(' ', [doc, node.name]);
260+
}
257261
return join(' ', [doc, node.visibility, node.name]);
258262
case 'ArrayTypeName':
259263
return concat([

tests/SimpleStorage.sol

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
pragma solidity ^0.4.0;
2+
3+
contract SimpleStorage {
4+
string public name = "SimpleStorage";
5+
uint storedData;
6+
7+
function set(uint x) public {
8+
storedData = x;
9+
}
10+
11+
function get() public view returns (uint) {
12+
return storedData;
13+
}
14+
}

tests/contract/__snapshots__/jsfmt.spec.js.snap renamed to tests/__snapshots__/jsfmt.spec.js.snap

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3-
exports[`inbox.sol 1`] = `
3+
exports[`Inbox.sol 1`] = `
44
// This comment spans one line
55
66
/*
@@ -28,11 +28,46 @@ contract Inbox {
2828
pragma solidity ^0.4.23;
2929
contract Inbox {
3030
string public message;
31+
3132
constructor(string initialMessage) public {
3233
message = initialMessage;
3334
}
35+
3436
function setMessage(string newMessage) public {
3537
message = newMessage;
3638
}
3739
}
40+
41+
`;
42+
43+
exports[`SimpleStorage.sol 1`] = `
44+
pragma solidity ^0.4.0;
45+
46+
contract SimpleStorage {
47+
string public name = "SimpleStorage";
48+
uint storedData;
49+
50+
function set(uint x) public {
51+
storedData = x;
52+
}
53+
54+
function get() public view returns (uint) {
55+
return storedData;
56+
}
57+
}
58+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
59+
pragma solidity ^0.4.0;
60+
contract SimpleStorage {
61+
string public name = "SimpleStorage";
62+
uint storedData;
63+
64+
function set(uint x) public {
65+
storedData = x;
66+
}
67+
68+
function get() public view returns(uint) {
69+
return storedData;
70+
}
71+
}
72+
3873
`;

tests/pragma/__snapshots__/jsfmt.spec.js.snap

Lines changed: 0 additions & 16 deletions
This file was deleted.

0 commit comments

Comments
 (0)