@speedy-js/code-helper-diagnostic
Advanced tools
Comparing version 1.2.2 to 1.2.3
@@ -0,5 +1,4 @@ | ||
import { DiagnosticBundlerInstance, DiagnosticLevel, Compiler, DiagnosticOption } from '@speedy-js/code-helper-types'; | ||
import { ModuleGraph } from '@speedy-js/speedy-types'; | ||
import { DiagnosticLevel, Compiler } from '../linter'; | ||
import { DiagnosticOption } from './types'; | ||
export declare class DiagnosticBundler { | ||
export declare class DiagnosticBundler implements DiagnosticBundlerInstance { | ||
/** 根目录 */ | ||
@@ -23,4 +22,2 @@ private root; | ||
private buildErrorMap; | ||
/** 当前打包配置 */ | ||
private bundleConfig; | ||
constructor(root: string, opt: DiagnosticOption); | ||
@@ -37,3 +34,3 @@ /** 读取构建器库 */ | ||
*/ | ||
diagnostic(level?: keyof typeof DiagnosticLevel): Promise<import("../linter/types").ValidateResult | undefined>; | ||
diagnostic(level?: keyof typeof DiagnosticLevel): Promise<import("@speedy-js/code-helper-types").ValidateResult | undefined>; | ||
private getDiagnosticConfig; | ||
@@ -44,3 +41,3 @@ /** | ||
*/ | ||
diagnosticWithoutBundle(level?: keyof typeof DiagnosticLevel): Promise<import("../linter/types").ValidateResult>; | ||
diagnosticWithoutBundle(level?: keyof typeof DiagnosticLevel): Promise<import("@speedy-js/code-helper-types").ValidateResult>; | ||
/** 清空缓存 */ | ||
@@ -47,0 +44,0 @@ clear(): void; |
@@ -20,3 +20,3 @@ "use strict"; | ||
const speedy_logger_1 = require("@speedy-js/speedy-logger"); | ||
const speedy_types_1 = require("@speedy-js/speedy-types"); | ||
const code_helper_types_1 = require("@speedy-js/code-helper-types"); | ||
const modules_1 = require("../modules"); | ||
@@ -36,4 +36,2 @@ const linter_1 = require("../linter"); | ||
this.buildErrorMap = new Map(); | ||
/** 当前打包配置 */ | ||
this.bundleConfig = new Map(); | ||
this.root = path_1.default.resolve(root); | ||
@@ -64,3 +62,3 @@ this.options = opt; | ||
title: constant_1.ErrorCode.Require, | ||
severity: speedy_types_1.Severity.Error, | ||
severity: code_helper_types_1.Severity.Error, | ||
message: "Only support 'Speedy', 'Webpack'. Quit building.", | ||
@@ -73,3 +71,3 @@ }); | ||
title: constant_1.ErrorCode.Require, | ||
severity: speedy_types_1.Severity.Error, | ||
severity: code_helper_types_1.Severity.Error, | ||
message: err.message, | ||
@@ -198,11 +196,10 @@ suggestions: [ | ||
diagnosticWithoutBundle(level) { | ||
var _a; | ||
var _a, _b, _c, _d; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const userConfig = this.getDiagnosticConfig(); | ||
const _rulesConfig = typeof userConfig === 'object' ? userConfig.rules : undefined; | ||
const result = yield (0, linter_1.lint)({ | ||
errors: this.buildErrorMap, | ||
level: level ? linter_1.DiagnosticLevel[level] : this.options.level, | ||
rules: (_a = this.options.rules) !== null && _a !== void 0 ? _a : _rulesConfig, | ||
extends: this.options.extends, | ||
level: level ? code_helper_types_1.DiagnosticLevel[level] : this.options.level, | ||
rules: (_b = (_a = this.options.rules) !== null && _a !== void 0 ? _a : userConfig === null || userConfig === void 0 ? void 0 : userConfig.rules) !== null && _b !== void 0 ? _b : {}, | ||
extends: (_d = (_c = this.options.extends) !== null && _c !== void 0 ? _c : userConfig === null || userConfig === void 0 ? void 0 : userConfig.extends) !== null && _d !== void 0 ? _d : [], | ||
compilers: this.compilers, | ||
@@ -209,0 +206,0 @@ moduleGraphMap: this.moduleGraphMap, |
@@ -1,2 +0,1 @@ | ||
export * from './types'; | ||
export * from './diagnostic'; |
@@ -13,4 +13,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
__exportStar(require("./types"), exports); | ||
__exportStar(require("./diagnostic"), exports); | ||
//# sourceMappingURL=index.js.map |
export * from './diagnostic'; | ||
export * from './modules'; | ||
export * from './linter'; | ||
export { defineRule, diagnosticToSpeedyError } from './utils'; |
@@ -13,5 +13,9 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.diagnosticToSpeedyError = exports.defineRule = void 0; | ||
__exportStar(require("./diagnostic"), exports); | ||
__exportStar(require("./modules"), exports); | ||
__exportStar(require("./linter"), exports); | ||
var utils_1 = require("./utils"); | ||
Object.defineProperty(exports, "defineRule", { enumerable: true, get: function () { return utils_1.defineRule; } }); | ||
Object.defineProperty(exports, "diagnosticToSpeedyError", { enumerable: true, get: function () { return utils_1.diagnosticToSpeedyError; } }); | ||
//# sourceMappingURL=index.js.map |
@@ -1,2 +0,2 @@ | ||
import { FormatError } from '../types'; | ||
import { FormatError } from '@speedy-js/code-helper-types'; | ||
export declare function transform(err: any): FormatError | void; |
@@ -1,2 +0,2 @@ | ||
import { FormatError } from '../types'; | ||
import { FormatError } from '@speedy-js/code-helper-types'; | ||
export declare function transform(err: any): FormatError; |
@@ -1,2 +0,2 @@ | ||
import { FormatError } from '../types'; | ||
import { FormatError } from '@speedy-js/code-helper-types'; | ||
export declare function transformError(err: any): FormatError[]; |
@@ -1,4 +0,3 @@ | ||
import { ValidateOption, ValidateResult } from './types'; | ||
import { ValidateOption, ValidateResult } from '@speedy-js/code-helper-types'; | ||
export * from './document'; | ||
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,14 +22,10 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.lint = exports.DiagnosticLevel = exports.RuleKind = void 0; | ||
exports.lint = void 0; | ||
const chalk_1 = require("chalk"); | ||
const code_helper_types_1 = require("@speedy-js/code-helper-types"); | ||
const errors_1 = require("./errors"); | ||
const types_1 = require("./types"); | ||
const rules_1 = require("./rules"); | ||
const rule_1 = require("./rule"); | ||
const document_1 = require("./document"); | ||
const utils_1 = require("../utils"); | ||
__exportStar(require("./document"), exports); | ||
var types_2 = require("./types"); | ||
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) { | ||
@@ -51,3 +47,3 @@ const rules = rules_1.rules.concat(extendRules.map((data) => rule_1.Rule.fromExtend(data))); | ||
}; | ||
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 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 : code_helper_types_1.DiagnosticLevel.Normal); | ||
const context = { | ||
@@ -60,3 +56,2 @@ errors: (0, utils_1.map)((_d = option.errors) !== null && _d !== void 0 ? _d : new Map(), (val) => (0, errors_1.transformError)(val)), | ||
config: undefined, | ||
Document: document_1.Document, | ||
}; | ||
@@ -63,0 +58,0 @@ yield Promise.all(rules.map((rule) => __awaiter(this, void 0, void 0, function* () { |
@@ -1,3 +0,2 @@ | ||
import { RuleEntry, Severity } from '@speedy-js/speedy-types'; | ||
import { RuleMeta, Diagnostic, RuleData, RuleCheckContext, DiagnosticLevel, RuleKind, ValidateResult, ExtendRuleData } from './types'; | ||
import { RuleConfigItem, Severity, DiagnosticLevel, RuleMeta, ExtendRuleData, RuleKind, Diagnostic, RuleData, RuleCheckContext, ValidateResult } from '@speedy-js/code-helper-types'; | ||
export declare class Rule implements RuleMeta { | ||
@@ -28,5 +27,5 @@ static fromExtend(data: ExtendRuleData): Rule; | ||
match(level: DiagnosticLevel): boolean; | ||
setOption(opt: RuleEntry): void; | ||
setOption(opt: RuleConfigItem): void; | ||
/** 校验 */ | ||
validate(context: Omit<RuleCheckContext, 'report'>): Promise<ValidateResult>; | ||
} |
@@ -24,4 +24,3 @@ "use strict"; | ||
exports.Rule = void 0; | ||
const speedy_types_1 = require("@speedy-js/speedy-types"); | ||
const types_1 = require("./types"); | ||
const code_helper_types_1 = require("@speedy-js/code-helper-types"); | ||
const utils_1 = require("./utils"); | ||
@@ -40,4 +39,4 @@ class Rule { | ||
static fromExtend(data) { | ||
const severity = speedy_types_1.Severity[data.meta.severity]; | ||
const kind = types_1.RuleKind[data.meta.kind]; | ||
const severity = code_helper_types_1.Severity[data.meta.severity]; | ||
const kind = code_helper_types_1.RuleKind[data.meta.kind]; | ||
return new Rule({ | ||
@@ -68,7 +67,7 @@ check: data.check, | ||
switch (level) { | ||
case types_1.DiagnosticLevel.Fast: | ||
return this.kind === types_1.RuleKind.ModuleGraph; | ||
case types_1.DiagnosticLevel.Normal: | ||
return this.kind <= types_1.RuleKind.AST; | ||
case types_1.DiagnosticLevel.All: | ||
case code_helper_types_1.DiagnosticLevel.Fast: | ||
return this.kind === code_helper_types_1.RuleKind.ModuleGraph; | ||
case code_helper_types_1.DiagnosticLevel.Normal: | ||
return this.kind <= code_helper_types_1.RuleKind.AST; | ||
case code_helper_types_1.DiagnosticLevel.All: | ||
return true; | ||
@@ -75,0 +74,0 @@ default: |
@@ -16,6 +16,5 @@ "use strict"; | ||
exports.rule = void 0; | ||
const speedy_types_1 = require("@speedy-js/speedy-types"); | ||
const code_helper_types_1 = require("@speedy-js/code-helper-types"); | ||
const path_1 = __importDefault(require("path")); | ||
const rule_1 = require("../../rule"); | ||
const types_1 = require("../../types"); | ||
const map_1 = require("./map"); | ||
@@ -33,4 +32,4 @@ function getErrorMsg(packages, chalk, root) { | ||
title: 'duplicate-package', | ||
severity: speedy_types_1.Severity.Warn, | ||
kind: types_1.RuleKind.ModuleGraph, | ||
severity: code_helper_types_1.Severity.Warn, | ||
kind: code_helper_types_1.RuleKind.ModuleGraph, | ||
defaultConfig: { checkVersion: 'minor' }, | ||
@@ -37,0 +36,0 @@ }, |
@@ -81,7 +81,8 @@ "use strict"; | ||
contain(file) { | ||
if (!file.startsWith(this.root)) { | ||
const subPath = path_1.default.relative(this.root, file); | ||
// 非同一级目录 | ||
if (subPath.startsWith('..')) { | ||
return false; | ||
} | ||
// 有些模块会在当前模块的 node_modules 里面,这里需要再做一次判断 | ||
const subPath = path_1.default.relative(this.root, file); | ||
return !Package.isPackage(subPath); | ||
@@ -88,0 +89,0 @@ } |
@@ -1,3 +0,3 @@ | ||
import { Severity, SeverityInput } from '@speedy-js/speedy-types'; | ||
import { Severity, SeverityInput } from '@speedy-js/code-helper-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 speedy_types_1 = require("@speedy-js/speedy-types"); | ||
const code_helper_types_1 = require("@speedy-js/code-helper-types"); | ||
function toSeverity(input, defaultLevel) { | ||
if (input === 'off') { | ||
return speedy_types_1.Severity.Ignore; | ||
return code_helper_types_1.Severity.Ignore; | ||
} | ||
@@ -13,3 +13,3 @@ if (input === 'on') { | ||
const key = `${input[0].toUpperCase()}${input.slice(1)}`; | ||
return speedy_types_1.Severity[key]; | ||
return code_helper_types_1.Severity[key]; | ||
} | ||
@@ -16,0 +16,0 @@ exports.toSeverity = toSeverity; |
import { SpeedyPlugin as SpeedyPluginType } from '@speedy-js/speedy-types'; | ||
import { DiagnosticOption } from '../../diagnostic'; | ||
import { DiagnosticOption } from '@speedy-js/code-helper-types'; | ||
declare type PluginOption = Pick<DiagnosticOption, 'level' | 'rules' | 'extends'>; | ||
export declare function DiagnosticPlugin(opt?: PluginOption): SpeedyPluginType; | ||
export {}; |
export * from './load'; | ||
export * from './log'; | ||
export * from './utils'; | ||
export * from './transform'; | ||
export * from './config'; |
@@ -16,2 +16,4 @@ "use strict"; | ||
__exportStar(require("./utils"), exports); | ||
__exportStar(require("./transform"), exports); | ||
__exportStar(require("./config"), exports); | ||
//# sourceMappingURL=index.js.map |
import { SpeedyError, ErrorLevel } from '@speedy-js/speedy-error'; | ||
import { Severity } from '@speedy-js/speedy-types'; | ||
import { Diagnostic } from '../linter'; | ||
import { Severity, Diagnostic } from '@speedy-js/code-helper-types'; | ||
export declare function toSpeedySeverity(level: Severity): keyof typeof ErrorLevel; | ||
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 speedy_types_1 = require("@speedy-js/speedy-types"); | ||
const code_helper_types_1 = require("@speedy-js/code-helper-types"); | ||
function toSpeedySeverity(level) { | ||
switch (level) { | ||
case speedy_types_1.Severity.Error: | ||
case code_helper_types_1.Severity.Error: | ||
return 'Error'; | ||
case speedy_types_1.Severity.Warn: | ||
case code_helper_types_1.Severity.Warn: | ||
return 'Warn'; | ||
@@ -13,0 +13,0 @@ default: |
{ | ||
"name": "@speedy-js/code-helper-diagnostic", | ||
"version": "1.2.2", | ||
"version": "1.2.3", | ||
"description": "", | ||
@@ -17,3 +17,3 @@ "keywords": [], | ||
"dependencies": { | ||
"@speedy-js/speedy-utils": "0.13.2-alpha.12", | ||
"@speedy-js/speedy-utils": "0.13.2-alpha.13", | ||
"lines-and-columns": "2.0.3", | ||
@@ -24,8 +24,8 @@ "look-it-up": "2.1.0" | ||
"@speedy-js/config": "0.8.0-3", | ||
"@speedy-js/esbuild": "0.14.28-speedy-6", | ||
"@speedy-js/code-helper-types": "1.1.0", | ||
"@speedy-js/eslint-config": "0.0.1", | ||
"@speedy-js/speedy-config-loader": "0.13.2-alpha.12", | ||
"@speedy-js/speedy-error": "0.13.2-alpha.12", | ||
"@speedy-js/speedy-logger": "0.13.2-alpha.12", | ||
"@speedy-js/speedy-types": "0.13.2-alpha.12", | ||
"@speedy-js/speedy-config-loader": "0.13.2-alpha.13", | ||
"@speedy-js/speedy-error": "0.13.2-alpha.13", | ||
"@speedy-js/speedy-logger": "0.13.2-alpha.13", | ||
"@speedy-js/speedy-types": "0.13.2-alpha.13", | ||
"@speedy-js/test-toolkit": "0.9.2-alpha.2", | ||
@@ -32,0 +32,0 @@ "@types/node": "12.20.42", |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
89395
79
1395
+ Added@speedy-js/speedy-utils@0.13.2-alpha.13(transitive)
- Removed@speedy-js/speedy-utils@0.13.2-alpha.12(transitive)