0.2.2 • Published 4 years ago

@matriarx/core v0.2.2

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years ago

Matriarx Core

A project template that contains the core essentials for any project.

Packages

  • typescript
  • jest
  • eslint
  • prettier
  • husky
  • lint-staged

Usage

  npx @matriarx/core 'project'
  cd 'project'
  npm i
  npx husky install bin
  git add bin/pre-commit && git add bin/pre-push

  ...

  npm start // run the index file
  npm run build // compile everything
  npm run deploy // compile everything and run the index file
  npm run dev // compile in watch mode
  npm test // run tests
  npm run lint // run eslint
  npm run style // run prettier

Using the above you can run dev in one terminal to watch for file changes and run start in another terminal to run the compiled index. Alternatively you can set up your own ts-node-dev or nodemon watchers. If you want to build for production you can just run deploy.

Config

  • All of the configurations for typescript, jest, eslint, prettier, husky and lint-staged have already been set up and can be used for any client- or serverside application.
  • You don't necessarily have to use the entire project, you can also just use it to quickly copy the configs.
  • Project root is /src so typescript will search for all source files there, after which it will compile everything to /lib.
  • Javascript is enabled by default so if you don't want to use typescript you can ignore it.
  • It will automatically lint and style the code on git commit as well as run the tests on git push, if you want to change that you can edit the husky hooks in /bin.
  • The coverage tests have a threshold which will fail the tests if you haven't covered majority of the code base, if you want to change that you can edit the percentage values in .jestrc.json.

Extension

Jsx is not enabled by default, if you want to use it you'll have to add a few things.

.tsrc.json:

  "include": ["src/**/*.ts", "src/**/*.tsx"],

tsconfig.json:

  "include": ["**/*.ts", "**/*.tsx"],
  "lib": ["esnext", "dom", "dom.iterable"],
  "jsx": "react", // leave it on preserve if you're using babel to compile your tsx

.jestrc.json:

  "testRegex": ["test/.*.[jt]sx?"],
  "moduleFileExtensions": ["js", "ts", "jsx", "tsx"],
  "collectCoverageFrom": ["src/**/*.{js,ts,jsx,tsx}"],

package.json:

  "lint": "eslint --fix {src,test}/**/*.{js,ts,jsx,tsx} --no-error-on-unmatched-pattern",
  "style": "prettier --write {src,test}/**/*.{js,ts,jsx,tsx,json} *.{json,*.json} !package-lock.json --no-error-on-unmatched-pattern",

  ...

  "lint-staged": {
    "{src,test}/**/*.{js,ts,jsx,tsx}": [

.eslintrc.json:

  "extends": [
    "eslint:recommended",
    "plugin:@typescript-eslint/recommended",
    "plugin:react/recommended",
    "standard",
    // add "next" here if you're using nextjs
    "prettier"
  ],
  "env": {
    "es2021": true,
    "jest": true,
    "browser": true
  },

  ...

  "parserOptions": {
    "ecmaFeatures": {
      "jsx": true
    },

  ...

  "plugins": [
    "@typescript-eslint",
    "react",
    "prettier"
  ],

Then install the plugin:

  npm i eslint-plugin-react -D

And install react:

  npm i react react-dom

If you're running a server like express then you'll need something to watch and compile your files on file changes while restarting the server.

  npm i ts-node-dev -D

package.json:

  "dev": "ts-node-dev src/server.ts"

Contribution

If you have any ideas or suggestions for ways I can improve on this repo you can contact me at mia@matriarx.org. If you find any issues let me know so I can fix it, alternatively feel free to make a PR.

License

MIT.

0.1.0

4 years ago

0.2.1

4 years ago

0.2.0

4 years ago

0.0.5

4 years ago

0.2.2

4 years ago

0.0.6

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.4

4 years ago

0.0.1

4 years ago