Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@speedy-js/code-helper-diagnostic

Package Overview
Dependencies
Maintainers
9
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@speedy-js/code-helper-diagnostic - npm Package Compare versions

Comparing version 1.1.3 to 1.2.0

lib/linter/errors/default.d.ts

24

lib/diagnostic/diagnostic.d.ts
import { ModuleGraph } from '@speedy-js/speedy-types';
import { DiagnosticLevel, Compiler } from '../linter';
import { DiagnosticOption } from './types';
declare type DiagnosticData = Map<Compiler, ModuleGraph>;
export declare class DiagnosticBundler {

@@ -10,6 +9,6 @@ /** 根目录 */

private options;
/** 诊断错误 */
private errors;
/** 日志记录 */
private logger;
/** 颜色输出 */
private print;
/** 当前打包库 */

@@ -19,2 +18,6 @@ private bundler;

private compilers;
/** 诊断错误 */
private errors;
/** 构建错误记录 */
private buildErrorMap;
/** 模块图记录 */

@@ -34,2 +37,3 @@ private moduleGraphMap;

diagnostic(level?: keyof typeof DiagnosticLevel): Promise<import("../linter/types").ValidateResult | undefined>;
private getDiagnosticConfig;
/**

@@ -39,10 +43,16 @@ * 诊断构建流程

*/
diagnosticWithoutBundle(err: any, level?: keyof typeof DiagnosticLevel): Promise<import("../linter/types").ValidateResult>;
diagnosticWithoutBundle(level?: keyof typeof DiagnosticLevel): Promise<import("../linter/types").ValidateResult>;
/** 清空缓存 */
clear(): void;
/** 设置模块图数据 */
setMapData(data: DiagnosticData): void;
/** 设置编译器数据 */
setModuleGraphData(compiler: Compiler, moduleGraph: ModuleGraph): void;
/** 设置错误数据 */
setErrorData(compiler: Compiler, errors: any[]): void;
/**
* 获取所有错误
* - 错误为 SpeedyError 实例
*/
getErrors(): import("@speedy-js/speedy-error").SpeedyError[];
/** 打印错误 */
printErrors(): void;
}
export {};

@@ -17,18 +17,18 @@ "use strict";

const path_1 = __importDefault(require("path"));
const chalk_1 = __importDefault(require("chalk"));
const module_1 = __importDefault(require("module"));
const speedy_error_1 = require("@speedy-js/speedy-error");
const chalk_1 = require("chalk");
const speedy_logger_1 = require("@speedy-js/speedy-logger");
const speedy_types_1 = require("@speedy-js/speedy-types");
const modules_1 = require("../modules");
const linter_1 = require("../linter");
const constant_1 = require("./constant");
const transform_1 = require("../utils/transform");
class DiagnosticBundler {
constructor(root, opt) {
/** 打包器实例 */
this.compilers = [];
/** 诊断错误 */
this.errors = [];
/** 日志记录 */
this.logger = (0, speedy_logger_1.createLogger)({
level: 'info',
});
/** 打包器实例 */
this.compilers = [];
/** 构建错误记录 */
this.buildErrorMap = new Map();
/** 模块图记录 */

@@ -38,2 +38,6 @@ this.moduleGraphMap = new Map();

this.options = opt;
this.print = opt.noColor ? new chalk_1.Instance({ level: 0 }) : new chalk_1.Instance({ level: 3 });
this.logger = (0, speedy_logger_1.createLogger)({
level: opt.noLogger ? 'silent' : 'info',
});
}

@@ -58,3 +62,3 @@ /** 读取构建器库 */

title: constant_1.ErrorCode.Require,
severity: linter_1.Severity.Error,
severity: speedy_types_1.Severity.Error,
message: "Only support 'Speedy', 'Webpack'. Quit building.",

@@ -67,3 +71,3 @@ });

title: constant_1.ErrorCode.Require,
severity: linter_1.Severity.Error,
severity: speedy_types_1.Severity.Error,
message: err.message,

@@ -81,14 +85,15 @@ suggestions: [

try {
// TODO: 要区分读取配置文件的错误和构建错误
const Bundler = this.bundler.SpeedyBundler;
const userConfig = yield this.bundler.loadConfig({
root: path_1.default.resolve(this.root),
configFile: this.options.projectConfig,
command: 'build',
});
const userConfig = yield this.getDiagnosticConfig();
if (!userConfig) {
this.logger.error(`No builder found, terminate diagnosis.`);
return;
}
const bundler = yield Bundler.create(userConfig);
const map = new Map();
bundler.config.logLevel = 'silent';
bundler.config.command = 'build';
bundler.config.watch = false;
modules_1.DiagnosticSpeedyPlugin.TransformPlugin(this).apply(bundler);
yield bundler.build();
map.set(bundler, bundler.moduleGraph);
this.setMapData(map);
}

@@ -130,11 +135,12 @@ catch (err) {

return __awaiter(this, void 0, void 0, function* () {
if (!this.bundler) {
this.logger.error(`No builder found, terminate diagnosis.`);
const { options, print, logger, bundler } = this;
if (!bundler) {
logger.error(`No builder found, terminate diagnosis.`);
return;
}
const { project } = this.options;
const { project } = options;
const start = Date.now();
const logStart = (name) => {
this.logger.info(`Using the ${chalk_1.default.blue(name)} builder, version: ${chalk_1.default.blue(this.bundler.version)}`);
this.logger.info(`Start building... `);
logger.info(`Using the ${print.blue(name)} builder, version: ${print.blue(bundler.version)}`);
logger.info(`Start building... `);
};

@@ -151,3 +157,3 @@ let err;

const end = Date.now() - start;
this.logger.info(`Build completed in ${end}ms.`);
logger.info(`Build completed in ${end}ms.`);
return err;

@@ -166,6 +172,6 @@ });

}
const bundleError = yield this.runBundle();
const result = this.diagnosticWithoutBundle(bundleError, level);
yield this.runBundle();
const result = this.diagnosticWithoutBundle(level);
if (this.errors.length > 0) {
this.logger.info(`Diagnosis completed, found ${chalk_1.default.red(this.errors.length)} problems:\n`);
this.logger.info(`Diagnosis completed, found ${this.print.red(this.errors.length)} problems:\n`);
}

@@ -178,2 +184,12 @@ else {

}
getDiagnosticConfig() {
var _a;
return __awaiter(this, void 0, void 0, function* () {
return (_a = this.bundler) === null || _a === void 0 ? void 0 : _a.loadConfig({
root: path_1.default.resolve(this.root),
configFile: this.options.projectConfig,
command: 'build',
});
});
}
/**

@@ -183,13 +199,17 @@ * 诊断构建流程

*/
diagnosticWithoutBundle(err, level) {
diagnosticWithoutBundle(level) {
var _a;
return __awaiter(this, void 0, void 0, function* () {
const userConfig = yield this.getDiagnosticConfig();
const _rulesConfig = typeof (userConfig === null || userConfig === void 0 ? void 0 : userConfig.diagnostic) === 'object' ? userConfig.diagnostic.rules : undefined;
const result = yield (0, linter_1.lint)({
error: err,
errors: this.buildErrorMap,
level: level ? linter_1.DiagnosticLevel[level] : this.options.level,
rules: this.options.rules,
rules: (_a = this.options.rules) !== null && _a !== void 0 ? _a : _rulesConfig,
extends: this.options.extends,
compilers: this.compilers,
moduleGraphMap: this.moduleGraphMap,
chalk: this.options.chalk,
chalk: this.print,
root: this.root,
config: (userConfig === null || userConfig === void 0 ? void 0 : userConfig.diagnostic) || {},
});

@@ -205,29 +225,33 @@ this.errors = this.errors.concat(result.errors);

this.moduleGraphMap = new Map();
this.buildErrorMap = new Map();
}
/** 设置模块图数据 */
setMapData(data) {
this.compilers = Array.from(data.keys());
this.moduleGraphMap = data;
/** 设置编译器数据 */
setModuleGraphData(compiler, moduleGraph) {
if (!this.compilers.includes(compiler)) {
this.compilers.push(compiler);
}
this.moduleGraphMap.set(compiler, moduleGraph);
}
/** 设置错误数据 */
setErrorData(compiler, errors) {
if (!this.compilers.includes(compiler)) {
this.compilers.push(compiler);
}
this.buildErrorMap.set(compiler, errors);
}
/**
* 获取所有错误
* - 错误为 SpeedyError 实例
*/
getErrors() {
const { options, errors } = this;
return errors.map((error) => {
return (0, transform_1.diagnosticToSpeedyError)(error, options.project, options.noColor);
});
}
/** 打印错误 */
printErrors() {
// const { language } = this.options;
const errors = this.errors.map((error) => {
// const message =
// typeof error.message === 'string' ? error.message : language === 'zh' ? error.message.zh : error.message.en;
const codeFrame = error.uri && error.content && error.range
? {
filePath: error.uri,
fileContent: error.content,
range: error.range,
}
: undefined;
return new speedy_error_1.SpeedyError(error.title, error.message, {
codeFrame,
controller: {
noStack: true,
},
});
});
errors.forEach((err) => this.logger.error(err.toString()));
this.logger.error(this.getErrors()
.map((err) => err.toString())
.join('\n'));
}

@@ -234,0 +258,0 @@ }

@@ -1,3 +0,3 @@

import type { Chalk } from 'chalk';
import type { RulesMap, RuleData, DiagnosticLevel } from '../linter';
import type { IDiagnosticConfig } from '@speedy-js/speedy-types';
import type { RuleData, DiagnosticLevel } from '../linter';
/** 项目类别 */

@@ -16,7 +16,9 @@ export declare type ProjectKind = 'speedy' | 'pia' | 'jupiter' | 'webpack';

/** 规则配置 */
rules?: RulesMap;
rules?: IDiagnosticConfig['rules'];
/** 自定义规则 */
extends?: RuleData[];
/** 文本染色输出 */
chalk?: Chalk;
/** 禁止输出颜色 */
noColor?: boolean;
/** 禁用日志 */
noLogger?: boolean;
}
import { FormatError } from '../types';
interface NormalizeError {
errors: any[];
formatErrors: FormatError[];
}
export declare function transformError(err: any): NormalizeError;
export {};
export declare function transformError(err: any): FormatError[];

@@ -5,3 +5,4 @@ "use strict";

const babel_type_duplicate_declare_1 = require("./babel-type-duplicate-declare");
const transforms = [babel_type_duplicate_declare_1.transform];
const default_1 = require("./default");
const transforms = [babel_type_duplicate_declare_1.transform, default_1.transform];
function expandErrors(err) {

@@ -11,8 +12,5 @@ return Array.isArray(err) ? err : Array.isArray(err.errors) && err.errors.length > 0 ? err.errors : [err];

function transformError(err) {
const data = {
errors: [],
formatErrors: [],
};
const result = [];
if (!err) {
return data;
return result;
}

@@ -22,12 +20,11 @@ const normalErrors = expandErrors(err);

for (const transform of transforms) {
const result = transform(error);
if (result) {
data.formatErrors.push(result);
const transformed = transform(error);
if (transformed) {
result.push(transformed);
}
}
data.errors.push(error);
});
return data;
return result;
}
exports.transformError = transformError;
//# sourceMappingURL=index.js.map
import { ValidateOption, ValidateResult } from './types';
export * from './document';
export { Suggestion, I18nMessage, ReportData, Diagnostic, Severity, RuleKind, Compiler, RuleCheckContext, CheckCallback, SeverityInput, RuleKindInput, RuleConfigItem, RulesMap, DiagnosticLevel, ExtendRuleMeta as RuleMeta, ExtendRuleData as RuleData, } from './types';
export { Suggestion, I18nMessage, ReportData, Diagnostic, RuleKind, Compiler, RuleCheckContext, CheckCallback, RuleKindInput, RuleConfigItem, RulesMap, DiagnosticLevel, ExtendRuleMeta as RuleMeta, ExtendRuleData as RuleData, } from './types';
export declare function lint(option?: ValidateOption): Promise<ValidateResult>;

@@ -22,3 +22,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.lint = exports.DiagnosticLevel = exports.RuleKind = exports.Severity = void 0;
exports.lint = exports.DiagnosticLevel = exports.RuleKind = void 0;
const chalk_1 = require("chalk");

@@ -30,8 +30,8 @@ const errors_1 = require("./errors");

const document_1 = require("./document");
const utils_1 = require("../utils");
__exportStar(require("./document"), exports);
var types_2 = require("./types");
Object.defineProperty(exports, "Severity", { enumerable: true, get: function () { return types_2.Severity; } });
Object.defineProperty(exports, "RuleKind", { enumerable: true, get: function () { return types_2.RuleKind; } });
Object.defineProperty(exports, "DiagnosticLevel", { enumerable: true, get: function () { return types_2.DiagnosticLevel; } });
function getRules(ruleMap, extendRules, filterLevel) {
function getRules(ruleMap = {}, extendRules, filterLevel) {
const rules = rules_1.rules.concat(extendRules.map((data) => rule_1.Rule.fromExtend(data)));

@@ -46,3 +46,3 @@ rules.forEach((rule) => {

function lint(option = {}) {
var _a, _b, _c, _d, _e, _f, _g;
var _a, _b, _c, _d, _e, _f, _g, _h;
return __awaiter(this, void 0, void 0, function* () {

@@ -53,10 +53,9 @@ const lintResult = {

};
const { formatErrors } = (0, errors_1.transformError)(option.error);
const rules = getRules((_a = option.rules) !== null && _a !== void 0 ? _a : {}, (_b = option.extends) !== null && _b !== void 0 ? _b : [], (_c = option.level) !== null && _c !== void 0 ? _c : types_1.DiagnosticLevel.Normal);
const context = {
errors: formatErrors,
compilers: (_d = option.compilers) !== null && _d !== void 0 ? _d : [],
root: (_e = option.root) !== null && _e !== void 0 ? _e : process.cwd(),
chalk: (_f = option.chalk) !== null && _f !== void 0 ? _f : new chalk_1.Instance({ level: 3 }),
moduleGraphMap: (_g = option.moduleGraphMap) !== null && _g !== void 0 ? _g : new Map(),
errors: (0, utils_1.map)((_d = option.errors) !== null && _d !== void 0 ? _d : new Map(), (val) => (0, errors_1.transformError)(val)),
compilers: (_e = option.compilers) !== null && _e !== void 0 ? _e : [],
root: (_f = option.root) !== null && _f !== void 0 ? _f : process.cwd(),
chalk: (_g = option.chalk) !== null && _g !== void 0 ? _g : new chalk_1.Instance({ level: 3 }),
moduleGraphMap: (_h = option.moduleGraphMap) !== null && _h !== void 0 ? _h : new Map(),
config: undefined,

@@ -63,0 +62,0 @@ Document: document_1.Document,

@@ -1,2 +0,3 @@

import { RuleMeta, Diagnostic, RuleData, RuleCheckContext, DiagnosticLevel, RuleKind, RuleConfigItem, Severity, ValidateResult, ExtendRuleData } from './types';
import { RuleEntry, Severity } from '@speedy-js/speedy-types';
import { RuleMeta, Diagnostic, RuleData, RuleCheckContext, DiagnosticLevel, RuleKind, ValidateResult, ExtendRuleData } from './types';
export declare class Rule implements RuleMeta {

@@ -27,5 +28,5 @@ static fromExtend(data: ExtendRuleData): Rule;

match(level: DiagnosticLevel): boolean;
setOption(opt: RuleConfigItem): void;
setOption(opt: RuleEntry): void;
/** 校验 */
validate(context: Omit<RuleCheckContext, 'report'>): Promise<ValidateResult>;
}

@@ -24,2 +24,3 @@ "use strict";

exports.Rule = void 0;
const speedy_types_1 = require("@speedy-js/speedy-types");
const types_1 = require("./types");

@@ -39,3 +40,3 @@ const utils_1 = require("./utils");

static fromExtend(data) {
const severity = types_1.Severity[data.meta.severity];
const severity = speedy_types_1.Severity[data.meta.severity];
const kind = types_1.RuleKind[data.meta.kind];

@@ -89,3 +90,3 @@ return new Rule({

this._severity = severity;
this._config = config;
this._config = config !== null && config !== void 0 ? config : this._config;
}

@@ -92,0 +93,0 @@ /** 校验 */

@@ -16,2 +16,3 @@ "use strict";

exports.rule = void 0;
const speedy_types_1 = require("@speedy-js/speedy-types");
const path_1 = __importDefault(require("path"));

@@ -32,7 +33,7 @@ const rule_1 = require("../../rule");

title: 'duplicate-package',
severity: types_1.Severity.Warn,
severity: speedy_types_1.Severity.Warn,
kind: types_1.RuleKind.ModuleGraph,
defaultConfig: [],
defaultConfig: { checkVersion: 'minor' },
},
check({ moduleGraphMap, compilers, report, root, chalk }) {
check({ moduleGraphMap, compilers, report, root, chalk, config }) {
return __awaiter(this, void 0, void 0, function* () {

@@ -42,3 +43,3 @@ const dupPackages = (yield Promise.all(compilers.map((compiler) => __awaiter(this, void 0, void 0, function* () {

yield pkg.createTree();
return pkg.getDuplicatePackages();
return pkg.getDuplicatePackages(config);
})))).reduce((ans, item) => ans.concat(item), []);

@@ -45,0 +46,0 @@ // TODO: 保存数据到 json 文件,供后续读取

@@ -13,3 +13,5 @@ import type { ModuleGraph } from '@speedy-js/speedy-types';

addPackage(node: Package): void;
getDuplicatePackages(): Package[][];
getDuplicatePackages(config: {
checkVersion: 'major' | 'minor' | 'patch';
}): Package[][];
}

@@ -11,7 +11,16 @@ "use strict";

};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.PackageMap = void 0;
const speedy_utils_1 = require("@speedy-js/speedy-utils");
const semver_1 = __importDefault(require("semver"));
const package_1 = require("./package");
const dependency_1 = require("./dependency");
const VERESIONMAP = {
patch: ['patch'],
minor: ['patch', 'minor'],
major: ['patch', 'monor', 'major'],
};
class PackageMap {

@@ -58,6 +67,29 @@ constructor(graph) {

}
getDuplicatePackages() {
return (0, speedy_utils_1.unique)(this.packages
getDuplicatePackages(config) {
const dupPacks = [];
this.packages
.map((pkg) => this.packages.filter((item) => item.name === pkg.name))
.filter((pkgs) => pkgs.length > 1), (pkgs) => pkgs[0].name);
.filter((pkgs) => pkgs.length > 1)
.map((duplicatePacks) => {
duplicatePacks.sort((_packA, _packB) => {
return semver_1.default.gt(_packA.version, _packB.version);
});
const final = [];
for (let index = 1; index < duplicatePacks.length; index++) {
const _prePack = duplicatePacks[index - 1];
const _curPack = duplicatePacks[index];
const _diffVersion = semver_1.default.diff(_prePack.version, _curPack.version) || 'null';
if (VERESIONMAP[config.checkVersion].indexOf(_diffVersion) > -1) {
index === 1 && final.push(_prePack);
final.push(_curPack);
}
else {
break;
}
}
if (final.length) {
dupPacks.push(final);
}
});
return (dupPacks === null || dupPacks === void 0 ? void 0 : dupPacks.length) ? (0, speedy_utils_1.unique)(dupPacks, (pkgs) => pkgs[0].name) : [];
}

@@ -64,0 +96,0 @@ }

@@ -1,2 +0,2 @@

import type { Range, ModuleGraph } from '@speedy-js/speedy-types';
import type { Range, ModuleGraph, Severity, SeverityInput, SeverityString, IDiagnosticConfig } from '@speedy-js/speedy-types';
import type { Chalk } from 'chalk';

@@ -44,8 +44,2 @@ import type { Document } from './document';

}
/** 错误严重程度 */
export declare enum Severity {
Ignore = 0,
Error = 1,
Warn = 2
}
/** 诊断等级 */

@@ -104,4 +98,4 @@ export declare enum DiagnosticLevel {

moduleGraphMap: Map<Compiler, ModuleGraph>;
/** 构建过程抛出的错误信息 */
errors: FormatError[];
/** 构建过程的错误信息 */
errors: Map<Compiler, FormatError[]>;
/** 当前工程根目录 */

@@ -138,6 +132,2 @@ root: string;

}
/** 报错等级 */
export declare type SeverityString = keyof typeof Severity;
/** 报错等级 */
export declare type SeverityInput = SeverityString | 'off' | 'on';
/** 规则类别 */

@@ -163,5 +153,5 @@ export declare type RuleKindInput = keyof typeof RuleKind;

/** 验证选项 */
export interface ValidateOption extends Omit<Partial<RuleCheckContext>, 'report'> {
error?: any;
rules?: RulesMap;
export interface ValidateOption extends Omit<Partial<RuleCheckContext>, 'report' | 'errors'> {
errors?: Map<Compiler, any>;
rules?: IDiagnosticConfig['rules'];
extends?: ExtendRuleData[];

@@ -173,3 +163,3 @@ level?: DiagnosticLevel;

/** 规则配置 */
export declare type RulesMap = Record<string, RuleConfigItem>;
export declare type RulesMap = IDiagnosticConfig['rules'];
/** 校验结果 */

@@ -176,0 +166,0 @@ export interface ValidateResult {

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.RuleKind = exports.DiagnosticLevel = exports.Severity = void 0;
/** 错误严重程度 */
var Severity;
(function (Severity) {
Severity[Severity["Ignore"] = 0] = "Ignore";
Severity[Severity["Error"] = 1] = "Error";
Severity[Severity["Warn"] = 2] = "Warn";
})(Severity = exports.Severity || (exports.Severity = {}));
exports.RuleKind = exports.DiagnosticLevel = void 0;
/** 诊断等级 */

@@ -12,0 +5,0 @@ var DiagnosticLevel;

@@ -1,3 +0,3 @@

import { Severity, SeverityInput } from './types';
import { Severity, SeverityInput } from '@speedy-js/speedy-types';
export declare function toSeverity(input: SeverityInput, defaultLevel: Severity): Severity;
export declare function removeItem<T>(arr: T[], items: any[]): T[];
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.removeItem = exports.toSeverity = void 0;
const types_1 = require("./types");
const speedy_types_1 = require("@speedy-js/speedy-types");
function toSeverity(input, defaultLevel) {
if (input === 'off') {
return types_1.Severity.Ignore;
return speedy_types_1.Severity.Ignore;
}

@@ -12,3 +12,4 @@ if (input === 'on') {

}
return types_1.Severity[input];
const key = `${input[0].toUpperCase()}${input.slice(1)}`;
return speedy_types_1.Severity[key];
}

@@ -15,0 +16,0 @@ exports.toSeverity = toSeverity;

@@ -1,1 +0,1 @@

export * as Speedy from './speedy';
export * as DiagnosticSpeedyPlugin from './speedy';

@@ -22,4 +22,4 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.Speedy = void 0;
exports.Speedy = __importStar(require("./speedy"));
exports.DiagnosticSpeedyPlugin = void 0;
exports.DiagnosticSpeedyPlugin = __importStar(require("./speedy"));
//# sourceMappingURL=index.js.map
export * from './instance';
export * from './transform';

@@ -14,2 +14,3 @@ "use strict";

__exportStar(require("./instance"), exports);
__exportStar(require("./transform"), exports);
//# sourceMappingURL=index.js.map
import { SpeedyPlugin as SpeedyPluginType } from '@speedy-js/speedy-types';
import { DiagnosticOption } from '../../diagnostic';
declare type PluginOption = Pick<DiagnosticOption, 'level' | 'chalk' | 'rules' | 'extends'>;
declare type PluginOption = Pick<DiagnosticOption, 'level' | 'rules' | 'extends'>;
export declare function DiagnosticPlugin(opt?: PluginOption): SpeedyPluginType;
export {};

@@ -15,4 +15,5 @@ "use strict";

const diagnostic_1 = require("../../diagnostic");
const transform_2 = require("./transform");
function DiagnosticPlugin(opt = {}) {
const pluginName = 'speedy-diagnostic:plugin';
const pluginName = 'speedy:diagnostic:plugin';
return {

@@ -22,16 +23,8 @@ name: pluginName,

const diagnostic = new diagnostic_1.DiagnosticBundler(compiler.config.root, Object.assign({ project: 'speedy' }, opt));
if (compiler.config.watch) {
return;
}
compiler.hooks.startCompilation.tapPromise({ name: pluginName }, () => __awaiter(this, void 0, void 0, function* () {
const map = new Map();
map.set(compiler, compiler.moduleGraph);
diagnostic.setMapData(map);
}));
// 编译完成
(0, transform_2.TransformPlugin)(diagnostic).apply(compiler);
compiler.hooks.endCompilation.tapPromise({
name: pluginName,
stage: Infinity,
}, ({ errors }) => __awaiter(this, void 0, void 0, function* () {
const result = yield diagnostic.diagnosticWithoutBundle(errors, 'Normal');
}, () => __awaiter(this, void 0, void 0, function* () {
const result = yield diagnostic.diagnosticWithoutBundle('Normal');
compiler.removeError(...result.replace);

@@ -38,0 +31,0 @@ compiler.report(result.errors.map((item) => (0, transform_1.diagnosticToSpeedyError)(item, 'Speedy')));

export * from './load';
export * from './log';
export * from './utils';

@@ -15,2 +15,3 @@ "use strict";

__exportStar(require("./log"), exports);
__exportStar(require("./utils"), exports);
//# sourceMappingURL=index.js.map
import { SpeedyError, ErrorLevel } from '@speedy-js/speedy-error';
import { Diagnostic, Severity } from '../linter';
import { Severity } from '@speedy-js/speedy-types';
import { Diagnostic } from '../linter';
export declare function toSpeedySeverity(level: Severity): keyof typeof ErrorLevel;
export declare function diagnosticToSpeedyError(error: Diagnostic, projectCode: string): SpeedyError;
export declare function diagnosticToSpeedyError(error: Diagnostic, projectCode: string, noColor?: boolean): SpeedyError;

@@ -5,8 +5,8 @@ "use strict";

const speedy_error_1 = require("@speedy-js/speedy-error");
const linter_1 = require("../linter");
const speedy_types_1 = require("@speedy-js/speedy-types");
function toSpeedySeverity(level) {
switch (level) {
case linter_1.Severity.Error:
case speedy_types_1.Severity.Error:
return 'Error';
case linter_1.Severity.Warn:
case speedy_types_1.Severity.Warn:
return 'Warn';

@@ -18,3 +18,3 @@ default:

exports.toSpeedySeverity = toSpeedySeverity;
function diagnosticToSpeedyError(error, projectCode) {
function diagnosticToSpeedyError(error, projectCode, noColor = false) {
var _a, _b, _c;

@@ -35,2 +35,5 @@ const codeFrame = error.uri && error.content

codeFrame,
controller: {
noColor,
},
});

@@ -37,0 +40,0 @@ }

{
"name": "@speedy-js/code-helper-diagnostic",
"version": "1.1.3",
"version": "1.2.0",
"description": "",

@@ -17,3 +17,3 @@ "keywords": [],

"dependencies": {
"@speedy-js/speedy-utils": "0.13.2-alpha.9",
"@speedy-js/speedy-utils": "0.13.2-alpha.10",
"lines-and-columns": "2.0.3",

@@ -26,8 +26,9 @@ "look-it-up": "2.1.0"

"@speedy-js/eslint-config": "0.0.1",
"@speedy-js/speedy-config-loader": "0.13.2-alpha.9",
"@speedy-js/speedy-error": "0.13.2-alpha.9",
"@speedy-js/speedy-logger": "0.13.2-alpha.9",
"@speedy-js/speedy-types": "0.13.2-alpha.9",
"@speedy-js/speedy-config-loader": "0.13.2-alpha.10",
"@speedy-js/speedy-error": "0.13.2-alpha.10",
"@speedy-js/speedy-logger": "0.13.2-alpha.10",
"@speedy-js/speedy-types": "0.13.2-alpha.10",
"@speedy-js/test-toolkit": "0.9.2-alpha.2",
"@types/node": "12.20.42",
"@types/semver": "7.3.9",
"@types/webpack": "5.28.0",

@@ -37,2 +38,3 @@ "chalk": "4.1.0",

"mocha": "9.1.3",
"semver": "7.3.5",
"typescript": "4.4.4"

@@ -39,0 +41,0 @@ },

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

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

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

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