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

@mdjermanovic mdjermanovic commented Dec 4, 2019

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?

Copy link
Member

@kaicataldo kaicataldo left a comment

LGTM, thanks. Agreed that this should be a semver-patch bug fix.

Copy link
Member

@btmills btmills left a comment

LGTM. Agreed this can be semver-minor.

@btmills btmills merged commit a258039 into master Dec 20, 2019
18 checks passed
18 checks passed
@github-actions
Verify Files
Details
@github-actions
Test (ubuntu-latest, 13.x)
Details
@github-actions
Test (ubuntu-latest, 12.x)
Details
@github-actions
Test (ubuntu-latest, 10.x)
Details
@github-actions
Test (ubuntu-latest, 8.x)
Details
@github-actions
Test (ubuntu-latest, 8.10.0)
Details
@github-actions
Test (windows-latest, 12.x)
Details
@github-actions
Test (macOS-latest, 12.x)
Details
@github-actions
Browser Test
Details
@eslint-deprecated
commit-message Commit message follows guidelines
Details
@azure-pipelines
continuous-integration Build #20191204.2 succeeded
Details
@azure-pipelines
continuous-integration (Test on Node.js 10 (Linux)) Test on Node.js 10 (Linux) succeeded
Details
@azure-pipelines
continuous-integration (Test on Node.js 12 (Linux)) Test on Node.js 12 (Linux) succeeded
Details
@azure-pipelines
continuous-integration (Test on Node.js 12 (Windows)) Test on Node.js 12 (Windows) succeeded
Details
@azure-pipelines
continuous-integration (Test on Node.js 12 (macOS)) Test on Node.js 12 (macOS) succeeded
Details
@azure-pipelines
continuous-integration (Test on Node.js 8 (Linux)) Test on Node.js 8 (Linux) succeeded
Details
licence/cla Contributor License Agreement is signed.
Details
@eslint-deprecated
release-monitor No patch release is pending
Details
@btmills btmills deleted the norestrictedimports-schema-multiple branch Dec 20, 2019
@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Jun 19, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants