This site uses cookies for analytics. By continuing to browse this site, you agree to this use.
A JS Foundation Project

Development environment

Development environment

This is a step-by-step guide to setting up a local development environment that will let you contribute back to the project.

  1. Install Node.js and yarn
  2. Fork and checkout your own sonarwhal repository
  3. Add the upstream source
  4. Run the tests

Step 1: Install Node.js and yarn

Go to nodejs.org to download and install the latest stable version of Node.js for your operating system.

Go to yarnpkg.com to download and install the latest stable version of yarn for your operating system. sonarwhal uses yarn’s workspaces feature to maintain several packages in the same GitHub repo.

Step 2: Fork and checkout your own sonarwhal repository

Go to https://github.com/sonarwhal/sonarwhal and click the Fork button. Follow the GitHub documentation for forking and cloning.

Once you’ve cloned the repository:

git clone https://github.com/sonarwhal/sonarwhal.git

go into the project’s directory:

cd sonarwhal

and run yarn to get all the necessary dependencies:

yarn

You must be connected to the Internet for this step to work. You’ll see a lot of utilities being downloaded.

Step 3: Add the upstream source

The upstream source is the main sonarwhal repository that active development happens on. While you won’t have push access to upstream, you will have pull access, allowing you to pull in the latest code whenever you want.

To add the upstream source for sonarwhal, run the following in your repository:

git remote add upstream git@github.com:sonarwhal/sonarwhal.git

Now, the remote upstream points to the upstream source.

Step 4: Run the tests

Running the tests is the best way to ensure you have correctly set up your development environment. Make sure you’re in the sonarwhal directory, and then run:

yarn test

The testing takes a a bit to complete. If any tests fail, that likely means one or more parts of the environment setup didn’t complete correctly. The upstream tests always pass.

Built-in scripts

There are different scripts in all the package.json (root and package ones). The following is the list of all the available ones:

CommandDescriptionAvailability
avaShortcut to the ava binary. Useful if you want to test one file and/or skip some of the steps of the test taskeverywhere
buildThis will build the current package or all the packages from scratcheverywhere
build:connector-edgeThis builds the connector-edge package that is only possible on Windows. This separation is needed because we test on Travisroot
build:sonarwhalThis builds the main sonarwhal packageroot
build:assetsCopies the static files to the dist folderpackage
build:tsCompiles the TypeScript files and outputs to the dist folderpackage
cleanCleans the output of all the packages or the current oneeverywhere
lintLints all the markdown and TypeScript fileseverywhere
lint:jsLints TypeScript files using eslinteverywhere
lint:mdLints markdown files using markdownlinteverywhere
new:ruleStarts the wizard to create a new rule under /packages/root
releasePublishes the package in npm after running the tests and validate everything is finepackage
sonarwhalRuns sonarwhal from packages/sonarwhalpackage (sonarwhal)
testBuilds the package or all packages and runs the tests with code coverageeverywhere
test-on-travisThis modifies some of the configurations to make sure we don’t run into issues when testing on Traviseverywhere
watchLaunches all the other watch tasks in parallel, useful when developingpackage
watch:resourcesCopies all the static assets to dist and any new ones addedpackage
watch:testRuns the tests as soon as there is a test in the tests or in the code to testpackage
watch:tsCompiles the TypeScript files as soon as there is a changepackage