forked from godaddy/eslint-plugin-i18n-json
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
50 lines (48 loc) · 1.36 KB
/
index.js
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
/* eslint-disable global-require */
module.exports = {
rules: {
'valid-json': require('./src/valid-json'),
'valid-message-syntax': require('./src/valid-message-syntax'),
'identical-keys': require('./src/identical-keys'),
'sorted-keys': require('./src/sorted-keys'),
'identical-placeholders': require('./src/identical-placeholders')
},
processors: {
'.json': {
preprocess: (source, filePath) =>
// augment the json into a comment
// along with the source path :D
// so we can pass it to the rules
// note: due to the spaced comment rule, include
// spaced comments
[`/* ${source.trim()} *//* ${filePath.trim()} */\n`],
// since we only return one line in the preprocess step,
// we only care about the first array of errors
postprocess: ([errors]) => [...errors],
supportsAutofix: true
}
},
configs: {
recommended: {
plugins: ['i18n-json'],
rules: {
'i18n-json/valid-message-syntax': [
2,
{
syntax: 'icu' // default syntax
}
],
'i18n-json/valid-json': 2,
'i18n-json/sorted-keys': [
2,
{
order: 'asc',
indentSpaces: 2
}
],
'i18n-json/identical-keys': 0,
'i18n-json/identical-placeholders': 0
}
}
}
};