0xFableOrg / 0xFable

A fully on-chain trading card game. There will be elves, wizards & shit. Drama and broken friendships also.
https://twitter.com/0xFableGame
BSD 3-Clause Clear License
103 stars 35 forks source link

Add global formatting for the webapp. #130

Closed ultraviolet10 closed 4 months ago

ultraviolet10 commented 5 months ago

Adds a global format command that runs prettier's --write on all specified file types.

Uses the following options within the config (prettierrc.json):

Also added eslint-config-prettier to be used as a plugin as the recommended mediator between linting and formatting.

ultraviolet10 commented 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"]
        ]
      }
ultraviolet10 commented 4 months ago

As well as: https://github.com/tailwindlabs/prettier-plugin-tailwindcss

norswap commented 4 months ago

"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?

ultraviolet10 commented 4 months ago

"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!