From b37967ca0267ae33a9f88f0dd1724dbf0db5bbee Mon Sep 17 00:00:00 2001 From: sam bacha Date: Wed, 8 Jun 2022 03:38:47 -0700 Subject: [PATCH 1/4] feat(prettier): import order sorting --- src/index.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/index.js b/src/index.js index 60d9c4f..656b678 100644 --- a/src/index.js +++ b/src/index.js @@ -10,9 +10,13 @@ 'use strict'; +/** + * @type {import('prettier').Options} + */ module.exports = { arrowParens: 'always', bracketSpacing: true, + bracketSameLine: true, endOfLine: 'lf', printWidth: 80, singleQuote: true, @@ -20,6 +24,10 @@ module.exports = { trailingComma: 'all', quoteProps: 'as-needed', semi: true, +plugins: [require.resolve("@trivago/prettier-plugin-sort-imports")], +importOrder: ["^@forge-std/(.*)$", "^ds-test/(.*)$", "^@openzeppelin/(.*)$"","^~(.*)$", "^[./]"], +importOrderSeparation: true, +importOrderSortSpecifiers: true, overrides: [ { files: '*.sol', From f61847153b8d3b0f3a0406fae530303dd0f1fccf Mon Sep 17 00:00:00 2001 From: sam bacha Date: Fri, 10 Jun 2022 00:27:45 -0700 Subject: [PATCH 2/4] fix(lint): eslint config --- .eslintrc | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/.eslintrc b/.eslintrc index 8e658f2..0185ea6 100644 --- a/.eslintrc +++ b/.eslintrc @@ -2,8 +2,37 @@ "env": { "jest": true }, - "extends": ["airbnb-base", "prettier"], "globals": { "run_spec": false + }, + "extends": ["airbnb-base", "prettier"], + "plugins": ["prettier"], + "rules": { + "prettier/prettier": [ + "error", + { + "singleQuote": true, + "trailingComma": "always" + } + ], + "max-len": [2, 130, 4], + "no-param-reassign": [ + 2, + { + "props": false + } + ], + "no-plusplus": 0, + "no-underscore-dangle": 0, + "prefer-rest-params": 0, + "comma-dangle": [2, + { + "arrays": "always-multiline", + "objects": "always-multiline", + "imports": "always-multiline", + "exports": "always-multiline", + "functions": "never" + } + ] } } From defe8c1cba60ff1673f23094d1ca615e4c9ff9b1 Mon Sep 17 00:00:00 2001 From: sam bacha Date: Sat, 11 Jun 2022 05:06:48 -0700 Subject: [PATCH 3/4] fix(prettier): refactor config for import sorts support --- src/index.js | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/src/index.js b/src/index.js index 656b678..3114722 100644 --- a/src/index.js +++ b/src/index.js @@ -1,15 +1,29 @@ /** - * @file Prettier configuration for Solidity - * @version 1.3.1 - * @summary base config adapted from AirBNB to reduce diff churn - * @overrides solidity settings from Solidity Documentation + * @package prettier-config-solidity + * @description Prettier configuration for Solidity + * @version 1.8.0 + * + * @summary base config adapted from AirBNB to reduce AST Diff Churn. + * Additionally, this overrides the suggested settings from + * the reference Solidity Documentation. + * + * @note Solidity does not support dangling commas, which would greatly + * improve the stated objectives of this configuration file * @note `printWidth` is not a line character capture - * @dev `explicitTypes` - * @solidity versions ^0.8.0 bytes1 + * + * @note `explicitTypes` are enforced for ABI conformance + * meaning `unit` is turned to `uint256` + * + * @note In Solidity versions ^0.8.0, bytes1 is removed + * */ 'use strict'; +/** +* @exports prettier-config-solidity +*/ + /** * @type {import('prettier').Options} */ @@ -25,7 +39,7 @@ module.exports = { quoteProps: 'as-needed', semi: true, plugins: [require.resolve("@trivago/prettier-plugin-sort-imports")], -importOrder: ["^@forge-std/(.*)$", "^ds-test/(.*)$", "^@openzeppelin/(.*)$"","^~(.*)$", "^[./]"], +importOrder: ["^@forge-std/(.*)$", "^ds-test/(.*)$", "^@openzeppelin/(.*)$","^~(.*)$", "^[./]"], importOrderSeparation: true, importOrderSortSpecifiers: true, overrides: [ @@ -42,4 +56,3 @@ importOrderSortSpecifiers: true, }, ], }; -/** @exports prettier-config-solidity */ From 06f3b8cd1620919bbcf47cd601d47682e1056eb4 Mon Sep 17 00:00:00 2001 From: sam bacha Date: Tue, 21 Jun 2022 13:23:25 -0700 Subject: [PATCH 4/4] fix(config): define all options --- src/index.js | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/src/index.js b/src/index.js index 3114722..a9b0b1b 100644 --- a/src/index.js +++ b/src/index.js @@ -17,31 +17,37 @@ * @note In Solidity versions ^0.8.0, bytes1 is removed * */ - 'use strict'; /** -* @exports prettier-config-solidity -*/ + * @exports prettier-config-solidity + */ /** * @type {import('prettier').Options} */ module.exports = { arrowParens: 'always', - bracketSpacing: true, bracketSameLine: true, - endOfLine: 'lf', - printWidth: 80, + bracketSpacing: false, + embeddedLanguageFormatting: 'auto', + htmlWhitespaceSensitivity: 'strict', + insertPragma: false, + jsxSingleQuote: false, + printWidth: 110, + proseWrap: 'always', + quoteProps: 'consistent', + requirePragma: false, + semi: true, singleQuote: true, tabWidth: 2, trailingComma: 'all', - quoteProps: 'as-needed', - semi: true, -plugins: [require.resolve("@trivago/prettier-plugin-sort-imports")], -importOrder: ["^@forge-std/(.*)$", "^ds-test/(.*)$", "^@openzeppelin/(.*)$","^~(.*)$", "^[./]"], -importOrderSeparation: true, -importOrderSortSpecifiers: true, + useTabs: false, + vueIndentScriptAndStyle: false, + plugins: [require.resolve("@trivago/prettier-plugin-sort-imports")], + importOrder: ["^@forge-std/(.*)$", "^ds-test/(.*)$", "^@openzeppelin/(.*)$", "^~(.*)$", "^[./]"], + importOrderSeparation: true, + importOrderSortSpecifiers: true, overrides: [ { files: '*.sol',