eslint-plugin-format-message
Advanced tools
Comparing version 6.2.2 to 6.2.3
# Changelog | ||
## 6.2.3 | ||
Handle rich text parameters in `no-missing-params` rule. | ||
## 6.2.2 | ||
@@ -4,0 +8,0 @@ |
@@ -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" | ||
} |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
66031
26
2174
0
Updatedformat-message@^6.2.3
Updatedformat-message-parse@^6.2.3