New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

cssmodules-language-server

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cssmodules-language-server - npm Package Compare versions

Comparing version 1.1.0 to 1.2.0

5

lib/utils.d.ts

@@ -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;

26

lib/utils.js

@@ -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;

3

package.json
{
"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",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc