mirror of https://github.com/lukechilds/ava.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
559 B
22 lines
559 B
'use strict';
|
|
|
|
function isRequire(path) {
|
|
return path.isCallExpression() && path.get('callee').isIdentifier() && (path.get('callee').node.name === 'require');
|
|
}
|
|
|
|
module.exports = babel => {
|
|
const t = babel.types;
|
|
|
|
return {
|
|
visitor: {
|
|
CallExpression: path => {
|
|
// skip require calls
|
|
const firstArg = path.get('arguments')[0];
|
|
|
|
if (!isRequire(path) && firstArg && firstArg.isStringLiteral() && !/repeated test/.test(firstArg.node.value)) {
|
|
firstArg.replaceWith(t.stringLiteral(firstArg.node.value.toUpperCase()));
|
|
}
|
|
}
|
|
}
|
|
};
|
|
};
|
|
|