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

eslint-plugin-t

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-plugin-t - npm Package Compare versions

Comparing version 1.2.1 to 1.3.0

src/helpers/isGlobal.js

2

package.json
{
"name": "eslint-plugin-t",
"version": "1.2.1",
"version": "1.3.0",
"main": "./src/index.js",

@@ -5,0 +5,0 @@ "scripts": {

@@ -0,1 +1,2 @@

const isGlobal = require('./helpers/isGlobal');
const isStringLiteral = require('./helpers/isStringLiteral');

@@ -8,11 +9,3 @@

let { callee } = node;
if (callee.type === 'Identifier' && callee.name === 't') {
let scope = context.getScope();
while (scope && scope.type !== 'global') {
if (scope.set.has('t')) {
// t is not global
return;
}
scope = scope.upper;
}
let checkCallSignature = (expr) => {
let args = node.arguments;

@@ -22,3 +15,3 @@ if (!args || args.length === 0) {

node,
message: 't() must take at least one argument.',
message: `${expr} must take at least one argument.`,
});

@@ -31,4 +24,3 @@ return;

node: arg,
message:
'First argument to t() must be an array literal of length 2.',
message: `First argument to ${expr} must be an array literal of length 2.`,
});

@@ -45,2 +37,17 @@ return;

}
};
if (callee.type === 'Identifier' && callee.name === 't') {
if (isGlobal(context, 't')) {
checkCallSignature('t()');
}
} else if (
callee.type === 'MemberExpression' &&
callee.object.type === 'Identifier' &&
callee.object.name === 't' &&
callee.property.type === 'Identifier' &&
callee.property.name === 'frag'
) {
if (isGlobal(context, 't')) {
checkCallSignature('t.frag()');
}
}

@@ -47,0 +54,0 @@ },

@@ -0,1 +1,2 @@

const isGlobal = require('./helpers/isGlobal');
const isStringLiteral = require('./helpers/isStringLiteral');

@@ -8,11 +9,3 @@

let { callee } = node;
if (callee.type === 'Identifier' && callee.name === 't') {
let scope = context.getScope();
while (scope && scope.type !== 'global') {
if (scope.set.has('t')) {
// t is not global
return;
}
scope = scope.upper;
}
let checkCallSignature = (expr) => {
let args = node.arguments;

@@ -22,3 +15,3 @@ if (!args || args.length === 0) {

node,
message: 't() must take at least one argument.',
message: `${expr} must take at least one argument.`,
});

@@ -31,5 +24,20 @@ return;

node: arg,
message: 'First argument to t() must be a string literal.',
message: `First argument to ${expr} must be a string literal.`,
});
}
};
if (callee.type === 'Identifier' && callee.name === 't') {
if (isGlobal(context, 't')) {
checkCallSignature('t()');
}
} else if (
callee.type === 'MemberExpression' &&
callee.object.type === 'Identifier' &&
callee.object.name === 't' &&
callee.property.type === 'Identifier' &&
callee.property.name === 'frag'
) {
if (isGlobal(context, 't')) {
checkCallSignature('t.frag()');
}
}

@@ -36,0 +44,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