Problem/Motivation

We are using several eslint plugins to support our eslint config:

eslint-config-airbnb
eslint-config-prettier
eslint-plugin-import
eslint-plugin-jquery
eslint-plugin-jsx-a11y
eslint-plugin-prettier
eslint-plugin-react
eslint-plugin-react-hooks

Several of them are a dependency of the airbnb config, we should try to simplify our config so that we don't bring in unnecessary react-related packages, and possibly not depend on the airbnb config.

Proposed resolution

Use eslint-config-airbnb-base which is essentially same as eslint-config-airbnb without React specific plugins and rules.

Remaining tasks

Make the diff between the current config and eslint:recommended
Agree on what is important/what is not, what to keep/remove
update the config (with minimal changes to existing code hopefully)

Release notes snippet

JavaScript linting now uses eslint-config-airbnb-base instead of eslint-config-airbnb for linting core JavaScript. Anyone who uses core's ESLint config to lint React or JSX code should add eslint-config-airbnb back to their yarn dev dependencies.

Comments

nod_ created an issue. See original summary.

nod_’s picture

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

longwave’s picture

StatusFileSize
new60.91 KB

This command prints the full config:

$ node ./node_modules/eslint/bin/eslint.js --config=.eslintrc.passing.json --print-config

The attached diff shows the config difference between the existing airbnb config and the config with eslint:recommended instead.

We don't need any of the react or jsx rules but I don't know what a lot of the "no-X" rules are, and there are quite a lot of differences there.

longwave’s picture

Title: Update core eslint configuration » Update core eslint configuration to remove unused React and JSX rules
Status: Active » Needs review
StatusFileSize
new21.2 KB
new18.22 KB

Just discovered the existence of https://www.npmjs.com/package/eslint-config-airbnb-base which removes the React and JSX dependencies, but keeps all the other rules. .diff file attached here is an ESLint config diff.

nod_’s picture

Very nice, thanks for tracking this down :)

nod_’s picture

Status: Needs review » Reviewed & tested by the community

no regressions I can see on my end, RTBC

lauriii’s picture

Issue summary: View changes

Updated proposed resolution to the issue summary. I'm debating with myself if we need a CR for this 🤔 This would only impact folks who are using React and running our eslint against it (which I guess could be some people). Maybe that's worth mentioning in a CR? I think it's fine that we don't provide that capability. I think we could recommend people doing that to just directly depend on eslint-config-airbnb.

nod_’s picture

I wouldn't bother, if they use react they probably don't use our toolset anyway. We do provide lint to contrib through drupalci but everyone doing react is on github.

xjm’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs release note

No CR is OK here. It does need a small release note, though, as a coding standards update.

spokje’s picture

StatusFileSize
new21.2 KB
new6.82 KB

Reroll of patch #5

spokje’s picture

StatusFileSize
new7.43 KB
new21.2 KB

Right, 9.4.x-dev, not 10.0.x-dev...

longwave’s picture

Issue summary: View changes
Status: Needs work » Reviewed & tested by the community

Reroll looks good to me, added a release note snippet.

xjm’s picture

I think we'd also need a 10.0.x version of the patch?

xjm’s picture

Status: Reviewed & tested by the community » Needs review
Issue tags: -Needs release note
spokje’s picture

I think we'd also need a 10.0.x version of the patch?

Patch in #11 was/is against 10.0.x-dev

xjm’s picture

Status: Needs review » Reviewed & tested by the community

Ah sorry, got confused by the comments and test results. Restoring the status in the hope that it passes. :)

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 12: 3239838-12.patch, failed testing. View results

nod_’s picture

Status: Needs work » Reviewed & tested by the community

DB issue in the test so…

spokje’s picture

Thanks @nod_, saw the failure, triggered a retest, but you've beat me to putting it back on RTBC after the retest passed :)

  • lauriii committed 3e09146 on 10.0.x
    Issue #3239838 by longwave, Spokje, nod_, xjm: Update core eslint...
lauriii’s picture

Status: Reviewed & tested by the community » Fixed

Committed 3e09146 and pushed to 10.0.x. Also committed the 9.4.x. Thanks!

  • lauriii committed 3f738a9 on 9.4.x
    Issue #3239838 by longwave, Spokje, nod_, xjm: Update core eslint...
xjm’s picture

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.