🎉 First off, thanks for taking the time to contribute! 🎉
The following is a set of guidelines for contributing to Lingui. These are mostly guidelines, not rules. Use your best judgment, and feel free to propose changes to this document in a pull request.
This project and everyone participating in it are governed by the Code of Conduct. We expect that all community members adhere to the guidelines within.
Working on your first Pull Request? You can learn how from this free series How to Contribute to an Open Source Project on GitHub.
The documentation is based on Docusaurus framework. Source inside the website directory.
-
Go to the
website
directory:cd website
-
Install dependencies:
yarn install
-
To build the docs, watch for changes and preview documentation locally at http://localhost:3000/:
yarn start
-
It's also possible to run
yarn build
for single build. Incremental builds are much faster than the first one as only changed files are built. -
Please lint and validate the documentation before submitting any changes:
yarn lint yarn checkFormat
This project uses yarn package manager. Please follow official docs to install it.
-
Clone project
git clone https://github.com/lingui/js-lingui.git cd js-lingui
-
Install development packages. This project uses yarn workspaces instead of Lerna, so running
yarn
installs all development packages and also dependencies for all workspaces (insidepackages/*
).yarn
-
Run tests
# Watch mode yarn watch # Single run yarn test
Note If you are using an IDE to run test make sure to use the right Jest config. For unit tests use
-c jest.config.js
. Integration tests use build packages (created usingyarn release:build
) and config-c jest.config.integration.js
. See package.json for more info. If you run tests manually instead of usingyarn watch
oryarn test
commands and your tests fail due to missing locale data (typically you'll get wrong number and currency formatting) make sure you haveNODE_ICU_DATA
variable set:NODE_ICU_DATA=node_modules/full-icu
.
After you successfully fix a bug or add a new feature, you most probably want to test it in your project as soon as possible.
jsLingui
uses verdaccio, a lightweight local NPM registry, to install local build of packages in examples. You can do the same in your project:
-
Run
verdaccio
locally in docker (follow verdaccio guide if you don't want to run it in Docker):docker run -d -it --rm --name verdaccio -p 4873:4873 verdaccio/verdaccio
Make sure that your verdaccio user is the same that appears in verdacio-release.js script.
-
Publish local build of packages to registry. Run local release script:
node ./scripts/verdaccio-release.js
-
If you enter inside http://0.0.0.0:4873 (verdaccio instance), you will see your packages published, so you're ready to install them.
-
Inside your project, run:
with NPM:
# Point to your local registry npm config set registry http://0.0.0.0:4873/ # Run update-by-scope will update all @lingui packages npx update-by-scope @lingui
with Yarn (1.*):
yarn upgrade --scope @lingui --registry http://0.0.0.0:4873/ --latest
-
After you make some changes, you need to run the same process. (Releasing + yarn upgrade)
-
When finished testing, restore default registry (only for NPM)
npm config set registry https://registry.npmjs.org/
Please make sure that all tests pass and linter doesn't report any error before submitting a PR (Don't worry though! If you can't figure out the problem, create a PR anyway, and we'll help you).
yarn lint:all
- Linting & Type testingyarn test
- Quick test suite (sufficient)yarn release:test
- Full test suite (recommended)
yarn release:test
builds all packages, simulates creating packages for NPM, runs unit tests and finally runs integration tests using production build.
Note Don't commit
scripts/build/results.json
created byyarn release:test
.
Now you can create PR and let CI service do their work!
Note This project uses the Conventional Commits specification for commit messages and PR titles.
If you need any help, just raise an issue or submit a working draft of PR.