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

Stop using private ESLint APIs for ESLint config merging #1464

Merged
merged 1 commit into from
Sep 9, 2019
Merged

Stop using private ESLint APIs for ESLint config merging #1464

merged 1 commit into from
Sep 9, 2019

Conversation

edmorley
Copy link
Member

@edmorley edmorley commented Sep 9, 2019

In #1182, the previous broken ESLint config merging functionality was replaced by using an internal ESLint merge function from config-ops.

Unfortunately in ESLint 6 that function no longer exists in a form that is easy for us to use, so in order to support ESLint 6, I have replaced it with simpler manual merges. These are virtually identical, with one difference - rules are now merged by a later rule entry completely replacing the first, rather than updating it.

For example, merging these:
'foo': ['error', {'someSetting': false}]
'foo': 'warn'

...used to give:
'foo': ['warn', {'someSetting': false}]

...but now results in:
'foo': 'warn'

I think this difference is a reasonable compromise for not having to rely on ESLint internals and/or implement our own more complex merging. I also believe hitting this will be rare, since:

  • it doesn't affect merging with rules defined inside an extends external file
  • it won't make a difference for rules that were already at default settings (or that were overridden with custom settings in the later rule definition being merged in)

This more simplistic merging behaviour is also what's used by Neutrino 8 (#1182 landed for Neutrino 9 only) - and we still have the other bug fixes included in #1182 that were the primary motivation for refactoring in the first place.

Refs #1423.

In #1182, the previous broken ESLint config merging functionality was
replaced by using an internal ESLint `merge` function from `config-ops`.

Unfortunately in ESLint 6 that function no longer exists in a form that
is easy for us to use, so in order to support ESLint 6, I have replaced
it with simpler manual merges. These are virtually identical, with one
difference - `rules` are now merged by a later rule entry completely
replacing the first, rather than updating it.

For example, merging these:
`'foo': ['error', {'someSetting': false}]`
`'foo': 'warn'`

...used to give:
`'foo': ['warn', {'someSetting': false}]`

...but now results in:
`'foo': 'warn'`

I think this difference is a reasonable compromise for not having to
rely on ESLint internals and/or implement our own more complex merging.
I also believe hitting this will be rare, since:
* it doesn't affect merging with rules defined inside an `extends`
  external file
* it won't make a difference for rules that were already at default
  settings (or that were overridden with custom settings in the later
  rule definition being merged in)

This more simplistic merging behaviour is also what's used by Neutrino 8
(#1182 landed for Neutrino 9 only) - and we still have the other bug
fixes included in #1182 that were the primary motivation for refactoring
in the first place.

Refs #1423.
@edmorley edmorley added this to the Neutrino 9 milestone Sep 9, 2019
@edmorley edmorley self-assigned this Sep 9, 2019
@edmorley edmorley requested a review from a team September 9, 2019 12:10
@edclement
Copy link

Took a quick peak. Looks good to me...

@edmorley edmorley merged commit 79d4eda into neutrinojs:master Sep 9, 2019
@edmorley edmorley deleted the edmorley-simplify-eslint-merge branch September 9, 2019 15:12
@edmorley
Copy link
Member Author

edmorley commented Sep 9, 2019

Thank you for the reviews :-)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

Successfully merging this pull request may close these issues.

None yet

3 participants