eslint-plugin-format-message
Advanced tools
Comparing version 6.0.2 to 6.0.3
# Changelog | ||
## 6.0.3 | ||
Use `var` declarations for wider compatibility. | ||
## 6.0.0 | ||
@@ -4,0 +8,0 @@ |
'use strict' | ||
const lookupClosestLocale = require('lookup-closest-locale') | ||
const parse = require('format-message-parse') | ||
const visitEachTranslation = require('../util/visit-each-translation') | ||
const locales = require('../../cldr.json').locales | ||
var lookupClosestLocale = require('lookup-closest-locale') | ||
var parse = require('format-message-parse') | ||
var visitEachTranslation = require('../util/visit-each-translation') | ||
var locales = require('../../cldr.json').locales | ||
function getPluralKeywords (ast) { | ||
const keywords = { cardinal: new Set(), ordinal: new Set() } | ||
var keywords = { cardinal: new Set(), ordinal: new Set() } | ||
function search (element) { | ||
if (!Array.isArray(element)) return | ||
const children = element[3] || element[2] | ||
var children = element[3] || element[2] | ||
if (typeof children !== 'object') return | ||
const type = element[1] | ||
var type = element[1] | ||
Object.keys(children).forEach(key => { | ||
@@ -29,11 +29,11 @@ if (type === 'selectordinal') keywords.ordinal.add(key) | ||
create: function (context) { | ||
const settings = context.settings['format-message'] || {} | ||
const sourceLocale = settings.sourceLocale || 'en' | ||
const visitedNodes = new Set() | ||
var settings = context.settings['format-message'] || {} | ||
var sourceLocale = settings.sourceLocale || 'en' | ||
var visitedNodes = new Set() | ||
return visitEachTranslation(context, function ({ id, node, patternAst, locale, translation }) { | ||
if (!visitedNodes.has(node) && patternAst) { | ||
visitedNodes.add(node) | ||
const { cardinal, ordinal } = getPluralKeywords(patternAst) | ||
const closest = lookupClosestLocale(sourceLocale, locales) | ||
const rules = closest && locales[closest] && locales[closest].plurals | ||
var { cardinal, ordinal } = getPluralKeywords(patternAst) | ||
var closest = lookupClosestLocale(sourceLocale, locales) | ||
var rules = closest && locales[closest] && locales[closest].plurals | ||
cardinal.forEach(rule => { | ||
@@ -53,5 +53,5 @@ if (!rules || rule === 'other' || rule[0] === '=') return | ||
try { | ||
const { cardinal, ordinal } = getPluralKeywords(parse(translation)) | ||
const closest = lookupClosestLocale(locale, locales) | ||
const rules = closest && locales[closest] && locales[closest].plurals | ||
({ cardinal, ordinal } = getPluralKeywords(parse(translation))) | ||
closest = lookupClosestLocale(locale, locales) | ||
rules = closest && locales[closest] && locales[closest].plurals | ||
cardinal.forEach(rule => { | ||
@@ -58,0 +58,0 @@ if (!rules || rule === 'other' || rule[0] === '=') return |
'use strict' | ||
const lookupClosestLocale = require('lookup-closest-locale') | ||
const parse = require('format-message-parse') | ||
const visitEachTranslation = require('../util/visit-each-translation') | ||
const locales = require('../../cldr.json').locales | ||
var lookupClosestLocale = require('lookup-closest-locale') | ||
var parse = require('format-message-parse') | ||
var visitEachTranslation = require('../util/visit-each-translation') | ||
var locales = require('../../cldr.json').locales | ||
function getPlurals (ast) { | ||
const plurals = [] | ||
var plurals = [] | ||
function search (element) { | ||
if (!Array.isArray(element)) return | ||
const children = element[3] || element[2] | ||
var children = element[3] || element[2] | ||
if (typeof children !== 'object') return | ||
const type = element[1] | ||
var type = element[1] | ||
if (type === 'selectordinal' || type === 'plural') { | ||
@@ -34,10 +34,10 @@ plurals.push({ | ||
create: function (context) { | ||
const settings = context.settings['format-message'] || {} | ||
const sourceLocale = settings.sourceLocale || 'en' | ||
const visitedNodes = new Set() | ||
var settings = context.settings['format-message'] || {} | ||
var sourceLocale = settings.sourceLocale || 'en' | ||
var visitedNodes = new Set() | ||
return visitEachTranslation(context, function ({ id, node, patternAst, locale, translation }) { | ||
if (!visitedNodes.has(node) && patternAst) { | ||
visitedNodes.add(node) | ||
const closest = lookupClosestLocale(sourceLocale, locales) | ||
const rules = closest && locales[closest] && locales[closest].plurals | ||
var closest = lookupClosestLocale(sourceLocale, locales) | ||
var rules = closest && locales[closest] && locales[closest].plurals | ||
getPlurals(patternAst).forEach(({ id, type, keywords }) => { | ||
@@ -53,4 +53,4 @@ if (!rules || !rules[type]) return | ||
try { | ||
const closest = lookupClosestLocale(locale, locales) | ||
const rules = closest && locales[closest] && locales[closest].plurals | ||
closest = lookupClosestLocale(locale, locales) | ||
rules = closest && locales[closest] && locales[closest].plurals | ||
getPlurals(parse(translation)).forEach(({ id, type, keywords }) => { | ||
@@ -57,0 +57,0 @@ if (!rules || !rules[type]) return |
{ | ||
"name": "eslint-plugin-format-message", | ||
"version": "6.0.2", | ||
"version": "6.0.3", | ||
"description": "format-message i18n specific rules for ESLint", | ||
@@ -26,7 +26,7 @@ "author": "Andy VanWagoner <andy@thetalecrafter.com> (https://thetalecrafter.com/)", | ||
"dependencies": { | ||
"format-message": "^6.0.1", | ||
"format-message": "^6.0.3", | ||
"format-message-estree-util": "^6.0.0", | ||
"format-message-generate-id": "^6.0.2", | ||
"format-message-parse": "^6.0.0", | ||
"lookup-closest-locale": "^6.0.0" | ||
"format-message-generate-id": "^6.0.3", | ||
"format-message-parse": "^6.0.3", | ||
"lookup-closest-locale": "^6.0.3" | ||
}, | ||
@@ -33,0 +33,0 @@ "peerDependencies": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
63684
Updatedformat-message@^6.0.3
Updatedformat-message-parse@^6.0.3
Updatedlookup-closest-locale@^6.0.3