新增checker相关配置项
This commit is contained in:
parent
e4459b9a2d
commit
1d716c41a6
|
|
@ -2,6 +2,15 @@ export type Level = 'ignore' | 'error' | 'warn' | 'info';
|
||||||
|
|
||||||
export type OakConfiog = {
|
export type OakConfiog = {
|
||||||
projectDir: string;
|
projectDir: string;
|
||||||
|
// checker配置
|
||||||
|
checker?: {
|
||||||
|
// 不合法的返回值
|
||||||
|
onInvalidReturn?: Level;
|
||||||
|
// 不能为解构赋值
|
||||||
|
onInvalidDestructuring?: Level;
|
||||||
|
// 需要判断Promise
|
||||||
|
onNeedPromiseCheck?: Level;
|
||||||
|
}
|
||||||
// 触发器配置
|
// 触发器配置
|
||||||
trigger?: {
|
trigger?: {
|
||||||
// 返回值为字面量1
|
// 返回值为字面量1
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ import { createProjectProgram } from './ts-utils';
|
||||||
import { CheckerDef, CheckerInfo } from '../types';
|
import { CheckerDef, CheckerInfo } from '../types';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import { debounce, random } from 'lodash';
|
import { debounce, random } from 'lodash';
|
||||||
|
import { getLevel } from './oakConfig';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 记录主文件当前的checker程序
|
* 记录主文件当前的checker程序
|
||||||
|
|
@ -747,7 +748,7 @@ export const checkChecker = (
|
||||||
child.getEnd(),
|
child.getEnd(),
|
||||||
'checker.invalidReturn',
|
'checker.invalidReturn',
|
||||||
'checker应该返回执行链或者结果',
|
'checker应该返回执行链或者结果',
|
||||||
vscode.DiagnosticSeverity.Warning
|
getLevel('checker.onInvalidReturn')
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
// 如果返回值是一个函数调用,继续递归
|
// 如果返回值是一个函数调用,继续递归
|
||||||
|
|
@ -951,7 +952,7 @@ const handleVariable = (
|
||||||
node.getEnd(),
|
node.getEnd(),
|
||||||
'checker.invalidDestruct',
|
'checker.invalidDestruct',
|
||||||
'Checker中的context调用不能是解构赋值',
|
'Checker中的context调用不能是解构赋值',
|
||||||
vscode.DiagnosticSeverity.Error
|
getLevel('checker.onInvalidDestructuring')
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
|
|
@ -993,7 +994,7 @@ const handleVariable = (
|
||||||
node.getEnd(),
|
node.getEnd(),
|
||||||
'checker.invalidPromise',
|
'checker.invalidPromise',
|
||||||
'context调用需要判断是否为Promise',
|
'context调用需要判断是否为Promise',
|
||||||
vscode.DiagnosticSeverity.Error
|
getLevel("checker.onNeedPromiseCheck")
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,11 @@ import * as vscode from 'vscode';
|
||||||
|
|
||||||
export const defaultConfig: OakConfiog = {
|
export const defaultConfig: OakConfiog = {
|
||||||
projectDir: './',
|
projectDir: './',
|
||||||
|
checker: {
|
||||||
|
onInvalidReturn: "error",
|
||||||
|
onInvalidDestructuring: "error",
|
||||||
|
onNeedPromiseCheck: "error",
|
||||||
|
},
|
||||||
trigger: {
|
trigger: {
|
||||||
onReturnLiteral: 'warn',
|
onReturnLiteral: 'warn',
|
||||||
onNoAsyncFn: 'error',
|
onNoAsyncFn: 'error',
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue