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

expiring-todo-comments: Fix compatibility with ESLint 9.15 #2497

Conversation

marcalexiei
Copy link
Contributor

@marcalexiei marcalexiei commented Nov 16, 2024

Close #2496.

I added the default options to expiring-todo-comments rule to avoid error when running this config with [email protected].

I also added Iterator to languageOptions.globals otherwise the recommended config test will fail.

I tested that the patch works also with [email protected] but let me know if want that I try to test multiple version of ESLint in CI workflow


Warning

I cloned and checkout main branch then I installed the dependencies using npm i.
After that I ran npm run lint I got

27 warnings
56 errors

is this expected or I have missed some step during setup?

@github-actions github-actions bot changed the title add defaultOptions to expiring-todo-comments rule Add defaultOptions to expiring-todo-comments rule Nov 16, 2024
@marcalexiei
Copy link
Contributor Author

@sindresorhus I see you opened #2498, this PR is related to that eslint change.
If you have some insight about how to fix CI it would be great (I would consider add package-lock.json to git and fix the issues in a different PR).

@ipanasenko
Copy link

Would love to see this merged, this prevents us from bumping eslint

@sindresorhus sindresorhus merged commit 16b09d3 into sindresorhus:main Nov 19, 2024
17 checks passed
@sindresorhus sindresorhus changed the title Add defaultOptions to expiring-todo-comments rule expiring-todo-comments: Fix compatibility with ESLint 9.15 Nov 19, 2024
voxpelli added a commit to voxpelli/eslint that referenced this pull request Nov 25, 2024
Seems like eslint#17656 introduced an unintended change in `no-warnings-comments.js` where before it roughly looked like:

```js
var configuration = context.options[0] || {};
var decoration = [...configuration.decoration || []].join("");
```

And afterwards it looks like:

```js
const [{ decoration, location, terms: warningTerms }] = context.options;
```

Which unintentionally(?) removes the `context.options[0] || {}` default, which eg. causes `eslint-plugin-unicorn@<15.0.1` to fail (see sindresorhus/eslint-plugin-unicorn#2497)

Since this happened in a minor `eslint` release but the fix for `eslint-plugin-unicorn` is only available as a patch to its latest major, this is causing me some issues.

My guess is that you won't be wanting to merge this though as `eslint-plugin-unicorn` is [extending that rule](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/8b7c5fcf5c9743db4afde0bb9c90cc51782d47ef/rules/utils/get-builtin-rule.js#L4) through:

```js
require('eslint/use-at-your-own-risk').builtinRules.get('no-warning-comments')
```

And as discussed in eslint#19013 you don't consider that a good practise:

> It's in unstable APIs because rule APIs are indeed not stable

> Core rules are not intended to extended any you do so at your own risk

Perhaps eslint#19013 or similar can suggest an alternative for eg. `eslint-plugin-unicorn` to avoid this happening again in the future, but my guess is you consider such suggestions to be out of scope of `eslint` and as such to not be something you ant to get involved in.

Here's a PR fixing the regression at least, you decide if you want to accept it or reject it 🤷‍♂️
@voxpelli
Copy link
Contributor

Added a PR to fix this in upstream as well: eslint/eslint#19166 To avoid failures for those using unicorn <15.x

I guess backporting of this PR to 14.x is not something that you would be interested in?

@voxpelli
Copy link
Contributor

That issue was closed referencing eslint/eslint#19169 that will document that extension of built in rules are discouraged, they should be forked instead.

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

Successfully merging this pull request may close these issues.

expiring-todo-comments Broken in ESlint 9.15.0
5 participants