Skip to content

Commit 419f0e3

Browse files
committed
fix: review changes
1 parent da3b455 commit 419f0e3

File tree

8 files changed

+64
-72
lines changed

8 files changed

+64
-72
lines changed

docs/customize-extension.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ The following list of source file extensions does not need any customization.
1616
- Statically parses [template literals](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals). No customization needed
1717

1818
> `cssvar` has minimal support for parsing JS/TS files.
19-
> __*If you are facing issues with JS/TS source file parsing try*__
19+
> __*This won't be required, but in case you face issues with*__
20+
> __*JS/TS source file parsing try*__
2021
> __*using [postcss-css-in-js][css-in-js] parser,*__
2122
> __*as described in the [following section](#example-ii)*__.
2223

examples/css-extensions/package.json

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,5 @@
88
},
99
"keywords": [],
1010
"author": "",
11-
"license": "ISC",
12-
"dependencies": {
13-
"postcss": "8",
14-
"postcss-scss": "^4.0.4"
15-
}
11+
"license": "ISC"
1612
}

examples/css-extensions/pnpm-lock.yaml

Lines changed: 0 additions & 44 deletions
This file was deleted.

package.json

Lines changed: 55 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -223,32 +223,76 @@
223223
"postcss-sass": {
224224
"type": "array",
225225
"description": "Sass (.sass) source file extensions to parse",
226-
"default": ["sass"],
227-
"examples": [["sass"]]
226+
"default": [
227+
"sass"
228+
],
229+
"examples": [
230+
[
231+
"sass"
232+
]
233+
]
228234
},
229235
"postcss-html": {
230236
"type": "array",
231237
"description": "HTML (.html) source file extensions to parse",
232-
"default": ["html"],
233-
"examples": [["html", "ejs"]]
238+
"default": [
239+
"html"
240+
],
241+
"examples": [
242+
[
243+
"html",
244+
"ejs"
245+
]
246+
]
234247
},
235248
"sugarss": {
236249
"type": "array",
237250
"description": "SugarSS (.sss) source file extensions to parse",
238-
"default": ["sss"],
239-
"examples": [["sss"]]
251+
"default": [
252+
"sss"
253+
],
254+
"examples": [
255+
[
256+
"sss"
257+
]
258+
]
240259
},
241260
"postcss-styl": {
242261
"type": "array",
243262
"description": "Stylus (.styl) source file extensions to parse. Repo: https://github.com/stylus/postcss-styl",
244-
"default": ["styl"],
245-
"examples": [["styl"]]
263+
"default": [
264+
"styl"
265+
],
266+
"examples": [
267+
[
268+
"styl"
269+
]
270+
]
271+
},
272+
"postcss-syntax": {
273+
"type": "array",
274+
"description": "To parse template literals in JS/TS source files. Details: https://github.com/willofindie/vscode-cssvar/tree/main/docs/customize-extension.md",
275+
"default": [],
276+
"examples": [
277+
[
278+
"js",
279+
"ts",
280+
"sass"
281+
]
282+
]
246283
},
247284
"postcss-lit": {
248285
"type": "array",
249286
"description": "To parse Lit templates in JS/TS source files. Repo: https://github.com/43081j/postcss-lit",
250-
"default": ["ts"],
251-
"examples": [["js", "ts"]]
287+
"default": [
288+
"ts"
289+
],
290+
"examples": [
291+
[
292+
"js",
293+
"ts"
294+
]
295+
]
252296
}
253297
},
254298
"additionalProperties": true,
@@ -307,8 +351,7 @@
307351
"culori": "^2.0.3",
308352
"fast-glob": "^3.2.11",
309353
"postcss": "^8.4.12",
310-
"postcss-less": "^6.0.0",
311-
"postcss-scss": "^4.0.4"
354+
"postcss-less": "^6.0.0"
312355
},
313356
"lint-staged": {
314357
"*.{ts,tsx}": [

src/extension.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { CssDefinitionProvider } from "./definition-provider";
1414
import { LOGGER } from "./logger";
1515
import { setup } from "./main";
1616
import { parseFiles } from "./parser";
17+
import { isObjectProperty } from "./utils";
1718

1819
const watchers: FileSystemWatcher[] = [];
1920

@@ -117,7 +118,7 @@ export function deactivate(): void {
117118
*/
118119
function updateStatus(event: TextEditor | undefined) {
119120
if (event) {
120-
if (Object.prototype.hasOwnProperty.call(event, "document")) {
121+
if (isObjectProperty(event, "document")) {
121122
const rootPath =
122123
workspace.getWorkspaceFolder((<TextEditor>event).document.uri)?.uri
123124
.fsPath || CACHE.activeRootPath;

src/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ export async function setup(): Promise<{
9494
if (syntaxes) {
9595
config[fsPathKey][key] = Object.keys(syntaxes).reduce(
9696
(syntaxMap, key) => {
97-
if (Object.prototype.hasOwnProperty.call(syntaxes, key)) {
97+
if (isObjectProperty(syntaxes, key)) {
9898
const exts = syntaxes[key];
9999
exts.forEach(ext => {
100100
syntaxMap[ext] = key;

src/utils.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -297,9 +297,9 @@ export const getCSSErrorMsg = (
297297
error: Record<string, any>
298298
) => {
299299
if (
300-
Object.prototype.hasOwnProperty.call(error, "name") &&
301-
Object.prototype.hasOwnProperty.call(error, "reason") &&
302-
Object.prototype.hasOwnProperty.call(error, "line")
300+
isObjectProperty(error, "name") &&
301+
isObjectProperty(error, "reason") &&
302+
isObjectProperty(error, "line")
303303
) {
304304
return JSON.stringify(
305305
{

yarn.lock

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4461,11 +4461,6 @@ postcss-less@^6.0.0:
44614461
resolved "https://registry.yarnpkg.com/postcss-less/-/postcss-less-6.0.0.tgz#463b34c60f53b648c237f569aeb2e09149d85af4"
44624462
integrity sha512-FPX16mQLyEjLzEuuJtxA8X3ejDLNGGEG503d2YGZR5Ask1SpDN8KmZUMpzCvyalWRywAn1n1VOA5dcqfCLo5rg==
44634463

4464-
postcss-scss@^4.0.4:
4465-
version "4.0.4"
4466-
resolved "https://registry.yarnpkg.com/postcss-scss/-/postcss-scss-4.0.4.tgz#aa8f60e19ee18259bc193db9e4b96edfce3f3b1f"
4467-
integrity sha512-aBBbVyzA8b3hUL0MGrpydxxXKXFZc5Eqva0Q3V9qsBOLEMsjb6w49WfpsoWzpEgcqJGW4t7Rio8WXVU9Gd8vWg==
4468-
44694464
postcss@^8.1.2, postcss@^8.4.12, postcss@^8.4.4:
44704465
version "8.4.14"
44714466
resolved "https://registry.yarnpkg.com/postcss/-/postcss-8.4.14.tgz#ee9274d5622b4858c1007a74d76e42e56fd21caf"

0 commit comments

Comments
 (0)