All Projects → prettier-solidity → Prettier Plugin Solidity

prettier-solidity / Prettier Plugin Solidity

Licence: mit
Prettier plugin for Solidity

Programming Languages

javascript
184084 projects - #8 most used programming language
solidity
1140 projects

Projects that are alternatives of or similar to Prettier Plugin Solidity

Awesome Token Sale
Curated list of token sale resources / ICO resources
Stars: ✭ 149 (-4.49%)
Mutual labels:  ethereum
React Native Geth
Ethereum Light-Client implementation for React Native
Stars: ✭ 152 (-2.56%)
Mutual labels:  ethereum
Interledger Rs
An easy-to-use, high-performance Interledger implementation written in Rust
Stars: ✭ 155 (-0.64%)
Mutual labels:  ethereum
Sparkle Airdrop
Sparkle Airdrop Contract Built on Ethereum
Stars: ✭ 150 (-3.85%)
Mutual labels:  ethereum
Rattle
evm binary static analysis
Stars: ✭ 152 (-2.56%)
Mutual labels:  ethereum
Cryptocurrency Icons
A set of icons for all the main cryptocurrencies and altcoins, in a range of styles and sizes.
Stars: ✭ 2,116 (+1256.41%)
Mutual labels:  ethereum
Pettier
Prettier config that randomizes options and arbitrarily switches between spaces and tabs 🙄
Stars: ✭ 149 (-4.49%)
Mutual labels:  prettier
Telegram Kraken Bot
Python bot to trade on Kraken via Telegram
Stars: ✭ 156 (+0%)
Mutual labels:  ethereum
Tokenbase
A repository of ERC20 token information. Tokens listed are tradeable on https://forkdelta.github.io. We welcome contributions! 🎉
Stars: ✭ 152 (-2.56%)
Mutual labels:  ethereum
Protocol v1
[DEPRECATED] Solidity Smart Contracts for the dYdX V1 Margin Trading Protocol
Stars: ✭ 155 (-0.64%)
Mutual labels:  ethereum
Erc20 Rest Service
ERC-20 token standard RESTful service using Spring Boot and web3j
Stars: ✭ 150 (-3.85%)
Mutual labels:  ethereum
Spotless
Keep your code spotless
Stars: ✭ 2,285 (+1364.74%)
Mutual labels:  prettier
Defi Score
DeFi Score: An open framework for evaluating DeFi protocols
Stars: ✭ 152 (-2.56%)
Mutual labels:  ethereum
0x Mesh
A peer-to-peer network for sharing 0x orders
Stars: ✭ 149 (-4.49%)
Mutual labels:  ethereum
Lemon.email Dapp
Lemon dApp is a world's first encrypted & decentralized e-mail service.
Stars: ✭ 155 (-0.64%)
Mutual labels:  ethereum
Ebtc
eBitcoin (eBTC) is an ERC20 token. Its primary utility is to provide an easy & fast payment solution. Its edge over other tokens is that it is capable of sending up to 255 payments in a single transaction.
Stars: ✭ 149 (-4.49%)
Mutual labels:  ethereum
Chainlink Ruby
Easily connect your applications to blockchains
Stars: ✭ 152 (-2.56%)
Mutual labels:  ethereum
Bot18
Bot18 is a high-frequency cryptocurrency trading bot developed by Zenbot creator @carlos8f
Stars: ✭ 157 (+0.64%)
Mutual labels:  ethereum
Web3 By Example
Node.js with Web3 javascript examples for getting basic information (transactions, balances, network stats, and tokens) from the Ethereum blockchain.
Stars: ✭ 156 (+0%)
Mutual labels:  ethereum
Ethers.objc
Fast, simple and complete library for Ethereum in Objective-C.
Stars: ✭ 154 (-1.28%)
Mutual labels:  ethereum

prettier-plugin-solidity

Build Status codecov Telegram Twitter Follow

A Prettier Plugin for automatically formatting your Solidity code.

If you like this project, please consider contributing to our Gitcoin grant!

Installation and usage

Install both prettier and prettier-plugin-solidity:

npm install --save-dev prettier prettier-plugin-solidity

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 'contracts/**/*.sol'"

Or you can use it as part of your linting to check that all your code is prettified:

"lint": "prettier --list-different 'contracts/**/*.sol'"

Who's using it?

These are some of the projects using Prettier Solidity:

Integrations

Vim

To integrate this plugin with vim, first install vim-prettier. These instructions assume you are using vim-plug. Add this to your configuration:

Plug 'prettier/vim-prettier', {
  \ 'do': 'yarn install && yarn add prettier-plugin-solidity',
  \ 'branch': 'release/1.x',
  \ 'for': [
    \ 'javascript',
    \ 'typescript',
    \ 'css',
    \ 'less',
    \ 'scss',
    \ 'json',
    \ 'graphql',
    \ 'markdown',
    \ 'vue',
    \ 'lua',
    \ 'php',
    \ 'python',
    \ 'ruby',
    \ 'html',
    \ 'swift',
    \ 'solidity'] }

We modified the do instruction to also install this plugin. Then you'll have to configure the plugin to always use the version installed in the vim plugin's directory:

let g:prettier#exec_cmd_path = '~/.vim/bundle/vim-prettier/node_modules/.bin/prettier'

To check that everything is working, open a solidity file and run :Prettier.

If you also want to autoformat every time you write the buffer, add these lines:

let g:prettier#autoformat = 0
autocmd BufWritePre *.sol Prettier

Now Prettier will be run every time the file is saved.

VSCode

VSCode is not familiar with the solidity language, so solidity support needs to be installed.

code --install-extension JuanBlanco.solidity

Having done that you should proceed to install prettier-vscode.

code --install-extension esbenp.prettier-vscode

To interact with 3rd party plugins, prettier-vscode will look in the project's npm modules, so you'll need to have prettier and prettier-plugin-solidity in your package.json

npm install --save-dev prettier prettier-plugin-solidity

As a final check, make sure that VSCode is configured to format files on save.

You'll notice now that prettier is formatting every time the files are saved but the indentation is using 2 spaces instead of 4. This has been reported and in the meantime you can use the following configuration in your .prettierrc file:

{
  "overrides": [
    {
      "files": "*.sol",
      "options": {
        "printWidth": 80,
        "tabWidth": 4,
        "useTabs": false,
        "singleQuote": false,
        "bracketSpacing": false,
        "explicitTypes": "always"
      }
    }
  ]
}

Note: When you install the npm package prettier in your project and create a .prettierrc file (which wasn't in your project before this), your VSCode's default settings or rules in settings.json are ignored (prettier/prettier-vscode#1079).

If you want a different configuration for your javascript and solidity files, you can add an overrides property to your .prettierrc.

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b feature/fooBar)
  3. Commit your changes (git commit -am 'Add some fooBar')
  4. Push to the branch (git push origin feature/fooBar)
  5. Create a new Pull Request

License

Distributed under the MIT license. See LICENSE for more information.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].