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" + } + ] } } diff --git a/src/index.js b/src/index.js index 60d9c4f..a9b0b1b 100644 --- a/src/index.js +++ b/src/index.js @@ -1,25 +1,53 @@ /** - * @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} + */ module.exports = { arrowParens: 'always', - bracketSpacing: true, - endOfLine: 'lf', - printWidth: 80, + bracketSameLine: true, + 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, + 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', @@ -34,4 +62,3 @@ module.exports = { }, ], }; -/** @exports prettier-config-solidity */