2017-05-06 02:15:28 +01:00
|
|
|
const prettier = require('prettier');
|
|
|
|
|
|
2020-05-01 18:41:56 -07:00
|
|
|
const prettierOptions = {parser: 'babel'};
|
2017-05-06 02:15:28 +01:00
|
|
|
|
|
|
|
|
// filename serializer that removes the basedir
|
|
|
|
|
module.exports = {
|
|
|
|
|
test: function(val) {
|
|
|
|
|
try {
|
|
|
|
|
return (
|
|
|
|
|
typeof val === 'string' &&
|
|
|
|
|
/function /.test(val) &&
|
|
|
|
|
val !== prettier.format(val, prettierOptions)
|
|
|
|
|
);
|
|
|
|
|
} catch (ex) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
print: function(val, serialize, indent) {
|
|
|
|
|
return serialize(prettier.format(val, prettierOptions));
|
2020-05-01 22:00:44 +01:00
|
|
|
},
|
2017-05-06 02:15:28 +01:00
|
|
|
};
|