cssmodules-language-server
Advanced tools
+5
-0
@@ -6,2 +6,7 @@ import { Position } from 'vscode-languageserver-protocol'; | ||
| export declare function genImportRegExp(importName: string): RegExp; | ||
| /** | ||
| * Returns absolute file path to a file where css modules is from or an empty string | ||
| * | ||
| * @example "/users/foo/path/to/project/styles/foo.css" | ||
| */ | ||
| export declare function findImportPath(fileContent: string, importName: string, directoryPath: string): string; | ||
@@ -8,0 +13,0 @@ export declare type StringTransformer = (str: string) => string; |
+21
-5
@@ -22,2 +22,3 @@ "use strict"; | ||
| const postcss_1 = __importDefault(require("postcss")); | ||
| const resolveAliasedImport_1 = require("./utils/resolveAliasedImport"); | ||
| function getCurrentDirFromUri(uri) { | ||
@@ -35,11 +36,26 @@ return path_1.default.dirname(uri).replace(/^file:\/\//, ''); | ||
| exports.genImportRegExp = genImportRegExp; | ||
| function isRelativeFilePath(str) { | ||
| return str.startsWith('../') || str.startsWith('./'); | ||
| } | ||
| /** | ||
| * Returns absolute file path to a file where css modules is from or an empty string | ||
| * | ||
| * @example "/users/foo/path/to/project/styles/foo.css" | ||
| */ | ||
| function findImportPath(fileContent, importName, directoryPath) { | ||
| var _a; | ||
| const re = genImportRegExp(importName); | ||
| const results = re.exec(fileContent); | ||
| if (!!results && results.length > 0) { | ||
| if (results == null) { | ||
| return ''; | ||
| } | ||
| const rawImportedFrom = results[1]; | ||
| // "./style.modules.css" or "../../style.modules.css" | ||
| if (isRelativeFilePath(rawImportedFrom)) { | ||
| return path_1.default.resolve(directoryPath, results[1]); | ||
| } | ||
| else { | ||
| return ''; | ||
| } | ||
| return ((_a = (0, resolveAliasedImport_1.resolveAliasedImport)({ | ||
| importFilepath: rawImportedFrom, | ||
| location: directoryPath, | ||
| })) !== null && _a !== void 0 ? _a : ''); | ||
| } | ||
@@ -110,3 +126,3 @@ exports.findImportPath = findImportPath; | ||
| .join('\n\t'); | ||
| fs_1.default.writeFileSync('/tmp/log-cssmodules', `\n[${timestamp}] ${msg}`); | ||
| fs_1.default.appendFileSync('/tmp/log-cssmodules', `\n[${timestamp}] ${msg}\n`); | ||
| }; | ||
@@ -113,0 +129,0 @@ exports.log = log; |
+2
-1
| { | ||
| "name": "cssmodules-language-server", | ||
| "version": "1.1.0", | ||
| "version": "1.2.0", | ||
| "description": "language server for cssmodules", | ||
@@ -46,2 +46,3 @@ "bin": { | ||
| "dependencies": { | ||
| "lilconfig": "^2.0.4", | ||
| "lodash.camelcase": "^4.3.0", | ||
@@ -48,0 +49,0 @@ "postcss": "^8.1.10", |
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
37421
2.24%726
2.98%10
11.11%+ Added
+ Added