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

ioBroker.eslint-config migration #580

Closed
10 tasks done
hombach opened this issue Nov 29, 2024 · 2 comments
Closed
10 tasks done

ioBroker.eslint-config migration #580

hombach opened this issue Nov 29, 2024 · 2 comments
Assignees

Comments

@hombach
Copy link
Owner

hombach commented Nov 29, 2024

ESLint Migrations Guide

Migration from ESLint 8.x.x to 9.x.x

The following steps are recommended when migrating from an existing ESLint 8.x.x configuration using .eslint.rc configuration file to an ESLint 9.x.x setup using @iobroker/eslint-config.
The steps are valid for vanilla Javascript and TypeScript repositories. If you are using ESM modules or React the ESLint configuration needs to include some more modules. Please see README.md for details.

  • Clone your repository to a local workspace

  • Verify that current (old) ESLint configuration is working

    Execute npm run lint and check for errors. Consider fixing all existing errors before starting the migration.

  • remove packages no longer needed

    npm uninstall eslint
    npm uninstall eslint-config-prettier
    npm uninstall eslint-plugin-prettier
    npm uninstall prettier
    
  • install iobroker standard rules

    npm i @iobroker/eslint-config --save-dev
    
  • remove old configuration files

    .eslintignore
    .eslintrc.json
    .prettierignore
    .prettierrc.js
    
  • create new configuration file eslint.config.mjs for ESLint in the root directory of the repository

    // ioBroker eslint template configuration file for js and ts files
    // Please note that esm or react based modules need additional modules loaded.
    import config from '@iobroker/eslint-config';
    
    export default [
        ...config,
    
        {
            // specify files to exclude from linting here
            ignores: [
                '.dev-server/',
                '.vscode/',
                '*.test.js', 
                'test/**/*.js', 
                '*.config.mjs', 
                'build', 
                'admin/build', 
                'admin/words.js',
                'admin/admin.d.ts',
                '**/adapter-config.d.ts'     
            ] 
        },
    
        {
            // you may disable some 'jsdoc' warnings - but using jsdoc is highly recommended
            // as this improves maintainability. jsdoc warnings will not block buiuld process.
            rules: {
                // 'jsdoc/require-jsdoc': 'off',
            },
        },
        
    ];
  • create new configuration file 'prettier.config.mjs' for Prettier in the root directory of the repository

    // iobroker prettier configuration file
    import prettierConfig from '@iobroker/eslint-config/prettier.config.mjs';
    
    export default {
        ...prettierConfig,
        // uncomment next line if you prefer double quotes
        // singleQuote: false,
    }
  • check and eventually adapt script definition at package.json

    Your 'lint' script definition at package.json should read like this

    {
        "scripts": {
            "lint": "eslint -c eslint.config.mjs ."
        }
    }
  • update .npmignore (if still in use)

    If you still use .npmignore and not yet switched to use files section within package.json, add the following files to .npmignore

    eslint.config.mjs
    prettier.config.mjs
    
  • check functionality by executing

    npm run lint
    

    Please note that the execution of ESLint 9 checks will last longer than previous executions. You might get errors and warnings due to new rules.
    Feel free to try npm run lint -- --fix to perform automatic fixes.

@hombach hombach self-assigned this Nov 29, 2024
@hombach
Copy link
Owner Author

hombach commented Dec 12, 2024

implemented in 0.12.5

@hombach
Copy link
Owner Author

hombach commented Dec 12, 2024

0.12.5 released

@hombach hombach closed this as completed Dec 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant