-
Notifications
You must be signed in to change notification settings - Fork 0
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
Switch to new eslint config format #991
base: main
Are you sure you want to change the base?
Conversation
DEFRA/water-abstraction-team#115 In [Add linting using eslint with standard as the base](#948) we switched from using [standard](https://www.npmjs.com/package/standard) directly for linting to using [ESlint](https://eslint.org/). This is all part of the work we are doing to start codifying our conventions rather than writing them up for no one to read! 😁 We then went to make a config change but saw that we were using a deprecated core rule and instead needed to [use @stylistic/eslint-plugin-js for max-len rule](#989). So, we fixed that! 💪 But then we clocked ESLint was telling us our `.eslintrc.js` [config file format is deprecated](https://eslint.org/docs/latest/use/configure/configuration-files-deprecated)! 😩 We instead should be using the `eslint.config.js` [flat file config](https://eslint.org/docs/latest/use/configure/configuration-files). So, before we start making changes to our config this change gets us using the latest supported format.
The new flat file format no longer supports `extends:`. Instead, in flat config files > predefined configs are imported from separate modules into flat config files. This means you need to `import` your config as you would any other package then specify what you've imported at the top of your config. For example this ```javascript module.exports = { extends: 'standard', // ... ``` becomes this ```javascript const standard = require('eslint-config-standard') module.exports = [ standard, { //... ```
Note - This will error when run
This change is currently blocked. Admittedly we are new to this. But from our reading to switch away from the now deprecated config file format we cannot just have ESLint call out to standard. We have to follow what the docs say about Predefined and Shareable Configs. This means we have to use eslint-config-standard. The problem is when we do we get this error.
And it appears we are not the only ones. Now the PR references ESLint v9 and we appear to be on v8. But the problem seems to be the same. There are some workarounds suggested and we can keep an eye on them. But more worrying is the last issue added; A standard that lacks maintenance is no longer a standard. No one has responded to it or closed the issue. So, we don't want to switch file formats yet because doing so forces a dependency on eslint-config-standard. And we don't want that until we see some traction on these issues. |
DEFRA/water-abstraction-team#115
In Add linting using eslint with standard as the base we switched from using standard directly for linting to using ESlint.
This is all part of the work we are doing to start codifying our conventions rather than writing them up for no one to read! 😁
We then went to make a config change but saw that we were using a deprecated core rule and instead needed to use @stylistic/eslint-plugin-js for max-len rule. So, we fixed that! 💪
But then we clocked ESLint was telling us our
.eslintrc.js
config file format is deprecated! 😩 We instead should be using theeslint.config.js
flat file config.So, before we start making changes to our config this change gets us using the latest supported format.