UNPKG

4.12 kBTypeScriptView Raw
1/// <reference types="node" />
2import * as stream from 'stream';
3import * as File from 'vinyl';
4import * as doc from './doc';
5import EditorConfigError = require('./editor-config-error');
6export declare let charsets: {
7 '\u0000\u0000\u00FE\u00FF': string;
8 '\u00EF\u00BB\u00BF': string;
9 '\u00FE\u00FF': string;
10 '\u00FF\u00FE': string;
11 '\u00FF\u00FE\u0000\u0000': string;
12};
13export declare function configure(options: IConfigurationOptions): void;
14export interface IConfigurationOptions {
15 newlines?: string[];
16}
17export interface ISettings {
18 /**
19 * Set to latin1, utf-8, utf-8-bom, utf-16be or utf-16le to control the
20 * character set.
21 */
22 charset?: string;
23 /**
24 * Set to tab or space to use hard tabs or soft tabs respectively.
25 */
26 indent_style?: string;
27 /**
28 * The number of columns used for each indentation level and the width
29 * of soft tabs (when supported). When set to tab, the value of
30 * tab_width (if specified) will be used.
31 */
32 indent_size?: number | string;
33 /**
34 * Number of columns used to represent a tab character. This defaults
35 * to the value of indent_size and doesn't usually need to be specified.
36 */
37 tab_width?: number;
38 /**
39 * Removes any whitespace characters preceding newline characters.
40 */
41 trim_trailing_whitespace?: boolean;
42 /**
43 * Set to lf, cr, or crlf to control how line breaks are represented.
44 */
45 end_of_line?: string;
46 /**
47 * Ensures files ends with a newline.
48 */
49 insert_final_newline?: boolean;
50 /**
51 * Enforces the maximum number of columns you can have in a line.
52 */
53 max_line_length?: number;
54 block_comment?: string;
55 block_comment_start?: string;
56 block_comment_end?: string;
57}
58export interface IEditorConfigLintFile extends File {
59 editorconfig?: IEditorConfigLintResult;
60 contents: Buffer;
61}
62export interface IEditorConfigLintResult {
63 config: ISettings;
64 errors: EditorConfigError[];
65 fixed: boolean;
66}
67export interface IRule {
68 type: string;
69 resolve(settings: ISettings): string | number | boolean;
70}
71export interface ILineRule extends IRule {
72 check(settings: ISettings, line: doc.Line): EditorConfigError;
73 fix(settings: ISettings, line: doc.Line): doc.Line;
74 infer(line: doc.Line): string | number | boolean;
75}
76export interface IDocumentRule extends IRule {
77 check(settings: ISettings, doc: doc.IDocument): EditorConfigError[];
78 fix(settings: ISettings, doc: doc.IDocument): doc.IDocument;
79 infer(doc: doc.IDocument): string | number | boolean;
80}
81export interface ICommandOptions {
82 settings?: ISettings;
83}
84export declare type Command = (options?: ICommandOptions) => NodeJS.ReadWriteStream;
85export declare let ruleNames: string[];
86export interface ICheckCommandOptions extends ICommandOptions {
87 reporter?: (file: IEditorConfigLintFile, error: EditorConfigError) => void;
88}
89export declare function check(options?: ICheckCommandOptions): stream.Transform;
90export declare function fix(options?: ICommandOptions): stream.Transform;
91export interface InferOptions {
92 /**
93 * Shows the tallied score for each setting.
94 */
95 score?: boolean;
96 /**
97 * Exports file as ini file type.
98 */
99 ini?: boolean;
100 /**
101 * Adds root = true to the top of your ini file, if any.
102 */
103 root?: boolean;
104}
105export interface IScoredSetting {
106 [key: string]: {
107 [key: string]: number;
108 };
109}
110export interface IScoredSettings {
111 charset?: IScoredSetting;
112 indent_style?: IScoredSetting;
113 indent_size?: IScoredSetting;
114 trim_trailing_whitespace?: IScoredSetting;
115 end_of_line?: IScoredSetting;
116 insert_final_newline?: IScoredSetting;
117 max_line_length?: number;
118}
119export declare function infer(options?: InferOptions): stream.Transform;
120export interface IOptions extends ICheckCommandOptions {
121 fix?: boolean;
122}
123export default function eclint(options?: IOptions): stream.Transform;