Skip to content

Commit 16cc066

Browse files
authored
chore: upgrade dependencies (#2321)
* chore: upgrade dependencies * chore: replace memoize dependency with own implementation
1 parent ea27073 commit 16cc066

File tree

6 files changed

+192
-199
lines changed

6 files changed

+192
-199
lines changed

package.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
],
2222
"dependencies": {
2323
"linguist-languages": "^7.27.0",
24-
"mem": "^9.0.2",
2524
"php-parser": "^3.1.5"
2625
},
2726
"devDependencies": {
@@ -34,13 +33,13 @@
3433
"@rollup/plugin-node-resolve": "^15.2.1",
3534
"@rollup/plugin-replace": "^5.0.5",
3635
"@rollup/plugin-terser": "^0.4.3",
37-
"c8": "^8.0.1",
36+
"c8": "^9.1.0",
3837
"cross-env": "^7.0.2",
3938
"eslint": "8.56.0",
4039
"eslint-config-prettier": "9.1.0",
4140
"eslint-plugin-import": "2.29.1",
42-
"eslint-plugin-jest": "27.6.0",
43-
"eslint-plugin-prettier": "5.0.1",
41+
"eslint-plugin-jest": "27.6.3",
42+
"eslint-plugin-prettier": "5.1.3",
4443
"eslint-plugin-prettier-doc": "^1.1.0",
4544
"jest": "29.7.0",
4645
"jest-environment-jsdom": "29.7.0",

src/pragma.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import memoize from "mem";
1+
import { memoize } from "./util.mjs";
22
import parse from "./parser.mjs";
33

44
const reHasPragma = /@prettier|@format/;

src/printer.mjs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1018,8 +1018,8 @@ function printLines(path, options, print, childrenAttribute = "children") {
10181018
"?>",
10191019
]
10201020
: isProgramLikeNode(node) && isFirstNode && node.kind !== "namespace"
1021-
? ""
1022-
: [beforeCloseTagInlineNode, "?>"];
1021+
? ""
1022+
: [beforeCloseTagInlineNode, "?>"];
10231023

10241024
//FIXME getNode is used to get ancestors, but it seems this means to get next sibling?
10251025
const nextV = path.getNode(index + 1);
@@ -1034,8 +1034,8 @@ function printLines(path, options, print, childrenAttribute = "children") {
10341034
hardline,
10351035
]
10361036
: isProgramLikeNode(node) && isLastNode
1037-
? ""
1038-
: [openTag, " "];
1037+
? ""
1038+
: [openTag, " "];
10391039

10401040
printed = [beforeInline, printed, afterInline];
10411041
}
@@ -1091,8 +1091,8 @@ function printLines(path, options, print, childrenAttribute = "children") {
10911091
: "",
10921092
]
10931093
: node.comments
1094-
? hardline
1095-
: "";
1094+
? hardline
1095+
: "";
10961096

10971097
parts.push(lineSuffix([beforeCloseTag, "?>"]));
10981098
}
@@ -1711,8 +1711,8 @@ function printNode(path, options, print) {
17111711
hardline,
17121712
]
17131713
: hasDanglingComments(node)
1714-
? [line, printDanglingComments(path, options, true), line]
1715-
: "",
1714+
? [line, printDanglingComments(path, options, true), line]
1715+
: "",
17161716
"}",
17171717
]
17181718
: "",

src/util.mjs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -685,6 +685,16 @@ function isSimpleCallArgument(node, depth = 2) {
685685
return false;
686686
}
687687

688+
function memoize(fn) {
689+
const cache = new Map();
690+
return (key) => {
691+
if (!cache.has(key)) {
692+
cache.set(key, fn(key));
693+
}
694+
return cache.get(key);
695+
};
696+
}
697+
688698
export {
689699
printNumber,
690700
getPrecedence,
@@ -715,4 +725,5 @@ export {
715725
getAncestorNode,
716726
normalizeMagicMethodName,
717727
isSimpleCallArgument,
728+
memoize,
718729
};

tests_config/run_spec.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,8 @@ function printOptions(options) {
205205
return value === Infinity
206206
? "Infinity"
207207
: Array.isArray(value)
208-
? `[${value.map((v) => JSON.stringify(v)).join(", ")}]`
209-
: JSON.stringify(value);
208+
? `[${value.map((v) => JSON.stringify(v)).join(", ")}]`
209+
: JSON.stringify(value);
210210
}
211211
}
212212

0 commit comments

Comments
 (0)