-
Notifications
You must be signed in to change notification settings - Fork 0
/
types.ts
161 lines (152 loc) · 3.71 KB
/
types.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
export type OccurrenceType = 'internationalized' | 'not-internationalized';
/**
* The occurrence can have two types internationalized and non-internationalized.
* The non-internationalized occurrence represents what is identified as wrong by the [no-literal-string](https://github.com/victorsoares96/eslint-plugin-react-intl-universal) rule.
* The internationalized occurrence represents the pieces of code that match `intl.get` or `intl.getHTML`
*/
export type Occurrence = {
/**
* Indicates if the occurrence type is internationalized or not.
* @see {@link OccurrenceType}
*/
type: OccurrenceType;
/**
* The message returned by the rule.
*/
message: string;
/**
* The line number of the occurrence.
*/
line: number;
/**
* The end line number of the occurrence.
*/
endLine: number;
/**
* The column number of the occurrence.
*/
column: number;
/**
* The end column number of the occurrence.
*/
endColumn: number;
};
export type Result = {
/**
* Path of the processed file.
* @example 'src/components/App.tsx'
*/
filePath: string;
/**
* List of internationalized(or not) occurrences found by the analysis.
* @see {@link Occurrence}
*/
occurrences: Array<Occurrence>;
/**
* Number of occurrences of non-internationalized strings.
*/
notInternationalizedCount: number;
/**
* Number of occurrences of internationalized strings.
*/
internationalizedCount: number;
/**
* Percentage of occurrences of internationalized strings.
*/
percentage: number;
/**
* Source code of the processed file.
* @example 'import React from \'react\';\nimport { IntlProvider } from \'react-intl\';\nimport messages from \'./messages.json\';\n\nconst App = () => (\n <IntlProvider locale="en" messages={messages}>\n <div>Hello World</div>\n </IntlProvider>\n);\n\nexport default App;'
*/
source?: string;
};
export type Results = {
/**
* Number of occurrences of non-internationalized strings.
*/
notInternationalizedCount: number;
/**
* Number of occurrences of internationalized strings.
*/
internationalizedCount: number;
/**
* Percentage of occurrences of internationalized strings.
*/
percentage: number;
/**
* Detailed result of the analysis performed on each file.
*/
results: Array<Result>;
};
export type Analyzer = {
[key in
| 'words'
| 'jsx-components'
| 'jsx-attributes'
| 'callees'
| 'object-properties'
| 'class-properties']?: {
include?: string[];
exclude?: string[];
};
} & {
mode?: 'jsx-text-only' | 'jsx-only' | 'all';
message?: string;
'should-validate-template'?: boolean;
};
export type Template = {
title: string;
};
export type ReporterSettings = {
/**
* A list of patterns to ignore.
* @type {string[]}
*/
ignorePatterns: string[];
/**
* Repository extensions to be watched.
* @default ['ts', 'tsx', 'js', 'jsx']
* @type {string[]}
*/
extensions: string[];
/**
* The output directory to the generated report file.
* @default './out'
* @type {string}
*/
outputDir: string;
/**
* The output format.
*/
outputFormat: 'html' | 'xml';
/**
* Whether to print debug information.
* @default false
* @type {boolean}
*/
debug: boolean;
/**
* The i18n analyzer rules settings.
*/
analyzer: Analyzer;
/**
* The intl template settings.
* @type {Template}
*/
template: Template;
};
/**
* Arguments
* --source: The source path to the repository to be analyzed (required)
* --config-file: The path to the config file
*/
export type CLIArguments = {
'--source': string;
'--config-file'?: string;
};
export type ReportOptions = {
/**
* The report title
*/
title: string;
};