本文整理汇总了TypeScript中tslint.lint函数的典型用法代码示例。如果您正苦于以下问题:TypeScript lint函数的具体用法?TypeScript lint怎么用?TypeScript lint使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了lint函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: lint
function lint() {
var session = IDE.sessionTabView.getActiveSession();
var options = {
formatter: "json",
configuration: getLintConfig(),
rulesDirectory: "customRules/",
formattersDirectory: "customFormatters/"
};
if (session && session.isTypeScript()) {
var Linter = require("tslint");
var ll = new Linter(session.name, session.content, options);
var result:Array<any> = JSON.parse(ll.lint().output);
// console.log(result);
// IDE.console.log(JSON.stringify(result,null,4));
var r:Cats.FileRange[] = [];
result.forEach((msg) => {
var item:Cats.FileRange = {
fileName : msg.name,
message: msg.failure,
severity: Cats.Severity.Info,
range: convertPos(msg)
};
r.push(item)
});
session.setErrors(r);
IDE.problemResult.setData(r);
}
}
示例2: callback
fs.readFile(params.filePath, 'utf8', (err, contents) => {
if (err) {
callback(err, null);
return;
}
let linter = new Linter(params.filePath, contents, params.options);
let result = linter.lint();
result.output = result.output.split('\n').reduce((memo: string[], line: string) => {
if (line !== '') {
memo.push(line + '\n');
}
return memo;
}, []).join('');
callback(err, result);
});
示例3: Linter
cb: (sf => {
const filePath = sf.fileName;
const contents = sf.getFullText();
const linter = new Linter(filePath, contents, linterConfig.linterConfig, lintprogram);
const lintResult = linter.lint();
filePaths.push(filePath);
if (lintResult.failureCount) {
// console.log(linterMessagePrefix, filePath, lintResult.failureCount); // DEBUG
errors = errors.concat(
lintResult.failures.map(
le => lintErrorToCodeError(le, contents)
)
);
}
})
示例4: lint
public lint(path: string) {
var contents = fs.readFileSync(path, "utf8");
var linter = new Linter(path, contents, this.options);
var result = linter.lint();
return result.output;
}
示例5: TsLinter
const results = filePaths.map((filePath, index) => {
const content = contents[index];
const linter = new TsLinter(filePath, content, options);
return linter.lint();
});