-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prevent nesting plugin from breaking other plugins (#7563)
* Prevent nesting plugin from breaking other plugins This uses a private API but it’s the only solution we have right now. It’s guarded to hopefully be less breaking if the API disappears. * Update changelog
- Loading branch information
1 parent
9effea5
commit af64d71
Showing
4 changed files
with
135 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
export function visitorSpyPlugin() { | ||
let Once = jest.fn() | ||
let OnceExit = jest.fn() | ||
let Root = jest.fn() | ||
let AtRule = jest.fn() | ||
let Rule = jest.fn() | ||
let Comment = jest.fn() | ||
let Declaration = jest.fn() | ||
|
||
let plugin = Object.assign( | ||
function () { | ||
return { | ||
postcssPlugin: 'visitor-test', | ||
|
||
// These work fine | ||
Once, | ||
OnceExit, | ||
|
||
// These break | ||
Root, | ||
Rule, | ||
AtRule, | ||
Declaration, | ||
Comment, | ||
} | ||
}, | ||
{ postcss: true } | ||
) | ||
|
||
return { | ||
plugin, | ||
spies: { | ||
Once, | ||
OnceExit, | ||
Root, | ||
AtRule, | ||
Rule, | ||
Comment, | ||
Declaration, | ||
}, | ||
} | ||
} |