Closed ultraviolet10 closed 4 months ago
there's another interesting plugin we could use: https://www.npmjs.com/package/eslint-plugin-simple-import-sort
this helps sort imports in different files according to your specs, here's an example one:
"simple-import-sort/imports": [
"error",
{
"groups": [
// Packages. `react` related packages come first.
[
"^react",
"^next",
"@metamask|@walletconnect|clsx|@reduxjs|async-mutex|flowbite-react|redux-persist|pubnub|redux",
"^(ethers|google|lodash|bn.js|styled-components|child_process|cluster|console|constants|crypto|dgram|dns|domain|events|fs|http|https|module|net|os|path|punycode|querystring|readline|repl|stream|string_decoder|sys|timers|tls|tty|url|util|vm|zlib|freelist|v8|process|async_hooks|http2|perf_hooks)"
],
// Internal packages.
["^@?\\w"],
// Parent imports. Put `..` last.
["^\\.\\.(?!/?$)", "^\\.\\./?$"],
// Other relative imports. Put same-folder imports and `.` last.
["^\\./(?=.*/)(?!/?$)", "^\\.(?!/?$)", "^\\./?$"],
// Style imports.
["^.+\\.s?css$"],
// Side effect imports.
["^\\u0000"]
]
}
"tabWidth": 2
: @norswap did you want this as 4?
Yes let's go for 4!
"useTabs": true: https://prettier.io/docs/en/options.html#tabs
This is always religious, but I do prefer spaces myself. I guess with prettier it matters less, but it ensures proper display on Github for instance.
Any counter here? Like would you strongly prefer a 2 or 8 spaces local display?
"tabWidth": 2
: @norswap did you want this as 4?Yes let's go for 4!
"useTabs": true: https://prettier.io/docs/en/options.html#tabs
This is always religious, but I do prefer spaces myself. I guess with prettier it matters less, but it ensures proper display on Github for instance.
Any counter here? Like would you strongly prefer a 2 or 8 spaces local display?
No hard preference here, 4 is good!
Adds a global format command that runs prettier's
--write
on all specified file types.Uses the following options within the config (
prettierrc.json
):"semi": false
: prevents addition of semicolons on save"trailingComma": "es5"
: https://prettier.io/docs/en/options.html#trailing-commas"singleQuote": false
: uses double quotes for imports/elsewhere."tabWidth": 2
: @norswap did you want this as 4?"useTabs": true
: https://prettier.io/docs/en/options.html#tabs"printWidth": 100
: increase the number of characters that prettier will try to wrap around, prevents the dependency arrays ofuseEffect
anduseCallback
hooks from splitting into a column unless absolutely needed (https://prettier.io/docs/en/options.html#print-width).Also added
eslint-config-prettier
to be used as a plugin as the recommended mediator between linting and formatting.