Skip to content

Commit

Permalink
fix: be less strict with matched languages
Browse files Browse the repository at this point in the history
  • Loading branch information
marionebl committed Feb 14, 2016
1 parent 9790ebc commit dae11d1
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions source/rules/lang.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,17 @@ import franc from 'franc';

export default (parsed, when, value) => {
const negated = when === 'never';
const detected = franc.all(parsed.subject);
const matches = Object.keys(detected).indexOf(value) > -1;
const detected = franc.all(parsed.subject)
.filter(lang => lang[1] >= 0.45)
.map(lang => lang[0]);
const matches = detected.indexOf(value) > -1;

return [
negated ? !matches : matches,
[
'commit',
negated ? 'may not' : 'must',
`be in languague ${value}`
`be in languague "${value}", was one of: ${detected.join(', ')}`
]
.filter(Boolean)
.join(' ')
Expand Down

0 comments on commit dae11d1

Please sign in to comment.