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

Add eslint rule to enforce file extenstions #1008

Merged
merged 3 commits into from
May 13, 2024

Conversation

jonathangoulding
Copy link
Collaborator

Reference to the coding_convention - https://github.com/DEFRA/water-abstraction-team/blob/main/coding_conventions.md#add-the-js-extension

When linking to an internal module in our require() statements always include the *.js extension.

// Good
const RequestLib = require('../lib/request.lib.js')

// Bad
const RequestLib = require('../lib/request.lib')

We know 😝 that you don't have to and that generally the convention is not to. But we still hold out hope that one day we'll switch our main repo from CommonJS to ES6 modules. The extension is required when using import and the work of migrating is made easier if the existing require() statements already include it.

Reference to the coding_convention - https://github.com/DEFRA/water-abstraction-team/blob/main/coding_conventions.md#add-the-js-extension

When linking to an internal module in our require() statements always include the *.js extension.

// Good
const RequestLib = require('../lib/request.lib.js')

// Bad
const RequestLib = require('../lib/request.lib')

We know 😝 that you don't have to and that generally the convention is not to. But we still hold out hope that one day we'll switch our main repo from CommonJS to ES6 modules. The extension is required when using import and the work of migrating is made easier if the existing require() statements already include it.
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.

You hero!

This is the very rule I was trying to figure out how to implement that sent me down a rabbit hole of adding the other ones (the ones I could figure out 😬 )

@Cruikshanks Cruikshanks added the conventions Changes to tools that enforce our conventions label May 13, 2024
@jonathangoulding jonathangoulding merged commit 6ee704a into main May 13, 2024
6 checks passed
@jonathangoulding jonathangoulding deleted the chore-add-eslint-extensions-rule branch May 13, 2024 09:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
conventions Changes to tools that enforce our conventions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants