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: no-restricted-imports schema allows multiple paths/patterns objects #12639

Merged
merged 1 commit into from Dec 20, 2019

Conversation

mdjermanovic
Copy link
Member

What is the purpose of this pull request? (put an "X" next to item)

[X] Bug fix
[X] Other, please explain:

At the moment, no-restricted-imports schema allows multiple objects with paths/patterns keys:

/* eslint "no-restricted-imports": ["error", {
    "paths": ["foo"]
}, {
    "paths": ["bar"]
}] */

import a from "bar"; // no errors

Online Demo Link

This shouldn't be allowed because it isn't documented and it doesn't work as the user might expect. paths and patterns are being read only from the first object (at index 0), others are ignored.

What changes did you make? (Give an overview)

Fixed the schema to allow only 1 object with this form.

Also added a test to ensure that a configuration without any specified restricted imports is still allowed.

Is there anything you'd like reviewers to focus on?

This isn't related to #12638.

Marked as fix rather than chore because this change might break a build with an invalid configuration, which anyway didn't work as the user was expecting. Also, looks more like a fix than an update?

@mdjermanovic mdjermanovic added bug ESLint is working incorrectly rule Relates to ESLint's core rules evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion labels Dec 4, 2019
Copy link
Member

@kaicataldo kaicataldo 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. Agreed that this should be a semver-patch bug fix.

@kaicataldo kaicataldo added accepted There is consensus among the team that this change meets the criteria for inclusion and removed evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion labels Dec 4, 2019
Copy link
Member

@btmills btmills left a comment

Choose a reason for hiding this comment

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

LGTM. Agreed this can be semver-minor.

@btmills btmills merged commit a258039 into master Dec 20, 2019
@btmills btmills deleted the norestrictedimports-schema-multiple branch December 20, 2019 20:18
@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Jun 19, 2020
@eslint-deprecated eslint-deprecated bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Jun 19, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion bug ESLint is working incorrectly rule Relates to ESLint's core rules
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants