prettier-config-solidity – 更漂亮的外形坚固区块链毕设代写

区块链毕设代写本文提供国外最新区块链项目源码下载,包括solidity,eth,fabric等blockchain区块链,prettier-config-solidity – 更漂亮的外形坚固区块链毕设代写 是一篇很好的国外资料

prettier-config-solidity

Prettier configuration for Solidity

Quickstart

/**  * @file prettier.config.js  * @version v1.2.1  * @summary Prettier Configuration for Solidity  */  'use strict';  const prettierConfig = require('prettier-config-solidity'); module.exports = prettierConfig;

Overview

Prettier configuration for Solidity

Install

Prettier

npm i -D prettier prettier-plugin-solidity prettier-config-solidity  --save-exact

with SolHint

npm install --save-dev solhint solhint-plugin-prettier prettier prettier-plugin-solidity --save-exact
{   "plugins": ["prettier"],   "rules": {     "prettier/prettier": "error"   } }

Abstract

This configuration is optimized to reduce diff churn and improve AST results.

The following rules are employed, with specific reasonings to their choice (source: airbnb style guide):

whitespace

source@airbnb/javascript#whitespace–in-braces

  • 19.12 Add spaces inside curly braces. eslint: object-curly-spacing
// bad const foo = { clark: 'kent' };  // good const foo = { clark: 'kent' };

arrow-parens

  • 8.4 Always include parentheses around arguments for clarity and consistency. eslint: arrow-parens

source@airbnb/javascript#arrows–one-arg-parens

Why? Minimizes diff churn when adding or removing arguments.

// bad [1, 2, 3].map((x) => x * x);  // good [1, 2, 3].map((x) => x * x);  // bad [1, 2, 3].map(   (number) =>     `A long string with the ${number}. It’s so long that we don’t want it to take up space on the .map line!`, );  // good [1, 2, 3].map(   (number) =>     `A long string with the ${number}. It’s so long that we don’t want it to take up space on the .map line!`, );  // bad [1, 2, 3].map((x) => {   const y = x + 1;   return x * y; });  // good [1, 2, 3].map((x) => {   const y = x + 1;   return x * y; });

one var

  • 13.2 Use one const or let declaration per variable or assignment. eslint: one-var

Why? It’s easier to add new variable declarations this way, and you never have to worry about swapping out a ; for a , or introducing punctuation-only diffs. You can also step through each declaration with the debugger, instead of jumping through all of them at once.

ref:eslint/rules/one-var
// bad const items = getItems(),   goSportsTeam = true,   dragonball = 'z';  // bad // (compare to above, and try to spot the mistake) const items = getItems(),   goSportsTeam = true; dragonball = 'z';  // good const items = getItems(); const goSportsTeam = true; const dragonball = 'z';

20.2 Additional trailing comma: Yup. eslint: comma-dangle

Why? This leads to cleaner git diffs. Also, transpilers like Babel will remove the additional trailing comma in the transpiled code which means you don’t have to worry about the trailing comma problem in legacy browsers. 
// bad - git diff without trailing comma const hero = {      firstName: 'Florence', -    lastName: 'Nightingale' +    lastName: 'Nightingale', +    inventorOf: ['coxcomb chart', 'modern nursing'] };  // good - git diff with trailing comma const hero = {      firstName: 'Florence',      lastName: 'Nightingale', +    inventorOf: ['coxcomb chart', 'modern nursing'], };

8.6 Enforce the location of arrow function bodies with implicit returns. eslint: implicit-arrow-linebreak

// bad (foo) => bar;  (foo) => bar;  // good (foo) => bar; (foo) => bar; (foo) => bar;

License

SPDX-License-Identifier: Apache-2.0


prettier config solidity

稳定的更漂亮配置

快速启动

/**  * @file prettier.config.js  * @version v1.2.1  * @summary Prettier Configuration for Solidity  */  'use strict';  const prettierConfig = require('prettier-config-solidity'); module.exports = prettierConfig;

