From 0eea6fccdf5beae111d78225b16d77a658dfe193 Mon Sep 17 00:00:00 2001 From: Alan Cruikshanks Date: Tue, 24 Dec 2024 15:24:20 +0000 Subject: [PATCH] Add enforcement of .js extensions for require() https://github.com/DEFRA/water-abstraction-team/issues/115 Recently, we [overhauled our project linting](https://github.com/DEFRA/water-abstraction-system/pull/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!