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

Switch to new eslint config format #991

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Commits on May 8, 2024

  1. Switch from .eslintrc.js to eslint.config.js

    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.
    Cruikshanks committed May 8, 2024
    Configuration menu
    Copy the full SHA
    244a983 View commit details
    Browse the repository at this point in the history
  2. Rename the config file

    Cruikshanks committed May 8, 2024
    Configuration menu
    Copy the full SHA
    9c42540 View commit details
    Browse the repository at this point in the history
  3. Replace standard with eslint-config-standard

    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,
      {
        //...
    ```
    Cruikshanks committed May 8, 2024
    Configuration menu
    Copy the full SHA
    0909f3f View commit details
    Browse the repository at this point in the history
  4. Update config to match flat file format

    Note - This will error when run
    Cruikshanks committed May 8, 2024
    Configuration menu
    Copy the full SHA
    b23986e View commit details
    Browse the repository at this point in the history