概述

稳定的更漂亮配置

安装

prettier

npm i -D prettier prettier-plugin-solidity prettier-config-solidity  --save-exact

摘要

npm install --save-dev solhint solhint-plugin-prettier prettier prettier-plugin-solidity --save-exact
{   "plugins": ["prettier"],   "rules": {     "prettier/prettier": "error"   } }

空白

此配置经过优化以减少差异波动并改善AST结果。

采用以下规则,并给出具体的选择理由(来源:airbnb style guide):

箭头排列

source@airbnb/javascript#空白–大括号中source@airbnb/javascript箭头–一个参数

  • 19.12在花括号内添加空格。eslint:object curly spacing
// bad const foo = { clark: 'kent' };  // good const foo = { clark: 'kent' };

一个var

  • 8.4始终在参数周围包含圆括号,以保持清晰性和一致性。eslint:arrow parens

为什么?最小化添加或删除参数时的差异搅动。为什么?以这种方式添加新的变量声明更容易,而且您不必担心将a;换成a,或者只引入标点符号差异。也可以使用调试器单步执行每个声明,而不是一次跳过所有声明。

SPDX许可证标识符:Apache-2.0

// bad [1, 2, 3].map((x) => x * x);  // good [1, 2, 3].map((x) => x * x);  // bad [1, 2, 3].map(   (number) =>     `A long string with the ${number}. It’s so long that we don’t want it to take up space on the .map line!`, );  // good [1, 2, 3].map(   (number) =>     `A long string with the ${number}. It’s so long that we don’t want it to take up space on the .map line!`, );  // bad [1, 2, 3].map((x) => {   const y = x + 1;   return x * y; });  // good [1, 2, 3].map((x) => {   const y = x + 1;   return x * y; });

参考:eslint/rules/one var

  • 13.2为每个变量或赋值使用一个const或let声明。eslint:一个变量

Why? It’s easier to add new variable declarations this way, and you never have to worry about swapping out a ; for a , or introducing punctuation-only diffs. You can also step through each declaration with the debugger, instead of jumping through all of them at once.

20.2附加尾随逗号:是的。eslint:comma-dangle
// bad const items = getItems(),   goSportsTeam = true,   dragonball = 'z';  // bad // (compare to above, and try to spot the mistake) const items = getItems(),   goSportsTeam = true; dragonball = 'z';  // good const items = getItems(); const goSportsTeam = true; const dragonball = 'z';

8.6使用隐式返回强制箭头函数体的位置。eslint:implicit arrow linebreak

Why? This leads to cleaner git diffs. Also, transpilers like Babel will remove the additional trailing comma in the transpiled code which means you don’t have to worry about the trailing comma problem in legacy browsers. 
// bad - git diff without trailing comma const hero = {      firstName: 'Florence', -    lastName: 'Nightingale' +    lastName: 'Nightingale', +    inventorOf: ['coxcomb chart', 'modern nursing'] };  // good - git diff with trailing comma const hero = {      firstName: 'Florence',      lastName: 'Nightingale', +    inventorOf: ['coxcomb chart', 'modern nursing'], };

许可证

// bad (foo) => bar;  (foo) => bar;  // good (foo) => bar; (foo) => bar; (foo) => bar;

License

SPDX-License-Identifier: Apache-2.0

部分转自网络,侵权联系删除区块链源码网

www.interchains.cc

https://www.interchains.cc/20747.html

区块链毕设网(www.interchains.cc)全网最靠谱的原创区块链毕设代做网站 部分资料来自网络,侵权联系删除! 最全最大的区块链源码站 ! QQ3039046426
区块链知识分享网, 以太坊dapp资源网, 区块链教程, fabric教程下载, 区块链书籍下载, 区块链资料下载, 区块链视频教程下载, 区块链基础教程, 区块链入门教程, 区块链资源 » prettier-config-solidity – 更漂亮的外形坚固区块链毕设代写

提供最优质的资源集合

立即查看 了解详情