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 9] Make rules export object with a create method #367

Merged
merged 1 commit into from
Jun 13, 2024

Conversation

ej612
Copy link
Contributor

@ej612 ej612 commented Jun 10, 2024

Description

After upgrading to eslint 9, I get the following error:

Oops! Something went wrong! :(

ESLint: 9.4.0

TypeError: Error while loading rule 'jasmine/no-suite-callback-args': Rule must be an object with a `create` method

This is because some rules directly export create as an anonymous function, which doesn't seem to be tolerated by eslint 9. The solution is to export an object and provide the function under a create property.

How has this been tested?

Manually, with an installation of eslint 9.

Types of changes

  • Test change (non-breaking change which adds additional test scenarios)
  • Refactor change (non-breaking change updates coding styles)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • I have ran npm run test and everything passes
  • My code follows the code style of this project
  • I have updated the documentation where necessary
  • I have read the CONTRIBUTING document
  • I have added tests to cover my changes
  • All new and existing tests pass

In rules that export the `create` function directly, wrap it in an object. This is the syntax expected by eslint 9.
@tlvince
Copy link
Owner

tlvince commented Jun 12, 2024

Hi @ej612, was this fixed in #366? Could you test https://github.com/tlvince/eslint-plugin-jasmine/releases/tag/v4.1.4-beta.1? Thanks

@ej612
Copy link
Contributor Author

ej612 commented Jun 12, 2024

Hi @tlvince, thanks for your response! #366 fixed it for the rules it touched, but those were only the ones with config options. The others still throw errors in v4.1.4-beta.1 and will be fixed by this PR.

@tlvince
Copy link
Owner

tlvince commented Jun 13, 2024

Thanks. I've cherry picked #367 and #368 into v4.1.4-beta.2 if you don't mind giving it a quick test. Also, I assume by the function signature change, this is a breaking change and requires eslint>=9?

@ej612
Copy link
Contributor Author

ej612 commented Jun 13, 2024

I just tested with eslint 8 and can confirm that 4.1.4-beta.2 works fine.

Also, I assume by the function signature change, this is a breaking change and requires eslint>=9?

Good news: It's not a breaking change, exporting an object with a create function is accepted syntax in eslint 8.

Unrelated, but I've gotten the following error:

npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE   package: 'eslint-plugin-jasmine@4.1.4-beta.2',
npm WARN EBADENGINE   required: { npm: '>=10', node: '>=20' },
npm WARN EBADENGINE   current: { node: 'v18.18.2', npm: '9.8.1' }
npm WARN EBADENGINE }

Is it necessary to raise the bar to node 20? Our organisation is still currently stuck on node 18, which is still accepted by eslint 9:

  "engines": {
    "node": "^18.18.0 || ^20.9.0 || >=21.1.0"
  }

@tlvince
Copy link
Owner

tlvince commented Jun 13, 2024

Thanks for the confirmation!

I'll revert the node 20 bump; this is required for semantic-release, but can be done within CI.

@tlvince tlvince merged commit 3ce1766 into tlvince:master Jun 13, 2024
2 checks passed
Copy link

🎉 This PR is included in version 4.2.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@ej612 ej612 deleted the rule_object_create branch June 13, 2024 18:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants