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

@markuplint/create-rule-helper

Package Overview
Dependencies
Maintainers
1
Versions
108
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@markuplint/create-rule-helper - npm Package Compare versions

Comparing version 4.0.0-alpha.3 to 4.0.0-alpha.4

6

lib/fs-exists.js
import { stat } from 'node:fs/promises';
export async function fsExists(path) {
const res = await stat(path).catch(e => {
if (e?.code === 'ENOENT') {
const res = await stat(path).catch(error => {
if (error?.code === 'ENOENT') {
return null;
}
throw e;
throw error;
});
return !!res;
}

@@ -46,3 +46,3 @@ import fs from 'node:fs/promises';

}
await fs.writeFile(packageJson, JSON.stringify(packageContent, null, 2), { encoding: 'utf-8' });
await fs.writeFile(packageJson, JSON.stringify(packageContent, null, 2), { encoding: 'utf8' });
transferred.push({

@@ -49,0 +49,0 @@ ext: '.json',

@@ -6,9 +6,9 @@ import fs from 'node:fs/promises';

try {
const json = await fs.readFile(filePath, { encoding: 'utf-8' });
const json = await fs.readFile(filePath, { encoding: 'utf8' });
const data = JSON.parse(json);
return data?.name ?? null;
}
catch (_) {
catch {
return null;
}
}

@@ -28,15 +28,15 @@ import { statSync } from 'node:fs';

}
let contents = await fs.readFile(file.filePath, { encoding: 'utf-8' });
let contents = await fs.readFile(file.filePath, { encoding: 'utf8' });
if (options?.replacer) {
Object.entries(options?.replacer).forEach(([before, after]) => {
for (const [before, after] of Object.entries(options?.replacer)) {
if (!after) {
return;
continue;
}
// Hyphenation to camel-case for variables
// `rule-name` => `ruleName`
contents = contents.replace(new RegExp(`__${before}__c`, 'g'),
contents = contents.replaceAll(new RegExp(`__${before}__c`, 'g'),
// Camelize
after.replace(/-+([a-z])/gi, (_, $1) => $1.toUpperCase()).replace(/^[a-z]/, $0 => $0.toLowerCase()));
contents = contents.replace(new RegExp(`__${before}__`, 'g'), after);
});
after.replaceAll(/-+([a-z])/gi, (_, $1) => $1.toUpperCase()).replace(/^[a-z]/, $0 => $0.toLowerCase()));
contents = contents.replaceAll(new RegExp(`__${before}__`, 'g'), after);
}
}

@@ -62,5 +62,5 @@ // Remove prettier ignore comment

// Insert new line before comments and the export keyword
contents = contents.replace(/(\n)(\s+\/\*\*|export)/g, '$1\n$2');
contents = contents.replaceAll(/(\n)(\s+\/\*\*|export)/g, '$1\n$2');
}
const candidateName = options?.replacer?.[newFile.name.replace(/_/g, '')];
const candidateName = options?.replacer?.[newFile.name.replaceAll('_', '')];
if (candidateName) {

@@ -85,3 +85,3 @@ newFile.name = candidateName;

}
await fs.writeFile(dest, contents, { encoding: 'utf-8' });
await fs.writeFile(dest, contents, { encoding: 'utf8' });
return newFile;

@@ -88,0 +88,0 @@ }

{
"name": "@markuplint/create-rule-helper",
"version": "4.0.0-alpha.3",
"version": "4.0.0-alpha.4",
"description": "Create rule helper",

@@ -25,14 +25,13 @@ "repository": "git@github.com:markuplint/markuplint.git",

"dependencies": {
"@markuplint/ml-core": "4.0.0-alpha.3",
"@markuplint/ml-core": "4.0.0-alpha.4",
"glob": "^10.3.6",
"prettier": "^3.0.3",
"ts-node": "^10.9.1",
"tslib": "^2.6.2",
"typescript": "^5.2.2"
},
"devDependencies": {
"@types/fs-extra": "^11.0.2",
"@types/fs-extra": "^11.0.3",
"fs-extra": "^11.1.1"
},
"gitHead": "380836f7adc1ff7e8eaf9d869e68d29eee8f3b7e"
"gitHead": "991b3aef77fde42c79343ee8c807257a35c589d7"
}
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