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

Enhance the padding-line lint rules #1146

Merged
merged 4 commits into from
Jun 28, 2024
Merged

Conversation

Cruikshanks
Copy link
Member

@Cruikshanks Cruikshanks commented Jun 27, 2024

DEFRA/water-abstraction-team#115

We enhanced our linting rules to enforce spaces around blocks and expressions. This is a great step to helping folks 'fall into the pit of success' and avoid reviewers having to nitpick PRs.

But having enabled it, we've spotted that it is highlighting some things that are perfectly acceptable.

Screenshot 2024-06-27 at 14 38 35

We also think there are a few other options we could add.

So, this change is about building on the padding-line-between-statements we've already added.

Notes

  • Remove the config that is causing the violation
  • Ensure blanks after 'use strict' declaration
  • Ensure blanks after variable declarations

That last change ensures we put a blank line between variable declarations and the logic.

Running the linter across all files highlighted a number of violations. But the first 3 we fixed in this change give a good example of what to expect from this rule.

  • app/presenters/base.presenter.js - simple example of separating variables from logic to help readability
  • app/presenters/bill-runs/two-part-tariff/review-bill-run.presenter.js - demonstrating that comments are handled!
  • app/presenters/licences/set-up.presenter.js - this is an example of compromise. It could be rightly argued it is better to have the var declaration next to the logic. But for the sake of consistency and having a tool to automate this stuff, we'll compromise and make the change

DEFRA/water-abstraction-team#115

We enhanced our linting rules to enforce [spaces around blocks and expressions](#1143). This is a great step to helping folks 'fall into the pit of success' and avoid reviewers having to nit-pick PRs.

But having enabled it we've spotted it is highlighting some things that are perfectly acceptable. We also think there are a few other options we could add.

So, this change is about building on the [padding-line-between-statements](https://eslint.style/rules/js/padding-line-between-statements) we've already added.
When we run linter across the whole code base it finds an example of what we want to avoid Perfect!
@Cruikshanks Cruikshanks added the housekeeping Refactoring, tidying up or other work which supports the project label Jun 27, 2024
@Cruikshanks Cruikshanks self-assigned this Jun 27, 2024
This ensures we put a blank line between variables declarations and the logic.

Running the linter across all files highlighted a number of violations. But the first 3 (now) fixed give a good example of what to expect from this rule.

- `app/presenters/base.presenter.js` - simple example of separating variables from logic to help readability
- `app/presenters/bill-runs/two-part-tariff/review-bill-run.presenter.js` - demonstrating that comments are handled!
- `app/presenters/licences/set-up.presenter.js` - this is an example of compromise. It could be rightly argued it is better to have the var declaration next to the logic. But for the sake of consistency and having a tool to automate this stuff, we'll compromise and make the change
No violations of this one to demonstrate the rules. But we think it's pretty obvious what it relates to!
@Cruikshanks Cruikshanks marked this pull request as ready for review June 27, 2024 16:00
Copy link
Contributor

@rvsiyad rvsiyad left a comment

Choose a reason for hiding this comment

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

@Cruikshanks Cruikshanks merged commit e5dab58 into main Jun 28, 2024
6 checks passed
@Cruikshanks Cruikshanks deleted the tweak-padding-line-rules branch June 28, 2024 09:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
housekeeping Refactoring, tidying up or other work which supports the project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants