Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

eslint-plugin-format-message

Package Overview
Dependencies
Maintainers
1
Versions
42
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-plugin-format-message - npm Package Compare versions

Comparing version 6.0.2 to 6.0.3

4

CHANGELOG.md
# Changelog
## 6.0.3
Use `var` declarations for wider compatibility.
## 6.0.0

@@ -4,0 +8,0 @@

32

lib/rules/no-invalid-plural-keyword.js
'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": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc