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

Fix: include loadRules in internalSlotsMap cache #19

Merged
merged 2 commits into from Dec 3, 2020

Conversation

henryqdineen
Copy link
Contributor

@henryqdineen henryqdineen commented Nov 19, 2020

This fixes a possible bug that I ran into with eslint@7.13.0. When using the rulesPath option of the ESLint() constructor it would run into this error

TypeError: loadRules is not a function

I tracked this down to the implementation of clearCache(). When createBaseConfigArray() is called it won't supply the loadRules property because it doesn't exist in the internalSlotsMap value.

const slots = internalSlotsMap.get(this);
slots.baseConfigArray = createBaseConfigArray(slots);

This causes the loadRules is not a function on this line:

loadRules(rulesPath, cwd)

Thanks!

@nzakas nzakas added accepted bug Something isn't working and removed triage labels Nov 25, 2020
@nzakas
Copy link
Member

nzakas commented Nov 25, 2020

Thanks, that definitely looks like a bug. Can you add a test to verify the fix?

@henryqdineen
Copy link
Contributor Author

I'm a little overwhelmed looking at the tests/lib/cascading-config-array-factory.js file. Do you have any advice for what kind of test I should add?

@nzakas
Copy link
Member

nzakas commented Dec 1, 2020

I think you should be able to do a fairly simple test where you create a new instance of CascadingConfigArrayFactory and pass in a rulePaths argument. I think that will trigger the error without needing to do anything else. You can just throw the test in a describe at the bottom of the file for "bug fixes".

Copy link
Member

@nzakas nzakas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks!

Copy link
Member

@mdjermanovic mdjermanovic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@nzakas nzakas merged commit 1746840 into eslint:main Dec 3, 2020
@henryqdineen henryqdineen deleted the loadRules-bug branch December 3, 2020 16:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepted bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants