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
4
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.2.2 to 6.2.3

lib/util/rich-text-params.js

4

CHANGELOG.md
# Changelog
## 6.2.3
Handle rich text parameters in `no-missing-params` rule.
## 6.2.2

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

23

lib/rules/no-missing-params.js

@@ -5,2 +5,3 @@ 'use strict'

var visitFormatCall = require('../util/visit-format-call')
var richTextParams = require('../util/rich-text-params')

@@ -61,2 +62,4 @@ var validatePath = function (object, path) {

info.patternParams.forEach(function (paramName) {
var isRich = info.isRich && richTextParams.isRichTextParam(paramName)
var paramNameForComparison = isRich ? paramName.name : paramName
var isFound = params.properties.some(function (prop) {

@@ -66,9 +69,19 @@ if (prop.value.type === 'ObjectExpression') {

}
return (
(prop.key.type === 'Identifier' && prop.key.name === paramName) ||
(prop.key.type === 'Literal' && prop.key.value === paramName)
)
var propName
if (prop.key.type === 'Identifier') {
propName = prop.key.name
}
if (prop.key.type === 'Literal') {
propName = prop.key.value
}
return propName === paramNameForComparison
})
if (!isFound) {
context.report(node.arguments[1], 'Pattern requires missing "' + paramName + '" parameter')
var paramType = isRich ? 'rich text ' : ''
context.report(
node.arguments[1],
'Pattern requires missing ' + paramType + '"' + paramName + '" parameter'
)
}

@@ -75,0 +88,0 @@ })

@@ -6,7 +6,4 @@ 'use strict'

var visitEachTranslation = require('../util/visit-each-translation')
var richTextParams = require('../util/rich-text-params')
function isRichTextParam (paramName) {
return typeof paramName === 'object' && paramName.isRich === true
}
module.exports = {

@@ -36,3 +33,3 @@ meta: {

if (translationParams.indexOf(paramName) < 0) {
var paramType = isRichTextParam(paramName) ? 'rich text ' : ''
var paramType = richTextParams.isRichTextParam(paramName) ? 'rich text ' : ''
context.report(

@@ -47,3 +44,3 @@ (node.arguments && node.arguments[0]) || node,

if (patternParams.indexOf(paramName) < 0) {
var paramType = isRichTextParam(paramName) ? 'rich text ' : ''
var paramType = richTextParams.isRichTextParam(paramName) ? 'rich text ' : ''
context.report(

@@ -50,0 +47,0 @@ (node.arguments && node.arguments[0]) || node,

'use strict'
var richTagCache = []
function getRichTag (name) {
var cachedTag = richTagCache.find(function (cacheEntry) {
return cacheEntry.name === name
})
if (cachedTag) return cachedTag
var richTextParams = require('./rich-text-params')
var tag = {
isRich: true,
name: name,
toString: function () { return '<' + name + '>' }
}
richTagCache.push(tag)
return tag
}
module.exports = function getParamsFromPatternAst (ast, isRich) {

@@ -33,3 +19,3 @@ if (!ast || !ast.slice) return []

if (isRichParam) {
name = getRichTag(name)
name = richTextParams.getRichTextParam(name)
}

@@ -36,0 +22,0 @@ if (params.indexOf(name) < 0) params.push(name)

{
"name": "eslint-plugin-format-message",
"version": "6.2.2",
"version": "6.2.3",
"description": "format-message i18n specific rules for ESLint",

@@ -26,6 +26,6 @@ "author": "Andy VanWagoner <andy@vanwago.net>",

"dependencies": {
"format-message": "^6.2.2",
"format-message": "^6.2.3",
"format-message-estree-util": "^6.1.0",
"format-message-generate-id": "^6.2.2",
"format-message-parse": "^6.2.2",
"format-message-generate-id": "^6.2.3",
"format-message-parse": "^6.2.3",
"lookup-closest-locale": "^6.2.0"

@@ -36,3 +36,3 @@ },

},
"gitHead": "2ef1e701daa61ca6008651ced62d9ded8c127c0e"
"gitHead": "7747f5533981f7a1a3cc83714e8ac02bafd9d8c4"
}
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