prettier-plugin-solidity
Advanced tools
Comparing version 1.0.0-alpha.60 to 1.0.0-beta.1
{ | ||
"name": "prettier-plugin-solidity", | ||
"version": "1.0.0-alpha.60", | ||
"version": "1.0.0-beta.1", | ||
"description": "prettier plugin for solidity", | ||
@@ -74,11 +74,11 @@ "main": "src", | ||
"dependencies": { | ||
"@solidity-parser/parser": "^0.9.0", | ||
"@solidity-parser/parser": "^0.9.1", | ||
"dir-to-object": "^2.0.0", | ||
"emoji-regex": "^9.0.0", | ||
"escape-string-regexp": "^4.0.0", | ||
"extract-comments": "^1.1.0", | ||
"prettier": "^2.0.5", | ||
"semver": "^7.3.2", | ||
"solidity-comments-extractor": "^0.0.4", | ||
"string-width": "^4.2.0" | ||
} | ||
} |
@@ -6,5 +6,10 @@ # prettier-plugin-solidity | ||
[](https://t.me/joinchat/Je2WJFCfKJ_mht1XdhBh6w) | ||
[](https://twitter.com/PrettierSol) | ||
This is a work in progress [Prettier Plugin](https://prettier.io/docs/en/plugins.html) for [Solidity](https://github.com/ethereum/solidity). | ||
<p align="center"> | ||
<img width="375" height="375" src="https://user-images.githubusercontent.com/1022054/59317198-f1149b80-8d15-11e9-9b0f-0c5e7d4b8b81.png"> | ||
</p> | ||
A [Prettier Plugin](https://prettier.io/docs/en/plugins.html) for automatically formatting your [Solidity](https://github.com/ethereum/solidity) code. | ||
If you like this project, please consider contributing to our [Gitcoin grant](https://gitcoin.co/grants/1534/prettier-solidity)! | ||
@@ -20,6 +25,12 @@ | ||
Run prettier in your contracts: | ||
``` | ||
npx prettier --write 'contracts/**/*.sol' | ||
``` | ||
You can add a script for running prettier on all your contracts: | ||
``` | ||
"prettier": "prettier --write **/*.sol" | ||
"prettier": "prettier --write 'contracts/**/*.sol'" | ||
``` | ||
@@ -30,3 +41,3 @@ | ||
``` | ||
"lint": "prettier --list-different **/*.sol" | ||
"lint": "prettier --list-different 'contracts/**/*.sol'" | ||
``` | ||
@@ -33,0 +44,0 @@ |
@@ -0,5 +1,16 @@ | ||
const { | ||
doc: { | ||
builders: { join, line } | ||
} | ||
} = require('prettier/standalone'); | ||
const { printString } = require('../prettier-comments/common/util'); | ||
const HexLiteral = { | ||
print: ({ node }) => node.value | ||
print: ({ node, options }) => { | ||
const list = node.parts.map((part) => `hex${printString(part, options)}`); | ||
return join(line, list); | ||
} | ||
}; | ||
module.exports = HexLiteral; |
@@ -0,7 +1,15 @@ | ||
const { | ||
doc: { | ||
builders: { join, line } | ||
} | ||
} = require('prettier/standalone'); | ||
const { printString } = require('../prettier-comments/common/util'); | ||
const StringLiteral = { | ||
print: ({ node, options }) => printString(node.value, options) | ||
print: ({ node, options }) => { | ||
const list = node.parts.map((part) => printString(part, options)); | ||
return join(line, list); | ||
} | ||
}; | ||
module.exports = StringLiteral; |
@@ -1,2 +0,2 @@ | ||
const extract = require('extract-comments'); | ||
const extractComments = require('solidity-comments-extractor'); | ||
// https://prettier.io/docs/en/plugins.html#parsers | ||
@@ -17,3 +17,3 @@ const parser = require('@solidity-parser/parser'); | ||
const parsed = parser.parse(text, { loc: true, range: true }); | ||
parsed.comments = extract(text); | ||
parsed.comments = extractComments(text); | ||
@@ -20,0 +20,0 @@ parser.visit(parsed, { |
Sorry, the diff of this file is not supported yet
492685
255
3784
147
+ Addedsolidity-comments-extractor@0.0.4(transitive)
- Removedextract-comments@^1.1.0
- Removedesprima@4.0.1(transitive)
- Removedesprima-extract-comments@1.1.0(transitive)
- Removedextract-comments@1.1.0(transitive)
- Removedparse-code-context@1.0.0(transitive)