Lint rules
==========
File-scope linter
-----------------
File-scope linter checks consistency between file content and a file path of each file, without comparing with others.
'File-scope' is a sort of namespace that derives from a file path.
For example a file-scope of `models/user.en.yml` is `en.models.user`.
### A file must start with scopes that derive from its file path
|
models/user.en.yml |
โ
|
```yaml
en:
models:
user:
...
```
|
---|
Starts with `en.models.user`
|
|
models/user.en.yml |
๐ |
```yaml
ja:
models:
user:
...
```
|
---|
Starts with `ja`
|
|
controllers/admin/accounts_controller.en.yml |
๐ |
```yaml
en:
controllers:
nimda:
accounts_controller:
...
```
|
---|
Starts with `en.controllers.nimda`
|
### Having extra key at anywhere upper-or-equal level than a file-scope
|
models/user.en.yml |
๐ |
```yaml
en:
models:
user:
...
foo: ...
```
|
---|
`en.foo` and `en.models` coexist
|
### A file-scope itself must not have a scalar value
|
models/user.en.yml |
๐ |
```yaml
en:
models:
user: 'User'
```
|
---|
`user` must be either a mapping or a sequence
|
Symmetry linter
---------------
Symmetry linter compares a pair of files and checks their symmetry.
As a pair, one is 'master' and another is 'foreign'.
If your primary language is English and going to support Japanese as secondary, you may want to lint Japanese (foreign) locale file based on English locale file (master).
### Keys in a foreign file must be exhaustive and exclusive
[โ Justify violations with `!only` or ignore with `!ignore:key`](./tags.md)
|
master |
foreign |
โ
|
```yaml
en:
title: 'Non zero sum'
desc: 'A situation in...'
```
|
```yaml
ja:
title: '้ใผใญๅ'
desc: '่คๆฐใฎไบบใ็ธไบ...'
```
|
---|
Every keys exist on both files. No asymmetric keys
|
|
master |
foreign |
๐ |
```yaml
en:
title: 'Non zero sum'
desc: 'A situation in...'
```
|
```yaml
ja:
title: '้ใผใญๅ'
```
|
---|
Missing `ja.desc`
|
|
master |
foreign |
๐ |
```yaml
en:
title: 'Non zero sum'
```
|
```yaml
ja:
title: '้ใผใญๅ'
desc: '่คๆฐใฎไบบใ็ธไบ...'
```
|
---|
Having the extra `ja.desc`
|
### Structure must match exactly
[โ Ignore violations with `!ignore:key`](./tags.md)
|
master |
foreign |
๐ |
```yaml
en:
follower_count:
one: '1 follower'
other: '%{count} followers'
```
|
```yaml
ja:
follower_count: '%{count} ใใฉใญใฏ'
```
|
---|
`en.follower_count` is a mapping, whereas `ja.follower_count` is a scalar
|
### Interpolation arguments must be exhaustive and exclusive
[โ Ignore violations with `!ignore:args`](./tags.md)
|
master |
foreign |
โ
|
```yaml
en:
key: '%{alpha} %{beta} %{beta}'
```
|
```yaml
ja:
key: '%{beta} %{alpha}'
```
|
---|
It's insensitive of arguments order and repetition
|
|
master |
foreign |
๐ |
```yaml
en:
key: '%{alpha}'
```
|
```yaml
ja:
key: 'alpha'
```
|
---|
No arguments exists in `ja.key`
|
|
master |
foreign |
๐ |
```yaml
en:
key: '%{alpha}'
```
|
```yaml
ja:
key: '%{gamma}'
```
|
---|
A set of arguments is different from master
|