Allow break require() argument (#15256)
This commit is contained in:
1 parent
dc3ebe812f
commit
f75f717c4e
4 files changed
+61
-1
No files matched your search
@@ -0,0 +1,23 @@
|
||||
#### Allow argument of `require()` to break (#15256 by @fisker)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```jsx
|
||||
// Input
|
||||
const plugin = require(
|
||||
global.STANDALONE
|
||||
? path.join(__dirname, "../standalone.js")
|
||||
: path.join(__dirname, "..")
|
||||
);
|
||||
|
||||
// Prettier stable
|
||||
const plugin = require(global.STANDALONE
|
||||
? path.join(__dirname, "../standalone.js")
|
||||
: path.join(__dirname, ".."));
|
||||
|
||||
// Prettier main
|
||||
const plugin = require(
|
||||
global.STANDALONE
|
||||
? path.join(__dirname, "../standalone.js")
|
||||
: path.join(__dirname, "..")
|
||||
);
|
||||
```
|
||||
@@ -89,7 +89,8 @@ function isCommonsJsOrAmdCall(node, parentNode) {
|
||||
}
|
||||
|
||||
if (node.callee.name === "require") {
|
||||
return true;
|
||||
const args = getCallArguments(node);
|
||||
return (args.length === 1 && isStringLiteral(args[0])) || args.length > 1;
|
||||
}
|
||||
|
||||
if (node.callee.name === "define") {
|
||||
|
||||
@@ -11,6 +11,19 @@ const { one1, two1, three1, four1, five1, six1, seven1, eight1, nine1, ten1, ele
|
||||
|
||||
const MyReallyExtrememlyLongModuleName = require('MyReallyExtrememlyLongModuleName');
|
||||
|
||||
const plugin = require(
|
||||
global.STANDALONE
|
||||
? path.join(__dirname, "../standalone.js")
|
||||
: path.join(__dirname, "..")
|
||||
);
|
||||
|
||||
const plugin2 = require(
|
||||
path.join(
|
||||
__dirname,
|
||||
global.STANDALONE ? "../standalone.js" : '..'
|
||||
)
|
||||
);
|
||||
|
||||
=====================================output=====================================
|
||||
const {
|
||||
one,
|
||||
@@ -40,5 +53,15 @@ const {
|
||||
|
||||
const MyReallyExtrememlyLongModuleName = require("MyReallyExtrememlyLongModuleName");
|
||||
|
||||
const plugin = require(
|
||||
global.STANDALONE
|
||||
? path.join(__dirname, "../standalone.js")
|
||||
: path.join(__dirname, ".."),
|
||||
);
|
||||
|
||||
const plugin2 = require(
|
||||
path.join(__dirname, global.STANDALONE ? "../standalone.js" : ".."),
|
||||
);
|
||||
|
||||
================================================================================
|
||||
`;
|
||||
@@ -2,3 +2,16 @@ const { one, two, three, four, five, six, seven, eight, nine, ten } = require('.
|
||||
const { one1, two1, three1, four1, five1, six1, seven1, eight1, nine1, ten1, eleven1 } = require('./my-utils');
|
||||
|
||||
const MyReallyExtrememlyLongModuleName = require('MyReallyExtrememlyLongModuleName');
|
||||
|
||||
const plugin = require(
|
||||
global.STANDALONE
|
||||
? path.join(__dirname, "../standalone.js")
|
||||
: path.join(__dirname, "..")
|
||||
);
|
||||
|
||||
const plugin2 = require(
|
||||
path.join(
|
||||
__dirname,
|
||||
global.STANDALONE ? "../standalone.js" : '..'
|
||||
)
|
||||
);
|
||||
Reference in new issue
Block a user