Skip to content
This repository has been archived by the owner on Aug 14, 2024. It is now read-only.

Add Support for typescript-eslint v8 #354

Open
3 tasks
Kenneth-Sills opened this issue Jul 31, 2024 · 9 comments · May be fixed by #356
Open
3 tasks

Add Support for typescript-eslint v8 #354

Kenneth-Sills opened this issue Jul 31, 2024 · 9 comments · May be fixed by #356

Comments

@Kenneth-Sills
Copy link

Tomorrow, the ESLint Typescript Plugin's v8 will be released via PR 9165. The changes for this are described in the prerelease blog post (though that may come to be outdated on release), and we'll need corresponding updates for our users to stay up-to-date.

This WILL be a breaking change due to updates in required rules, the API exposed by the new version (which may break siblings plugins), and the move of all formatting rules to the separate ESLint Stylistic project.

  • Migrate @typescript-eslint/no-throw-literal to @typescript-eslint/only-throw-error.
  • Remove @typescript-eslint/no-loss-of-precision (deprecated TS rule, handled correctly in base ESLint).
  • Remove or replace formatting Rules.
  • Leaving no-unused-vars unchanged should be fine. This would keep us in line with the AirBnB base config and the justification text of the standard makes no indication that caught errors are excluded.

This does NOT address #331 (supporting ESLint v9), which must still wait for upstream compatibility. Nor will it add first-class support for flat configuration.

@Kenneth-Sills
Copy link
Author

Wonderful, the release is out and includes an updated blog post! I don't immediately see additional changes needed from the list above.

@emilgoldsmith
Copy link

emilgoldsmith commented Aug 2, 2024

I get this because of the removal of stylistic rules:

TypeError: Key "rules": Key "@typescript-eslint/lines-between-class-members": Could not find "lines-between-class-members" in plugin "@typescript-eslint". Did you mean "@/lines-between-class-members"

@Kenneth-Sills
Copy link
Author

Kenneth-Sills commented Aug 2, 2024

Yup! The full list of old rules moved to the stylistic plugin can be found here.

I hope to have a PR for the maintainer this weekend, but in the interim an example MVP project setup would look something like:

Details

Warning: I slapped this together to use as a reference, just copy and pasting this probably won't work.

// package.json
{
    "dependencies": {
		"@eslint/eslintrc": "^3.1.0",
        "eslint-config-airbnb-typescript": "^18.0.0",
		"typescript-eslint": "^8.0.0"
    },
    "overrides": {
        "eslint-config-airbnb-typescript": {
            "@typescript-eslint/parser": "^8.0.0",
            "@typescript-eslint/eslint-plugin": "^8.0.0"
        }
    }
}
// eslint.config.js

import { FlatConfig } from '@eslint/eslintrc';
import typescriptPlugin from 'typescript-eslint';

const compat = new FlatCompat({
    baseDirectory: import.meta.dirname,
});

export default typescriptPlugin.config(
    ...compat.extends('airbnb-base'),
    ...compat.extends('airbnb-typescript/base'),
	...typescriptPlugin.configs.recommendedTypeChecked,
    {
        languageOptions: {
            parserOptions: {
                projectService: true,
                tsconfigRootDir: import.meta.dirname,
                allowAutomaticSingleRunInference: true,
            },
        },
    },
    // Required overrides
	{
		rules: {
		    "@typescript-eslint/lines-between-class-members": "off",
			"@typescript-eslint/no-throw-literal": "off",
			"@typescript-eslint/only-throw-error": "error",

			// Already disabled by `prettier-eslint`, if you're using that.
			"@typescript-eslint/brace-style": "off",
		    "@typescript-eslint/comma-dangle": "off",
		    "@typescript-eslint/comma-spacing": "off",
		    "@typescript-eslint/func-call-spacing": "off",
		    "@typescript-eslint/keyword-spacing": "off",
		    "@typescript-eslint/no-extra-parens": "off",
		    "@typescript-eslint/no-extra-semi": "off",
		    "@typescript-eslint/object-curly-spacing": "off",
		    "@typescript-eslint/semi": "off",
		    "@typescript-eslint/space-before-blocks": "off",
		    "@typescript-eslint/space-before-function-paren": "off",
		    "@typescript-eslint/space-infix-ops": "off",
		    "@typescript-eslint/quotes": 0,

			// Deprecated, but not breaking yet
			"@typescript-eslint/no-loss-of-precision": "off",
		},
	},
);

@DiFuks
Copy link

DiFuks commented Aug 3, 2024

@Kenneth-Sills It seems to me that the fix should not only consist of disabling removed rules. Airbnb-typescript should support migrating these rules to similar ones from eslint stylistic. In our organization's config, we have done so. But maybe I am mistaken and the maintainers have a different view on this

Kenneth-Sills added a commit to Kenneth-Sills/eslint-config-airbnb-typescript-original that referenced this issue Aug 5, 2024
Rules updates to come in isolated commits.

Closes iamturns#354.
@Kenneth-Sills Kenneth-Sills linked a pull request Aug 5, 2024 that will close this issue
@Kenneth-Sills
Copy link
Author

@DiFuks Absolutely! The config above was really to get people going in the interim, and I had yet to have a look at the @stylistic ruleset to know the migration. A PR has been submitted via #356 now, which migrates all rules appropriately and just explains how to disable them in the updated README.

Feel free to take a look and let me know if you see any issues, I always appreciate a second set of eyes!

@SteveW94
Copy link

As this currently blocks updating to typescript-eslint 8 which was released: Any news here? :)

@Kenneth-Sills
Copy link
Author

@SteveW94 The maintainer doesn't have much activity, they may be on hiatus. A bit busy this week, but if I do have some time this weekend I can take a look at forking / starting a new project.

@SteveW94
Copy link

@SteveW94 The maintainer doesn't have much activity, they may be on hiatus. A bit busy this week, but if I do have some time this weekend I can take a look at forking / starting a new project.

This would be awesome :)

@khaleelkhalifa
Copy link

@SteveW94 The maintainer doesn't have much activity, they may be on hiatus. A bit busy this week, but if I do have some time this weekend I can take a look at forking / starting a new project.

I would be interested in this too

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
5 participants