@fimbul/ymir
Advanced tools
Comparing version 0.6.0-dev.20180321 to 0.6.0-dev.20180322
{ | ||
"name": "@fimbul/ymir", | ||
"version": "0.6.0-dev.20180321", | ||
"version": "0.6.0-dev.20180322", | ||
"description": "Core library for the Fimbullinter project", | ||
@@ -5,0 +5,0 @@ "publishConfig": { |
@@ -49,3 +49,3 @@ import 'reflect-metadata'; | ||
readonly deprecated?: boolean | string; | ||
supports?(sourceFile: ts.SourceFile, context: RuleSupportsContext): boolean; | ||
supports?: RuleSupportsPredicate; | ||
new (context: RuleContext): AbstractRule; | ||
@@ -75,2 +75,6 @@ } | ||
export declare type Settings = ReadonlyMap<string, {} | null | undefined>; | ||
export declare function isTypescriptFile(sourceFile: ts.SourceFile): boolean; | ||
export declare function typescriptOnly<T extends typeof AbstractRule>(target: T): void; | ||
export declare function excludeDeclarationFiles<T extends typeof AbstractRule>(target: T): void; | ||
export declare type RuleSupportsPredicate = (sourceFile: ts.SourceFile, context: RuleSupportsContext) => boolean; | ||
export declare abstract class AbstractRule { | ||
@@ -80,3 +84,3 @@ readonly context: RuleContext; | ||
static deprecated: boolean | string; | ||
static supports?: (sourceFile: ts.SourceFile, context: RuleSupportsContext) => boolean; | ||
static supports?: RuleSupportsPredicate; | ||
static validateConfig?(config: any): string[] | string | undefined; | ||
@@ -83,0 +87,0 @@ readonly sourceFile: ts.SourceFile; |
@@ -42,2 +42,19 @@ "use strict"; | ||
exports.TypedRuleContext = TypedRuleContext; | ||
function combinePredicates(existing, predicate) { | ||
if (existing === undefined) | ||
return predicate; | ||
return (sourceFile, context) => predicate(sourceFile, context) && existing(sourceFile, context); | ||
} | ||
function isTypescriptFile(sourceFile) { | ||
return /\.tsx?$/.test(sourceFile.fileName); | ||
} | ||
exports.isTypescriptFile = isTypescriptFile; | ||
function typescriptOnly(target) { | ||
target.supports = combinePredicates(target.supports, isTypescriptFile); | ||
} | ||
exports.typescriptOnly = typescriptOnly; | ||
function excludeDeclarationFiles(target) { | ||
target.supports = combinePredicates(target.supports, (sourceFile) => !sourceFile.isDeclarationFile); | ||
} | ||
exports.excludeDeclarationFiles = excludeDeclarationFiles; | ||
class AbstractRule { | ||
@@ -44,0 +61,0 @@ constructor(context) { |
Sorry, the diff of this file is not supported yet
32298
466