postcss-calc 9.0.0 → 10.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE CHANGED
File without changes
package/README.md CHANGED
File without changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "postcss-calc",
3
- "version": "9.0.0",
3
+ "version": "10.0.0",
4
4
  "description": "PostCSS plugin to reduce calc()",
5
5
  "keywords": [
6
6
  "css",
@@ -21,15 +21,8 @@
21
21
  "types",
22
22
  "LICENSE"
23
23
  ],
24
- "scripts": {
25
- "prepare": "pnpm run build && tsc",
26
- "build": "jison ./parser.jison -o src/parser.js",
27
- "lint": "eslint . && tsc",
28
- "test": "uvu test"
29
- },
30
24
  "author": "Andy Jansson",
31
25
  "license": "MIT",
32
- "repository": "https://github.com/postcss/postcss-calc.git",
33
26
  "eslintConfig": {
34
27
  "extends": [
35
28
  "eslint:recommended",
@@ -47,23 +40,28 @@
47
40
  }
48
41
  },
49
42
  "engines": {
50
- "node": "^14 || ^16 || >=18.0"
43
+ "node": "^18.12 || ^20.9 || >=22.0"
51
44
  },
52
45
  "devDependencies": {
53
- "@types/node": "^18.16.2",
54
- "eslint": "^8.39.0",
55
- "eslint-config-prettier": "^8.8.0",
46
+ "@types/node": "^20.12.7",
47
+ "eslint": "^9.0.0",
48
+ "eslint-config-prettier": "^9.1.0",
56
49
  "jison-gho": "^0.6.1-216",
57
- "postcss": "^8.2.2",
58
- "prettier": "^2.8.8",
59
- "typescript": "~5.0.4",
50
+ "postcss": "^8.4.38",
51
+ "prettier": "^3.2.5",
52
+ "typescript": "~5.4.5",
60
53
  "uvu": "^0.5.6"
61
54
  },
62
55
  "dependencies": {
63
- "postcss-selector-parser": "^6.0.11",
56
+ "postcss-selector-parser": "^6.0.16",
64
57
  "postcss-value-parser": "^4.2.0"
65
58
  },
66
59
  "peerDependencies": {
67
- "postcss": "^8.2.2"
60
+ "postcss": "^8.4.38"
61
+ },
62
+ "scripts": {
63
+ "build": "jison ./parser.jison -o src/parser.js",
64
+ "lint": "eslint . && tsc",
65
+ "test": "uvu test"
68
66
  }
69
- }
67
+ }
@@ -73,12 +73,17 @@ module.exports = function (calc, node, originalValue, options, result, item) {
73
73
  let str = stringify(node, options.precision);
74
74
 
75
75
  const shouldPrintCalc =
76
- node.type === 'MathExpression' || node.type === 'Function';
76
+ node.type === 'MathExpression' || node.type === 'Function' ||
77
+ node.type === 'ParenthesizedExpression';
77
78
 
78
79
  if (shouldPrintCalc) {
79
80
  // if calc expression couldn't be resolved to a single value, re-wrap it as
80
81
  // a calc()
81
- str = `${calc}(${str})`;
82
+ if (node.type === 'ParenthesizedExpression') {
83
+ str = `${calc}${str}`;
84
+ } else {
85
+ str = `${calc}(${str})`;
86
+ }
82
87
 
83
88
  // if the warnWhenCannotResolve option is on, inform the user that the calc
84
89
  // expression could not be resolved to a single value