cartant / eslint-plugin-rxjs-angular

ESLint rules for RxJS and Angular
MIT License
96 stars 11 forks source link

ESLint v9 support #23

Open json-derulo opened 5 months ago

json-derulo commented 5 months ago

ESLint v9 has been released recently. This plugin has a peer dependency to ESLint ^8.0.0 and causes peer dependency conflicts with ESLint v9.

e-oz commented 2 months ago

Also, this plugin doesn't send context information correctly to ESLint 9, causing "parserOptions.project" to be empty.

schreibse commented 2 months ago

@cartant: do you have a plan how you wish to proceed with all the recent changes? (flat config, takeuntildestroyed, ...). Since not too much happened here for quite some time, might it be an option to integrate and update the three rules in https://github.com/angular-eslint/angular-eslint ? I am just thinking out loud and I have no idea what JamesHenry would say to that

json-derulo commented 1 month ago

I got the plugin working in ESLint v9 with the help of the @eslint/compat package:

import { fixupPluginRules } from '@eslint/compat';
import rxjsAngular from 'eslint-plugin-rxjs-angular';

export default tseslint.config(
  {
    files: ['**/*.ts'],
    plugins: {
      'rxjs-angular': fixupPluginRules(rxjsAngular),
    },
  },
);

Additionally I needed to add a npm override to silence the peer dependency error.

e-oz commented 1 month ago

Didn't work for me :( And now here is ESLint 10 ;)

oBusk commented 1 month ago

Seems like the "correct" approach would be to use fixupConfigRules(). This worked for us;


const eslint = require('@eslint/js');
const tseslint = require('typescript-eslint');
const eslintrc = require('@eslint/eslintrc');
const { fixupConfigRules } = require('@eslint/compat');

const compat = new eslintrc.FlatCompat({
    baseDirectory: __dirname,
});

module.exports = [
    {
        files: ['**/*.ts'],
        languageOptions: {
            parserOptions: {
                project: true,
                tsconfigRootDir: __dirname,
            },
        },
        extends: [
            eslint.configs.recommended,
            ...tseslint.configs.recommendedTypeChecked,
            ...fixupConfigRules(compat.extends('plugin:rxjs/recommended')),
        ],
        rules: {
            // `eslint-plugin-rxjs` overrides
            'rxjs/no-implicit-any-catch': 0,
            'rxjs/no-subject-value': 'error',
        },
    }
]
e-oz commented 1 month ago

I don't understand how you can call "patching" a correct approach. It's just a temporary patch.

oBusk commented 1 month ago

I don't understand how you can call "patching" a correct approach. It's just a temporary patch.

To make it work right now of course, not as a permantent solution