frontend-coding-standards
frontend-coding-standards copied to clipboard
Standard set of yarn commands for every project
Linting, testing, starting a dev server, formatting, typechecking, building. Those are things that we should have available in every project in a standard way.
For example should we use yarn start or yarn dev? Or both?
For most of them we already use more or less the same ones. I am in favor of further unifying these. I think muban uses lint:css and vue-skeleton lint:scss or vice versa. I would be in favor of yarn start.
I like yarn dev as it is one characters less than yarn start and it's already been used in most of the projects that I have worked on.
It also gives a good differentiation between running local development and running a build.
yarn start is used a lot in the public, we could add it as an alias to the default dev script (I like to at least have dev and build in there, since they are more descriptive)
List of scripts (feel free to append to the opening comment):
yarn start- alias toyarn devyarn devyarn buildyarn check-types- separate script that checks TS typings (because babel only strips types), to be used in pre-commit hooksyarn lint- alias to all lint scripts (usingnpm-run-all)yarn lint:js- lints all js/ts - using eslintyarn lint:css- lint all (s)css - using stylelintyarn fix- alias to all fix scripts (with the same lints for js/css using the--fix)yarn test- runs unit tests, not in--watchmode (we could havetest:cifor CI, andtest:e2efor e2e tests)
In general the namespacing with npm-run-all works pretty nice.
I would suggest to also include yarn deploy for deployment to a configured deploy target.
You could also do something like this to differentiate between environments:
yarn deploy:devyarn deploy:stagingyarn deploy:prod
And also yarn preview to check if the yarn build script is valid.
IMO, I think we should get rid of yarn start entirely. As @ThaNarie already mentioned it is indeed used by the majority of the public and most of the time it is used as the command to start the development server. However, to me start doesn't tell me that it will surely start the development server, just that it will start something, which could also be a production build.
For this reason our CRA templates actually switched from the default yarn start to yarn dev.
My 2 cents are that:
yarn devshould be used as the command to start the development serveryarn serveshould be use as the command to build and "serve" the production build