Nuxt.JS Open Source Contribution Guidelines

From WikiOD

Welcome to make open source contributions to Nuxt.js!

Submit a question[edit | edit source]

We use CMTY to make it easier for contributors and maintainers to submit issues and new feature improvements.

Please make sure to include a clone repository or Code Sand Box so that the error can be better reproduced, the sooner we start to fix it!

Pull Requests[edit | edit source]

Everyone is welcome to submit a PR (source code pull request), even if it is to fix a spelling error.

Any major improvements should be linked to existing feature requests or bug reports .

Start[edit | edit source]
  1. Fork the  code repository to your own GitHub account, and then  clone  to your local.
  2. Run npm install or yarn install to install dependencies.

Please note that both npm and yarn are considered missing dependencies. To solve this problem, you can delete the node_modules folder in the sample application and then reinstall or perform a local installation of the missing dependencies.

If you want to add dependencies, use yarn add. The yarn.lock file is the latest source of all Nuxt dependencies.

Construct[edit | edit source]

Before running any tests, make sure all dependencies are satisfied and build all dependencies:

yarn build
Test structure[edit | edit source]

A great and excellent PR, whether it contains bug fixes or new features, will include testing.

To write great tests, let us explain our test structure:

Fixtures[edit | edit source]

This fixtures (under the tests/fixtures directory) contains several Nuxt applications. In order to keep the build time as short as possible, we will not build our own Nuxt application for each test. Instead, before running the actual unit tests, construct (yarn test: fixtures).

When submitting a PR, please make sure to change or add a new fixture to correctly reflect the change (if applicable). Also, don't forget to rebuild fixtures by running the corresponding test with jest test/fixtures/my-fixture/my-fixture.test.js after the change.

Unit tests[edit | edit source]

Unit tests can be found in tests/unit and will be executed after the fixtures are built. For each test, a new Nuxt server will be used so that there is no shared state (except for the initial state of the build step).

After adding unit tests, you can run them directly:

jest test/unit/test.js

Or you can run the entire unit test:

yarn test:unit

Please note again that you may need to rebuild your fixture!

Test your changes[edit | edit source]

When dealing with PR, you may need to check whether the fixture is set up correctly or debug the current changes. To do this, you can use the Nuxt script itself to launch, for example, your fixture or sample application:

yarn nuxt examples/your-app
yarn nuxt test/fixtures/your-fixture-app

npm link can also (and to some extent) work for this, but sometimes it has some problems. This is why we recommend calling yarn nuxt directly to run the example.

example[edit | edit source]

If you are developing a larger feature, please set up a sample application in examples/. This will help understand the changes and help Nuxt users gain insight into the features you submit to build.

Linting[edit | edit source]

You may have noticed that we are using ESLint to enforce code standards. Please run yarn lint your changes before submitting to check whether the code style is standard. If not, you can use yarn lint --fix or npm run lint - --fix (no misspellings!) to fix most of the style changes. If there are still errors, they must be corrected manually.

Documentation[edit | edit source]

If you want to add new features, please refactor or change Nuxt's behavior in any other way, you may do so and want to record the changes. Please submit a PR to the  docs  code repository. You do not need to write the document immediately (but please submit it after the PR is sufficiently rigorous and inspected).

Submission process[edit | edit source]

When submitting a PR, you need to fill out a simple template.

Please check all corresponding "answers" in the list.

Debug test on macOS[edit | edit source]

Searching for getPort() will reveal that it is used to start a new Nuxt process during the test. With macOS it sometimes stops and may require you to manually set the port for testing.

Another common problem is that the Nuxt process may hang memory when running fixture tests. The process usually prevents subsequent testing efforts. Run ps aux | grep -i node If you are puzzled that this is happening, check for any pending test procedures.