Skip to content
This repository was archived by the owner on Mar 23, 2024. It is now read-only.

Commit 90d38c9

Browse files
SimenBhzoo
authored andcommitted
Fix: requireDollarBeforejQueryAssignment - Ignore array destructuring
Fixes #1860 Closes gh-1861
1 parent c6a87c1 commit 90d38c9

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

lib/rules/require-dollar-before-jquery-assignment.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ module.exports.prototype = {
7676
var right;
7777

7878
if (type === 'VariableDeclarator') {
79-
if (token.id.type === 'ObjectPattern') {
79+
if (token.id.type === 'ObjectPattern' || token.id.type === 'ArrayPattern') {
8080
return;
8181
}
8282

test/specs/rules/require-dollar-before-jquery-assignment.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,10 @@ describe('rules/require-dollar-before-jquery-assignment', function() {
121121
expect(checker.checkString('const {beep, boop} = meep;\nvar $s = $("#id")')).to.have.no.errors();
122122
});
123123

124+
it('should not report on array destructuring', function() {
125+
expect(checker.checkString('const [beep, boop] = meep;\nvar $s = $("#id")')).to.have.no.errors();
126+
});
127+
124128
it('should report with assignment on right hand side of object destructuring', function() {
125129
expect(checker.checkString('var {foo} = {foo: $(".foo")}'))
126130
.to.have.one.validation.error.from('requireDollarBeforejQueryAssignment');

0 commit comments

Comments
 (0)