@fimbul/wotan
- Version 0.24.0
- Published
- 432 kB
- 20 dependencies
- Apache-2.0 license
Install
npm i @fimbul/wotan
yarn add @fimbul/wotan
pnpm add @fimbul/wotan
Overview
Pluggable TypeScript and JavaScript linter
Index
Variables
Functions
Classes
Interfaces
Enums
Type Aliases
Namespaces
Variables
variable CONFIG_EXTENSIONS
const CONFIG_EXTENSIONS: string[];
variable CONFIG_FILENAMES
const CONFIG_FILENAMES: string[];
variable GLOBAL_OPTIONS_SPEC
const GLOBAL_OPTIONS_SPEC: { modules: OptionParser.ParseFunction<readonly string[]>; config: OptionParser.ParseFunction<string | undefined>; files: OptionParser.ParseFunction<readonly string[]>; exclude: OptionParser.ParseFunction<readonly string[]>; project: OptionParser.ParseFunction<readonly string[]>; references: OptionParser.ParseFunction<boolean>; cache: OptionParser.ParseFunction<boolean>; formatter: OptionParser.ParseFunction<string | undefined>; fix: OptionParser.ParseFunction<number | boolean>; extensions: OptionParser.ParseFunction<string[] | undefined>; reportUselessDirectives: OptionParser.ParseFunction<boolean | Severity>;};
variable LINE_SWITCH_REGEX
const LINE_SWITCH_REGEX: RegExp;
Functions
function applyFixes
applyFixes: (source: string, fixes: Fix[]) => FixResult;
Tries to apply all fixes. The replacements of all fixes are sorted by index ascending. They are then applied in order. If a replacement overlaps (or touches) the range of the previous replacement, the process rolls back to the state before the first replacement of the offending fix was applied. The replacements of this fix are not applied again. At least one fix will be applied.
function createBaseline
createBaseline: (summary: FileSummary) => string;
function createCoreModule
createCoreModule: (globalOptions: GlobalOptions) => ContainerModule;
function createDefaultModule
createDefaultModule: () => ContainerModule;
function isCodeLine
isCodeLine: (line: string) => boolean;
function parseGlobalOptions
parseGlobalOptions: (options: GlobalOptions | undefined) => ParsedGlobalOptions;
Classes
class CachedFileSystem
class CachedFileSystem {}
constructor
constructor(fs: FileSystem, cache: CacheFactory);
property realpath
realpath: (file: string) => string;
method createDirectory
createDirectory: (dir: string) => void;
method getKind
getKind: (file: string) => FileKind;
method isDirectory
isDirectory: (dir: string) => boolean;
method isFile
isFile: (file: string) => boolean;
method readDirectory
readDirectory: (dir: string) => { kind: FileKind; name: string }[];
method readFile
readFile: (file: string) => string;
method remove
remove: (file: string) => void;
method writeFile
writeFile: (file: string, content: string) => void;
class ConfigurationManager
class ConfigurationManager {}
constructor
constructor( directories: DirectoryService, configProvider: ConfigurationProvider, fs: CachedFileSystem, cache: CacheFactory);
method find
find: (file: string) => Configuration | undefined;
Load the configuration for the specified file.
method findPath
findPath: (file: string) => string | undefined;
Look up the location of the configuration file for the specified file name.
method getProcessor
getProcessor: (config: Configuration, fileName: string) => string | undefined;
Get the processor configuration for a given file.
method getSettings
getSettings: (config: Configuration, fileName: string) => Settings;
Get the settings for a given file.
method load
load: (fileName: string) => Configuration;
Load a configuration from a resolved path using the ConfigurationProvider, recursively resolving and loading base configs.
method loadLocalOrResolved
loadLocalOrResolved: (pathOrName: string, basedir?: string) => Configuration;
Load the given config from a local file if it exists or from the resolved path otherwise
method reduce
reduce: ( config: Configuration, file: string) => ReducedConfiguration | undefined;
Collects all matching configuration options for the given file. Flattens all base configs and matches overrides. Returns
undefined
if the file is excluded in one of the configuraton files.
method resolve
resolve: (name: string, basedir: string) => string;
Resolve a configuration name to it's absolute path.
Parameter name
name of a builtin config - package name in
node_modules
or a submodule thereof - absolute path - relative path starting with./
or../
class ConsoleMessageHandler
class ConsoleMessageHandler implements MessageHandler {}
class ContentHasher
class ContentHasher implements ContentId {}
method forFile
forFile: (fileName: string, host: ContentIdHost) => string;
class DefaultBuiltinResolver
class DefaultBuiltinResolver implements BuiltinResolver {}
constructor
constructor(resolver: Resolver);
method resolveConfig
resolveConfig: (name: string) => string;
method resolveFormatter
resolveFormatter: (name: string) => string;
method resolveRule
resolveRule: (name: string) => string;
class DefaultCacheFactory
class DefaultCacheFactory implements CacheFactory {}
method create
create: { <K extends object, V = any>(weak: true): Cache<K, V>; <K = any, V = any>(weak?: false): Cache<K, V>;};
class DefaultConfigurationProvider
class DefaultConfigurationProvider implements ConfigurationProvider {}
constructor
constructor( fs: CachedFileSystem, resolver: Resolver, builtinResolver: BuiltinResolver, cache: CacheFactory);
method find
find: (fileToLint: string) => string | undefined;
method load
load: (filename: string, context: LoadConfigurationContext) => Configuration;
method parse
parse: ( raw: RawConfiguration, filename: string, context: LoadConfigurationContext) => Configuration;
method read
read: (filename: string) => RawConfiguration;
method resolve
resolve: (name: string, basedir: string) => string;
class DefaultDeprecationHandler
class DefaultDeprecationHandler implements DeprecationHandler {}
constructor
constructor(logger: MessageHandler);
method handle
handle: (target: DeprecationTarget, name: string, text?: string) => void;
class DefaultFileFilterFactory
class DefaultFileFilterFactory implements FileFilterFactory {}
method create
create: (context: FileFilterContext) => DefaultFileFilter;
class DefaultLineSwitchParser
class DefaultLineSwitchParser implements LineSwitchParser {}
method parse
parse: (context: LineSwitchParserContext) => RawLineSwitch[];
class DefaultStatePersistence
class DefaultStatePersistence implements StatePersistence {}
constructor
constructor(fs: CachedFileSystem);
method loadState
loadState: (project: string) => StaticProgramState | undefined;
method saveState
saveState: (project: string, state: StaticProgramState) => void;
class DependencyResolverFactory
class DependencyResolverFactory {}
method create
create: ( host: DependencyResolverHost, program: ts.Program) => DependencyResolver;
class FormatterLoader
class FormatterLoader {}
constructor
constructor(host: FormatterLoaderHost, directories: DirectoryService);
method loadFormatter
loadFormatter: (name: string) => FormatterConstructor;
class LineSwitchFilterFactory
class LineSwitchFilterFactory implements FindingFilterFactory {}
constructor
constructor(parser: LineSwitchParser);
method create
create: (context: FindingFilterContext) => FindingFilter;
method getDisabledRanges
getDisabledRanges: ( context: FindingFilterContext) => Map<string, ts.TextRange[]>;
class Linter
class Linter {}
constructor
constructor( ruleLoader: RuleLoader, logger: MessageHandler, deprecationHandler: DeprecationHandler, filterFactory: FindingFilterFactory);
method lintAndFix
lintAndFix: ( file: ts.SourceFile, content: string, config: EffectiveConfiguration, updateFile: UpdateFileCallback, iterations?: number, programFactory?: ProgramFactory, processor?: AbstractProcessor, options?: LinterOptions, findings?: readonly Finding[]) => LintAndFixFileResult;
method lintFile
lintFile: ( file: ts.SourceFile, config: EffectiveConfiguration, programOrFactory?: ProgramFactory | ts.Program, options?: LinterOptions) => ReadonlyArray<Finding>;
class NodeDirectoryService
class NodeDirectoryService implements DirectoryService {}
method getCurrentDirectory
getCurrentDirectory: () => string;
method getHomeDirectory
getHomeDirectory: () => string;
class NodeFileSystem
class NodeFileSystem implements FileSystem {}
constructor
constructor(logger: MessageHandler);
method createDirectory
createDirectory: (dir: string) => void;
method deleteFile
deleteFile: (path: string) => void;
method normalizePath
static normalizePath: (path: string) => string;
method readDirectory
readDirectory: (dir: string) => Array<string | Dirent>;
method readFile
readFile: (file: string) => string;
method realpath
realpath: (path: string) => string;
method stat
stat: (path: string) => Stats;
method writeFile
writeFile: (file: string, content: string) => void;
class NodeFormatterLoader
class NodeFormatterLoader implements FormatterLoaderHost {}
constructor
constructor(resolver: Resolver, builtinResolver: BuiltinResolver);
method loadCoreFormatter
loadCoreFormatter: (name: string) => FormatterConstructor | undefined;
method loadCustomFormatter
loadCustomFormatter: ( name: string, basedir: string) => FormatterConstructor | undefined;
class NodeResolver
class NodeResolver implements Resolver {}
constructor
constructor(fs: CachedFileSystem, directories: DirectoryService);
method getDefaultExtensions
getDefaultExtensions: () => readonly string[];
method require
require: (id: string, options?: { cache?: boolean }) => any;
method resolve
resolve: ( id: string, basedir?: string, extensions?: readonly string[], paths?: ReadonlyArray<string>) => string;
class NodeRuleLoader
class NodeRuleLoader implements RuleLoaderHost {}
constructor
constructor(builtinResolver: BuiltinResolver, resolver: Resolver);
method loadCoreRule
loadCoreRule: (name: string) => RuleConstructor | undefined;
method loadCustomRule
loadCustomRule: (name: string, directory: string) => RuleConstructor | undefined;
class ProcessorLoader
class ProcessorLoader {}
constructor
constructor(resolver: Resolver, cache: CacheFactory);
method loadProcessor
loadProcessor: (path: string) => ProcessorConstructor;
class ProgramStateFactory
class ProgramStateFactory {}
constructor
constructor( resolverFactory: DependencyResolverFactory, statePersistence: StatePersistence, contentId: ContentId);
method create
create: ( program: ts.Program, host: ProgramStateHost & DependencyResolverHost, tsconfigPath: string) => ProgramStateImpl;
class RuleLoader
class RuleLoader {}
constructor
constructor(host: RuleLoaderHost, logger: MessageHandler, cache: CacheFactory);
method loadRule
loadRule: ( name: string, directories: ReadonlyArray<string> | undefined) => RuleConstructor | undefined;
class Runner
class Runner {}
constructor
constructor( fs: CachedFileSystem, configManager: ConfigurationManager, linter: Linter, processorLoader: ProcessorLoader, directories: DirectoryService, logger: MessageHandler, filterFactory: FileFilterFactory, programStateFactory: ProgramStateFactory);
method lintCollection
lintCollection: (options: LintOptions) => LintResult;
Interfaces
interface DependencyResolver
interface DependencyResolver {}
method getDependencies
getDependencies: ( fileName: string) => ReadonlyMap<string, null | readonly string[]>;
method getFilesAffectingGlobalScope
getFilesAffectingGlobalScope: () => readonly string[];
method update
update: (program: ts.Program, updatedFile: string) => void;
interface DirectoryEntryWithKind
interface DirectoryEntryWithKind {}
interface FixResult
interface FixResult {}
interface LinterOptions
interface LinterOptions {}
property reportUselessDirectives
reportUselessDirectives?: Severity;
interface LintOptions
interface LintOptions {}
property cache
cache: boolean;
property config
config: string | undefined;
property exclude
exclude: ReadonlyArray<string>;
property extensions
extensions: ReadonlyArray<string> | undefined;
property files
files: ReadonlyArray<string>;
property fix
fix: boolean | number;
property project
project: ReadonlyArray<string>;
property references
references: boolean;
property reportUselessDirectives
reportUselessDirectives: Severity | boolean | undefined;
interface ParsedGlobalOptions
interface ParsedGlobalOptions extends LintOptions {}
interface ProgramFactory
interface ProgramFactory {}
This factory is used to lazily create or update the Program only when necessary.
method getCompilerOptions
getCompilerOptions: () => ts.CompilerOptions;
Get the CompilerOptions used to create the Program.
method getProgram
getProgram: () => ts.Program;
This method is called to retrieve the Program on the first use. It should create or update the Program if necessary.
interface ProgramState
interface ProgramState {}
method getUpToDateResult
getUpToDateResult: ( fileName: string, configHash: string) => readonly Finding[] | undefined;
method save
save: () => void;
method setFileResult
setFileResult: ( fileName: string, configHash: string, result: readonly Finding[]) => void;
method update
update: (program: ts.Program, updatedFile: string) => void;
interface RawConfiguration
interface RawConfiguration {}
property aliases
aliases?: RawConfiguration.AliasMap;
property exclude
exclude?: string | ReadonlyArray<string>;
property extends
extends?: string | ReadonlyArray<string>;
property overrides
overrides?: ReadonlyArray<RawConfiguration.Override>;
property processor
processor?: string | null | false;
property rules
rules?: RawConfiguration.RuleMap;
property rulesDirectories
rulesDirectories?: RawConfiguration.RulesDirectoryMap;
property settings
settings?: RawConfiguration.SettingsMap;
Enums
enum FileKind
enum FileKind { NonExistent = 0, File = 1, Directory = 2, Other = 3,}
member Directory
Directory = 2
member File
File = 1
member NonExistent
NonExistent = 0
member Other
Other = 3
Type Aliases
type DependencyResolverHost
type DependencyResolverHost = Required< Pick<ts.CompilerHost, 'resolveModuleNames'>> & { useSourceOfProjectReferenceRedirect?(): boolean;};
type ProgramStateHost
type ProgramStateHost = Pick<ts.CompilerHost, 'useCaseSensitiveFileNames'>;
type UpdateFileCallback
type UpdateFileCallback = ( content: string, range: ts.TextChangeRange) => ts.SourceFile | undefined;
Creates a new SourceFile from the updated source.
Returns
the new
SourceFile
on success orundefined
to roll back the latest set of changes.
Namespaces
namespace OptionParser
namespace OptionParser {}
function parse
parse: <T extends Record<string, ParseFunction<any>>>( options: Record<string, any> | undefined, specs: T, config: ParseConfig) => ParsedOptions<T>;
interface ParseConfig
interface ParseConfig {}
property context
context: string;
property exhaustive
exhaustive?: boolean;
property validate
validate?: boolean;
type MismatchCallback
type MismatchCallback = (type: string) => void;
type ParsedOptions
type ParsedOptions<T extends Record<string, ParseFunction<any>>> = { [K in keyof T]: ReturnType<T[K]>;};
type ParseFunction
type ParseFunction<T> = (value: any, report: MismatchCallback) => T;
namespace OptionParser.Factory
namespace OptionParser.Factory {}
function parsePrimitive
parsePrimitive: <T extends PrimitiveName[]>( ...types: T) => ParseFunction<PrimitiveMap<T[number]> | undefined>;
function parsePrimitiveOrArray
parsePrimitiveOrArray: <T extends PrimitiveName>( type: T) => ParseFunction<ReadonlyArray<PrimitiveMap<T>> | undefined>;
namespace OptionParser.Transform
namespace OptionParser.Transform {}
function map
map: <T extends readonly U[], U, V>( parseFn: ParseFunction<T>, cb: (item: U) => V) => ParseFunction<{ -readonly [K in keyof T]: V }>;
function noDefault
noDefault: <T>(parseFn: ParseFunction<T>) => ParseFunction<T | undefined>;
function transform
transform: <T, U>( parseFn: ParseFunction<T>, cb: (value: T) => U) => ParseFunction<U>;
function withDefault
withDefault: <T>( parseFn: ParseFunction<T | undefined>, defaultValue: T) => ParseFunction<T>;
namespace RawConfiguration
namespace RawConfiguration {}
interface AliasMap
interface AliasMap {}
index signature
[prefix: string]: | { [name: string]: RawConfiguration.Alias | null | false | string; } | null | false;
interface Override
interface Override {}
interface RuleConfig
interface RuleConfig {}
interface RuleMap
interface RuleMap {}
index signature
[key: string]: RawConfiguration.RuleConfigValue;
interface RulesDirectoryMap
interface RulesDirectoryMap {}
index signature
[prefix: string]: string;
interface SettingsMap
interface SettingsMap {}
index signature
[key: string]: any;
type RuleConfigValue
type RuleConfigValue = RuleSeverity | RuleConfig | null;
type RuleSeverity
type RuleSeverity = 'off' | 'warn' | 'warning' | 'error' | 'suggestion' | 'hint';
Package Files (30)
- index.d.ts
- src/argparse.d.ts
- src/baseline.d.ts
- src/di/core.module.d.ts
- src/di/default.module.d.ts
- src/fix.d.ts
- src/linter.d.ts
- src/optparse.d.ts
- src/runner.d.ts
- src/services/cached-file-system.d.ts
- src/services/configuration-manager.d.ts
- src/services/default/builtin-resolver.d.ts
- src/services/default/cache-factory.d.ts
- src/services/default/configuration-provider.d.ts
- src/services/default/content-hasher.d.ts
- src/services/default/deprecation-handler.d.ts
- src/services/default/directory-service.d.ts
- src/services/default/file-filter.d.ts
- src/services/default/file-system.d.ts
- src/services/default/formatter-loader-host.d.ts
- src/services/default/line-switches.d.ts
- src/services/default/message-handler.d.ts
- src/services/default/resolver.d.ts
- src/services/default/rule-loader-host.d.ts
- src/services/default/state-persistence.d.ts
- src/services/dependency-resolver.d.ts
- src/services/formatter-loader.d.ts
- src/services/processor-loader.d.ts
- src/services/program-state.d.ts
- src/services/rule-loader.d.ts
Dependencies (20)
Dev Dependencies (10)
Peer Dependencies (1)
Badge
To add a badge like this oneto your package's README, use the codes available below.
You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@fimbul/wotan
.
- Markdown[](https://www.jsdocs.io/package/@fimbul/wotan)
- HTML<a href="https://www.jsdocs.io/package/@fimbul/wotan"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
Package analyzed in 4148 ms. - Missing or incorrect documentation? Open an issue for this package.