Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check for console.log() in CI #1156

Merged
merged 13 commits into from
Jul 3, 2024
Merged

Check for console.log() in CI #1156

merged 13 commits into from
Jul 3, 2024

Conversation

rvsiyad
Copy link
Contributor

@rvsiyad rvsiyad commented Jul 2, 2024

DEFRA/water-abstraction-team#94

During development, we constantly use console.log() to print out and check for expected results. Although they are useful during the development process, it is very common that we forget to remove them, leading to requested changes during pull requests 😪.

Currently, we use checks within our CI to catch mistakes similar to this such as .only() on describe and it blocks within our unit tests.

      # Before we do anything, check we haven't accidentally left any `describe.only()` or `it.only(` statements in the
      # tests
      #
      # Reworking of https://stackoverflow.com/a/21788642/6117745
      - name: Temporary tag check
        run: |
          ! grep -R 'describe.only(\|it.only(' test

Aside from the accidental console.log() present, there is one instance we do not want the CI to flag. Within app/server.js there is a console.log() that is there to log unhandled exceptions. In this case we can change it to 'console.error()' to get around this.

This PR is focused on implementing the checks for console.log() when pushing code and changing the console.log() within app/server.js to console.error().

DEFRA/water-abstraction-team#94

During development, we constantly use `console.log()` to print out and check for expected results. Although they are useful during the development process,
it is very common that we forget to remove them, leading to requested changes during pull requests 😪.

Currently, we use checks within our CI to catch mistakes similar to this such as `.only()` on `describe` and `it` blocks within our unit tests.

```yaml
      # Before we do anything, check we haven't accidentally left any `describe.only()` or `it.only(` statements in the
      # tests
      #
      # Reworking of https://stackoverflow.com/a/21788642/6117745
      - name: Temporary tag check
        run: |
          ! grep -R 'describe.only(\|it.only(' test
```

Aside from the accidental `console.log()` present, there is one instance we do not want the CI to flag. Within `app/server.js` there is a `console.log()`
that is there to log unhandled exceptions. In this case we can change it to 'console.error()' to get around this.

This PR is focused on implementing the checks for `console.log()` when pushing code and changing the `console.log()` within `app/server.js` to `console.error()`.
@rvsiyad rvsiyad added the enhancement New feature or request label Jul 2, 2024
@rvsiyad rvsiyad self-assigned this Jul 2, 2024
@rvsiyad rvsiyad marked this pull request as ready for review July 2, 2024 16:04
Copy link
Member

@Cruikshanks Cruikshanks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rvsiyad rvsiyad merged commit e40ae73 into main Jul 3, 2024
6 checks passed
@rvsiyad rvsiyad deleted the check-for-console.log branch July 3, 2024 08:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants