Skip to content

Latest commit

 

History

History
52 lines (37 loc) · 1.67 KB

CONTRIBUTING.md

File metadata and controls

52 lines (37 loc) · 1.67 KB

How to Contribute

Thanks for taking the time to contribute!

Testing

We are using the Jest framework for testing. Imgur API mocking is configured via msw. This makes it simple to mock API responses. Simply add a new handler for an endpoint to mocks/handlers.js and that's it. These mocks are automatically configured to work for all new and existing tests.

Here's an example that mocks a response when making a POST request to https://api.imgur.com/3/image:

const handlers = [
  rest.post('https://api.imgur.com/3/image', (_req, res, ctx) => {
    const response = {
      data: {
        id: 'JK9ybyj',
        deletehash: 'j83zimv4VtDA0Xp',
        link: 'https://i.imgur.com/JK9ybyj.jpg',
      },
      success: true,
      status: 200,
    };
    return res(ctx.json(response));
  }),
];

Submitting Changes

We use commitizen to enforce conventional commits. This enables us to automate both semantic versioning and npm releases.

Install the commitizen command line tool:

npm install -g commitizen

Now simply use git cz or just cz instead of git commit when committing.

If you prefer not to install the commitizen command globally, alternatively you can use npm run commit instead of git commit.

Coding Conventions

  • Prettier is ran and applied automatically as part of a precommit hook, so you don't have to worry about semicolons or trailing commas