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

eslint-plugin-kolibri

Package Overview
Dependencies
Maintainers
5
Versions
44
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-plugin-kolibri - npm Package Compare versions

Comparing version 0.13.0-dev.7 to 0.13.0-dev.8

lib/rules/vue-no-undefined-string-uses.js

17

lib/rules/vue-no-unused-translations.js

@@ -9,2 +9,3 @@ /**

const get = require('lodash/get');
const utils = require('../utils');

@@ -37,3 +38,7 @@ const constants = require('../constants');

if (node.callee.property.name == $TR_FUNCTION && node.arguments.length) {
node.arguments.forEach(arg => usedStrings.push(arg.value));
node.arguments.forEach(arg => {
if (get(arg, ['value'])) {
usedStrings.push(arg.value);
}
});
}

@@ -48,3 +53,3 @@ },

node.properties.forEach(prop => {
if (prop.value.value) {
if (get(prop, ['value', 'value'])) {
usedStrings.push(prop.value.value);

@@ -58,3 +63,3 @@ }

node.elements.forEach(elem => {
if (elem.value) {
if (get(elem, ['value'])) {
usedStrings.push(elem.value);

@@ -81,3 +86,7 @@ }

if (node.callee.name == $TR_FUNCTION && node.arguments.length) {
node.arguments.forEach(arg => Boolean(arg.value) && usedStrings.push(arg.value));
node.arguments.forEach(arg => {
if (get(arg, ['value'])) {
usedStrings.push(arg.value);
}
});
}

@@ -84,0 +93,0 @@ },

@@ -224,6 +224,21 @@ 'use strict';

node: prop.node,
message: `Unused translation defined for ${prop.node.name}`,
message: `Unused message found in $trs: "${prop.node.name}"`,
});
});
},
/**
* Report uses of undefined strings
*/
reportUseOfUndefinedTranslation(context, definitions, uses) {
const definedStrings = definitions.map(prop => prop.name);
const badAttempts = uses.filter(prop => !definedStrings.includes(prop.value));
badAttempts.forEach(node => {
context.report({
node,
message: `Message not defined in $trs: "${node.value}"`,
});
});
},
};
{
"name": "eslint-plugin-kolibri",
"version": "0.13.0-dev.7",
"version": "0.13.0-dev.8",
"description": "Custom rules.",

@@ -5,0 +5,0 @@ "author": "Learning Equality",

@@ -184,3 +184,3 @@ 'use strict';

{
message: 'Unused translation defined for helloWorld',
message: 'Unused message found in $trs: "helloWorld"',
},

@@ -209,3 +209,3 @@ ],

{
message: 'Unused translation defined for testString',
message: 'Unused message found in $trs: "testString"',
},

@@ -240,3 +240,3 @@ ],

{
message: 'Unused translation defined for unusedLabel',
message: 'Unused message found in $trs: "unusedLabel"',
},

@@ -270,3 +270,3 @@ ],

// in this component would be going unused.
message: 'Unused translation defined for coachLabel',
message: 'Unused message found in $trs: "coachLabel"',
},

@@ -301,3 +301,3 @@ ],

{
message: 'Unused translation defined for unusedLabel',
message: 'Unused message found in $trs: "unusedLabel"',
},

@@ -332,9 +332,9 @@ ],

{
message: 'Unused translation defined for testString',
message: 'Unused message found in $trs: "testString"',
},
{
message: 'Unused translation defined for personLabel',
message: 'Unused message found in $trs: "personLabel"',
},
{
message: 'Unused translation defined for unusedLabel',
message: 'Unused message found in $trs: "unusedLabel"',
},

@@ -383,6 +383,6 @@ ],

{
message: 'Unused translation defined for lesson',
message: 'Unused message found in $trs: "lesson"',
},
{
message: 'Unused translation defined for slideshow',
message: 'Unused message found in $trs: "slideshow"',
},

@@ -411,6 +411,6 @@ ],

{
message: 'Unused translation defined for channel',
message: 'Unused message found in $trs: "channel"',
},
{
message: 'Unused translation defined for exercise',
message: 'Unused message found in $trs: "exercise"',
},

@@ -417,0 +417,0 @@ ],

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