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

eslint v9 support #2961

Open
7 of 14 tasks
Tracked by #118
ljharb opened this issue Apr 6, 2024 · 26 comments
Open
7 of 14 tasks
Tracked by #118

eslint v9 support #2961

ljharb opened this issue Apr 6, 2024 · 26 comments

Comments

@ljharb
Copy link
Collaborator

ljharb commented Apr 6, 2024

(see also #2478, #2223, #2036, #1834, #1447)

eslint v9 was released on 2024.04.05.

The current plan is, if possible, to release a new semver-minor of both configs, that supports 7 || 8 || 9.

Note that this is different from whether flat config is supported or not by these plugins, and from whether this project will convert to flat config.

The timeframe for eslint v9 support is "not as soon as you would like, but as soon as we can".
Please accept this, and please add no noise to this thread beyond emoji reactions - distractions won't help anyone get the work done any faster.

Please do not file additional issues and do not file pull requests attempting to add support - please, instead, continue to use eslint v8 until such time as our configs support v9.

Peer Dep eslint combined v7, v8, and v9 support released:

@ljharb ljharb pinned this issue Apr 8, 2024
tripodsan added a commit to adobe/helix-shared that referenced this issue Apr 9, 2024
tripodsan added a commit to adobe/helix-shared that referenced this issue Apr 9, 2024
nickjj added a commit to nickjj/docker-node-example that referenced this issue Apr 16, 2024
Certain extensions aren't compatible yet with 9.X such as:

  airbnb/javascript#2961
notfrancois added a commit to ct-desarrollo/eslint-config that referenced this issue Oct 30, 2024
since eslint v9 is released, there are some packages like eslint-config-airbnb that is a boilerplate setup community contribution that doesn't support eslint v9 yet.
follow more on airbnb/javascript#2961
@pierluigilenoci

This comment was marked as spam.

@ljharb

This comment was marked as off-topic.

@rarenatoe

This comment was marked as off-topic.

@ljharb

This comment was marked as off-topic.

@pierluigilenoci

This comment was marked as off-topic.

@ljharb

This comment was marked as resolved.

kris7t added a commit to graphs4value/refinery that referenced this issue Nov 23, 2024
* Remove Airbnb ESLint config, as it doesn't support ESLint 9. Consider adding
  it back once airbnb/javascript#2961 is resolved.
* We're still using the legacy config format, since
  facebook/react#30774 is not merged yet.
* Fix some lint errors output by the new ESLint config.
* The TypeScript version is bumped to 5.6.3, which is the latest supported by
  typescript-eslint.
kris7t added a commit to graphs4value/refinery that referenced this issue Nov 23, 2024
* Remove Airbnb ESLint config, as it doesn't support ESLint 9. Consider adding
  it back once airbnb/javascript#2961 is resolved.
* We're still using the legacy config format, since
  facebook/react#30774 is not merged yet.
* Fix some lint errors output by the new ESLint config.
* The TypeScript version is bumped to 5.6.3, which is the latest supported by
  typescript-eslint.
@dgtllion
Copy link

I see it will take a bit longer than I expected. Has anyone a workaround while its in progress?

@ljharb
Copy link
Collaborator Author

ljharb commented Nov 25, 2024

@dgtllion this is still within the expected timeframe. The workaround is "stick with eslint 8 for now".

@dgtllion
Copy link

@dgtllion this is still within the expected timeframe. The workaround is "stick with eslint 8 for now".

My goal is to move to eslint v9. I think your advice is more to stayaround instead of workaround.
May be anyone has another workaround like patching, use another config package or something else (while its in progress)?

@xfournet
Copy link

@dgtllion here is an excerpt of what I use to make airbnb works in ESLint 9 : https://gist.github.com/xfournet/ed9f2f02e411b86188bad4aeb9b1bddb

@controversial
Copy link

controversial commented Nov 25, 2024

Here’s the workaround I’m using for eslint-config-airbnb on eslint 9, including:

  • automatically migrating legacy config to flat config using FlatCompat
  • automatically replacing deprecated rules that should be moved to @stylistic/eslint
  • (optional) within typescript files, automatically using the @typescript-eslint version of any rules that are available under typescript-eslint
import { FlatCompat } from '@eslint/eslintrc';
import js from '@eslint/js';

import tseslint from 'typescript-eslint';
import stylisticPlugin from '@stylistic/eslint-plugin';


// Load airbnb config as FlatConfig
const compat = new FlatCompat({
  baseDirectory: import.meta.dirname,
  recommendedConfig: js.configs.recommended,
  allConfig: js.configs.all,
});
const airbnbFlat = compat.extends('eslint-config-airbnb');
// Extract list of rules
const baseRuleEntries = airbnbFlat.flatMap((cfg) => (cfg.rules ? Object.entries(cfg.rules) : []));


// 1. Replace deprecated stylistic rules with rules from stylistic plugin
const ruleEntriesWithStylisticVersion = baseRuleEntries
  .map(([rule, setting]) => [rule.split('/').at(-1), setting])
  .filter(([rule]) => rule in stylisticPlugin.rules);
const stylisticPatchedRules = {
  ...Object.fromEntries(baseRuleEntries),
  ...stylisticPlugin.configs['disable-legacy'].rules,
  ...Object.fromEntries(ruleEntriesWithStylisticVersion.map(([rule, setting]) => [`@stylistic/${rule}`, setting])),
};

// 2. For typescript config, replace rules that have a typescript-eslint version
const ruleEntriesWithTsEslintVersion = baseRuleEntries
  .filter(([rule]) => rule in (tseslint.plugin.rules ?? {}));
const typescriptPatchedRules = Object.fromEntries([
  ...ruleEntriesWithTsEslintVersion.map(([rule]) => [rule, 'off']),
  ...ruleEntriesWithTsEslintVersion.map(([rule, setting]) => [`@typescript-eslint/${rule}`, setting]),
]);

export default [
  // Base rules - patched to use stylistic plugin
  {
    plugins: { '@stylistic': stylisticPlugin },
    rules: stylisticPatchedRules,
  },

  // Within typescript files, use the @typescript-eslint version of any rule we can
  {
    files:['**/*.ts', '**/*.tsx', '**/*.d.ts'],
    rules: typescriptPatchedRules,
  },
];

@ljharb
Copy link
Collaborator Author

ljharb commented Nov 25, 2024

@dgtllion you can't move to eslint 9 yet while using the airbnb config in a supported fashion. You can choose to be unsupported (using the workaround above, for example), or choose to wait on eslint 8 (which is perfectly reasonable and won't obstruct anything meaningful), or choose to stop using the airbnb config.

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