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

@textlint/fixer-formatter

Package Overview
Dependencies
Maintainers
3
Versions
89
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@textlint/fixer-formatter - npm Package Compare versions

Comparing version 12.6.1 to 13.0.0

83

lib/src/index.js
// LICENSE : MIT
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {

@@ -29,52 +20,48 @@ return (mod && mod.__esModule) ? mod : { "default": mod };

// https://github.com/nodejs/node/issues/31710
function dynamicImport(targetPath) {
return __awaiter(this, void 0, void 0, function* () {
const fileUrl = (0, node_url_1.pathToFileURL)(targetPath).href;
return import(fileUrl);
});
async function dynamicImport(targetPath) {
const fileUrl = (0, node_url_1.pathToFileURL)(targetPath).href;
return import(fileUrl);
}
exports.dynamicImport = dynamicImport;
const debug = (0, debug_1.default)("textlint:textfix-formatter");
function loadFormatter(formatterConfig) {
return __awaiter(this, void 0, void 0, function* () {
const formatterName = formatterConfig.formatterName;
debug(`formatterName: ${formatterName}`);
let formatter;
let formatterPath;
if (fs_1.default.existsSync(formatterName)) {
formatterPath = formatterName;
async function loadFormatter(formatterConfig) {
const formatterName = formatterConfig.formatterName;
debug(`formatterName: ${formatterName}`);
let formatter;
let formatterPath;
if (fs_1.default.existsSync(formatterName)) {
formatterPath = formatterName;
}
else if (fs_1.default.existsSync(path_1.default.resolve(process.cwd(), formatterName))) {
formatterPath = path_1.default.resolve(process.cwd(), formatterName);
}
else {
if ((0, is_file_1.default)(`${path_1.default.join(__dirname, "formatters/", formatterName)}.js`)) {
formatterPath = `${path_1.default.join(__dirname, "formatters/", formatterName)}.js`;
}
else if (fs_1.default.existsSync(path_1.default.resolve(process.cwd(), formatterName))) {
formatterPath = path_1.default.resolve(process.cwd(), formatterName);
else if ((0, is_file_1.default)(`${path_1.default.join(__dirname, "formatters/", formatterName)}.ts`)) {
formatterPath = `${path_1.default.join(__dirname, "formatters/", formatterName)}.ts`;
}
else {
if ((0, is_file_1.default)(`${path_1.default.join(__dirname, "formatters/", formatterName)}.js`)) {
formatterPath = `${path_1.default.join(__dirname, "formatters/", formatterName)}.js`;
const pkgPath = (0, try_resolve_1.default)(`textlint-formatter-${formatterName}`) || (0, try_resolve_1.default)(formatterName);
if (pkgPath) {
formatterPath = pkgPath;
}
else if ((0, is_file_1.default)(`${path_1.default.join(__dirname, "formatters/", formatterName)}.ts`)) {
formatterPath = `${path_1.default.join(__dirname, "formatters/", formatterName)}.ts`;
}
else {
const pkgPath = (0, try_resolve_1.default)(`textlint-formatter-${formatterName}`) || (0, try_resolve_1.default)(formatterName);
if (pkgPath) {
formatterPath = pkgPath;
}
}
}
try {
const moduleExports = (yield dynamicImport(formatterPath)).default;
formatter = (0, module_interop_1.moduleInterop)(moduleExports);
}
catch (ex) {
throw new Error(`Could not find formatter ${formatterName}
}
try {
const moduleExports = (await dynamicImport(formatterPath)).default;
formatter = (0, module_interop_1.moduleInterop)(moduleExports);
}
catch (ex) {
throw new Error(`Could not find formatter ${formatterName}
See https://github.com/textlint/textlint/issues/148
${ex}`);
}
debug(`use formatter: ${formatterPath}`);
return {
format(results) {
return formatter(results, formatterConfig);
}
debug(`use formatter: ${formatterPath}`);
return {
format(results) {
return formatter(results, formatterConfig);
}
};
});
};
}

@@ -81,0 +68,0 @@ exports.loadFormatter = loadFormatter;

// LICENSE : MIT
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
import { moduleInterop } from "@textlint/module-interop";

@@ -24,51 +15,47 @@ import fs from "fs";

// https://github.com/nodejs/node/issues/31710
export function dynamicImport(targetPath) {
return __awaiter(this, void 0, void 0, function* () {
const fileUrl = pathToFileURL(targetPath).href;
return import(fileUrl);
});
export async function dynamicImport(targetPath) {
const fileUrl = pathToFileURL(targetPath).href;
return import(fileUrl);
}
const debug = debug0("textlint:textfix-formatter");
export function loadFormatter(formatterConfig) {
return __awaiter(this, void 0, void 0, function* () {
const formatterName = formatterConfig.formatterName;
debug(`formatterName: ${formatterName}`);
let formatter;
let formatterPath;
if (fs.existsSync(formatterName)) {
formatterPath = formatterName;
export async function loadFormatter(formatterConfig) {
const formatterName = formatterConfig.formatterName;
debug(`formatterName: ${formatterName}`);
let formatter;
let formatterPath;
if (fs.existsSync(formatterName)) {
formatterPath = formatterName;
}
else if (fs.existsSync(path.resolve(process.cwd(), formatterName))) {
formatterPath = path.resolve(process.cwd(), formatterName);
}
else {
if (isFile(`${path.join(__dirname, "formatters/", formatterName)}.js`)) {
formatterPath = `${path.join(__dirname, "formatters/", formatterName)}.js`;
}
else if (fs.existsSync(path.resolve(process.cwd(), formatterName))) {
formatterPath = path.resolve(process.cwd(), formatterName);
else if (isFile(`${path.join(__dirname, "formatters/", formatterName)}.ts`)) {
formatterPath = `${path.join(__dirname, "formatters/", formatterName)}.ts`;
}
else {
if (isFile(`${path.join(__dirname, "formatters/", formatterName)}.js`)) {
formatterPath = `${path.join(__dirname, "formatters/", formatterName)}.js`;
const pkgPath = tryResolve(`textlint-formatter-${formatterName}`) || tryResolve(formatterName);
if (pkgPath) {
formatterPath = pkgPath;
}
else if (isFile(`${path.join(__dirname, "formatters/", formatterName)}.ts`)) {
formatterPath = `${path.join(__dirname, "formatters/", formatterName)}.ts`;
}
else {
const pkgPath = tryResolve(`textlint-formatter-${formatterName}`) || tryResolve(formatterName);
if (pkgPath) {
formatterPath = pkgPath;
}
}
}
try {
const moduleExports = (yield dynamicImport(formatterPath)).default;
formatter = moduleInterop(moduleExports);
}
catch (ex) {
throw new Error(`Could not find formatter ${formatterName}
}
try {
const moduleExports = (await dynamicImport(formatterPath)).default;
formatter = moduleInterop(moduleExports);
}
catch (ex) {
throw new Error(`Could not find formatter ${formatterName}
See https://github.com/textlint/textlint/issues/148
${ex}`);
}
debug(`use formatter: ${formatterPath}`);
return {
format(results) {
return formatter(results, formatterConfig);
}
debug(`use formatter: ${formatterPath}`);
return {
format(results) {
return formatter(results, formatterConfig);
}
};
});
};
}

@@ -75,0 +62,0 @@ /**

{
"name": "@textlint/fixer-formatter",
"version": "12.6.1",
"version": "13.0.0",
"description": "textlint output formatter for fixer",

@@ -40,4 +40,4 @@ "keywords": [

"dependencies": {
"@textlint/module-interop": "^12.6.1",
"@textlint/types": "^12.6.1",
"@textlint/module-interop": "^13.0.0",
"@textlint/types": "^13.0.0",
"chalk": "^4.1.2",

@@ -65,3 +65,3 @@ "debug": "^4.3.4",

},
"gitHead": "d2b1ea21b70dd86190f530ba3c1ecad697c8f39d"
"gitHead": "5ab6892e6c3f100751542f2c84bc91e78c584f7f"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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