eslint-plugin-t
Advanced tools
Comparing version 1.2.1 to 1.3.0
{ | ||
"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 @@ }, |
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
4583
6
129