File sharing karma, eslint, etc. Through multiple codebases
I have a few repositories that share the same configuration files (eg, .eslintrc
, .babelrc
, karma.conf.js
), as well as other files of official files. I wish they could check them out and be able to use them across all repos. What are some of the best ways to achieve this?
- Create a new repo and publish it as a module
npm
. Then import it and use it as needed? - Create a CLI tool that basically generates the required files.
- Creating a symbolic link?
- Others?
I believe that 1
would be ideal, however I am not sure how one would refer to a file that is not exported. For example, how does one repo use a file .eslintrc
in this module npm
?
source to share
Symlinking won't work when you need to run builds and tests on a CI server, but it might be worth checking out lerna , which wraps multiple packages in monorepo.
I tried the CLI approach but ended up going with private "npm" "micro" modules, which I just ran in package.json
as needed.
What's wrong with the CLI:
- it introduces a global dependency that each team member must install on their machine.
- you need to create a mechanism to update the CLI yourself
- adds a layer of abstraction to your project.
To use specific .eslintrc
from npm module, you can pass eslint a --config
arg with your path .eslintrc
.
Keep in mind that these tools (eslint, babel, karma, mocha, etc.) are sometimes a pain to tweak and update, so it's a good idea to keep your codebase standalone and duplicate config files instead of having layers of abstraction.
source to share