Skip to content

Latest commit

 

History

History
316 lines (212 loc) · 4.69 KB

rules.md

File metadata and controls

316 lines (212 loc) · 4.69 KB

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
en:
  models:
    user:
      ...

Starts with en.models.user

models/user.en.yml
👎
ja:
  models:
    user:
      ...

Starts with ja

controllers/admin/accounts_controller.en.yml
👎
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
👎
en:
  models:
    user:
      ...

  foo: ...

en.foo and en.models coexist

A file-scope itself must not have a scalar value

models/user.en.yml
👎
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

master foreign
en:
  title: 'Non zero sum'
  desc: 'A situation in...'
ja:
  title: '非ゼロ和'
  desc: '複数の人が相互...'

Every keys exist on both files. No asymmetric keys

master foreign
👎
en:
  title: 'Non zero sum'
  desc: 'A situation in...'
ja:
  title: '非ゼロ和'
  

Missing ja.desc

master foreign
👎
en:
  title: 'Non zero sum'
  
ja:
  title: '非ゼロ和'
  desc: '複数の人が相互...'

Having the extra ja.desc

Structure must match exactly

→ Ignore violations with !ignore:key

master foreign
👎
en:
  follower_count:
    one: '1 follower'
    other: '%{count} followers'
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

master foreign
en:
  key: '%{alpha} %{beta} %{beta}'
ja:
  key: '%{beta} %{alpha}'

It's insensitive of arguments order and repetition

master foreign
👎
en:
  key: '%{alpha}'
ja:
  key: 'alpha'

No arguments exists in ja.key

master foreign
👎
en:
  key: '%{alpha}'
ja:
  key: '%{gamma}'

A set of arguments is different from master