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 enforcement of .js extensions for require() #1586

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

Cruikshanks
Copy link
Member

DEFRA/water-abstraction-team#115

Recently, we overhauled our project linting. We moved to ESLint v9 and its new flat file config, switched to Prettier to handle our 'style' conventions, and replaced StandardJS with Neostandard.

On that last point, the one rule we could not migrate at the time was the enforcement of .js extensions when requiring modules. We know Node.js will handle this for us and that the extension is not required. Eventually, we intend to migrate to ESM modules, and from previous attempts, having the .js in place reduces the amount of work this requires.

We are now happy to report that in v0.12.0 Neostandard has adopted eslint-plugin-import-x so we can add the rule back in, which is handy, as we've spotted new instances of folks forgetting to do this!

DEFRA/water-abstraction-team#115

Recently, we [overhauled our project linting](#1476). We moved to ESLint v9 and its new flat file config, switched to Prettier to handle our 'style' conventions, and replaced StandardJS with Neostandard.

On that last point, the one rule we could not migrate at the time, was enforcement of `.js` extensions when requiring modules. We know Node.js will handle this for us: the extension is not required. But eventually we intend to migrate to ESM modules and from previous attempts, having the `.js` in place reduces the amount of work this requires.

We are now happy to report that in v0.12.0 [Neostandard](https://github.com/neostandard/neostandard) has adopted [eslint-plugin-import-x](https://github.com/un-ts/eslint-plugin-import-x) so we can add the rule back in, which is handy, as we've spotted new instances of folks forgetting to do this!
@Cruikshanks Cruikshanks added the housekeeping Refactoring, tidying up or other work which supports the project label Dec 24, 2024
@Cruikshanks Cruikshanks self-assigned this Dec 24, 2024
The rule is also flagging `eslint.config.js`, specifically `const eslintPluginPrettierRecommended = require('eslint-plugin-prettier/recommended')` which is a false-positive.
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.

1 participant