1.1.0 • Published 4 years ago

@tomsssm/eslint-config v1.1.0

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

Tomorepo

Monorepo of packages and projects created by @TomSssM

lerna Commitizen friendly

Getting Started

⚠️ Tomorepo won't work in a non-UNIX environment ⚠️

To initialize the environment run:

npm run init

This command will install the dependencies as well as linking all the local packages to their projects. The latter action is called bootstrap, you can do just bootstrap with a command:

npm run bootstrap

Read more what bootstrap is.

To bootstrap only one package add the following arguments to the bootstrap command:

npm run bootstrap -- --scope=package1
# or a list of packages:
npm run bootstrap -- --scope={package1,package2}

where package* is the name of the package you are about to develop.

Note: if you are using nvm, do nvm use to set the appropriate NodeJS version.

Packages

Generally, Tomorepo consists of:

Lifecycle of packages

An external dependency is a dependency from npm, a local dependency is the package that lives literally inside the Tomorepo ( inside the ./packages/** / ./public-packages/** directory ).

Note: some packages that live inside Tomorepo ( therefore local packages ) are published to npm and installed as external dependencies inside projects.

Adding an external dependency

The rules are the same as always:

npm install package1 package2

Note: to do CI, it is better to add packages as specified above instead of writing the package name and the version manually to package.json and then executing npm install. The latter approach will update the dependencies of dependencies as well, which might lead to inconsistencies. The locks for public packages are updated automatically.

Adding a local dependency

First Steps

Create a package called name in the ./packages/name directory. If you want the package to be published to npm, then create it inside the public-packages/* directory.

Make sure that the package.json has the same npm-scripts as described in the next section.

Note: package.json should always have "private": true unless it belongs to a package that should be published to npm ( the ./public-packages/** directory ). Read more about why here.

Linking

If there are other packages that depend on name, then simply do:

npx lerna add name --scope={package1,package2}

to add name to packages called package1 and package2, which depend on name ( don't specify --scope=... if you want to add name as a dependency to all the local packages and projects ).

This will symlink name to the node_modules of package1 and package2 for development. If you don't want such behavior, then simply publish name to npm and then npm i it.

Init a new project

Projects should have "private": true inside their package.json as well, to forbid accidentally publishing them to npm.

Also every project / package should have at least the following scripts:

  • test
  • lint

Commit

Tomorepo uses conventional commits so make sure that you are a nice commitizen 🚓

If you are new to conventional commits, feel free to use the interactive wizard to make a commit:

npm run commitizen
# or an alias:
npm run cz

Publish

Publish all the updated packages with the command:

npm run publish-all

This command will:

  • update the versions of all the modified packages since the last release
  • publish them to npm
  • will publish only public packages ( without "private": true in their package.json )

If you need to just bump versions of the packages without publishing them, then run:

npm run bump

Clean

To get a fully clean environment ( the same as on GitHub ) you need to run:

npm run clean

Details

There are many quirks to be discussed considering the inner workings of Tomorepo:

Allowed Languages

  • JavaScript
  • Node.js
  • Shell
  • TypeScript

TODO

  • Add eslint support to packages/configs
  • Write shared eslint configs
  • Test linters again
  • Edit the docs