You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I enter the following code into the Prettier playground it formats correctly:
Click to expand
"use strict";varPLUGIN_NAME="groupRequiredTest";Plugin.prototype={/** * Returns the plugin instance's options object. * * @returns {object} */getOptions: function(){returnthis.options;},/** * Destroys the plugin instance. * * @returns {jQuery} */destroy: function(){// Reset each element's 'required' attribute.this.$els.each(function(){varorigRequired=$(this).data("origRequired."+PLUGIN_NAME);if(origRequired){$(this).attr("required",origRequired);}else{$(this).removeAttr("required");}});// Remove all events and data added by the plugin.returnthis.$els.off("."+this.options.namespace).removeData([PLUGIN_NAME+".plugin","origRequired."+PLUGIN_NAME]);}};/** * * @param {jQuery} $elements * @param {Object} options * @constructor */functionPlugin($elements,options){this.$els=$elements;this.options=$.extend({},$.fn[PLUGIN_NAME].defaults,options);var_this=this;this.$els.each(function(){$(this).data("origRequired."+PLUGIN_NAME,$(this).attr("required"));setRequired.call(_this,$(this));}).on("input."+this.options.namespace+" change."+this.options.namespace,function(event){setRequired.call(_this,$(this),event);}).on("invalid."+this.options.namespace,function(event){varerrorMessage=_this.options.errorMessage;if($.isFunction(errorMessage)){errorMessage=errorMessage.call(this,_this,event);}this.setCustomValidity(errorMessage);});}/** * Sets the required property of all other elements in the group based on the value of the given * element and the custom required filter function. * * Used as a handler for the 'input' event AND to initialise the plugin. * * @param {jQuery} $element * @param {jQuery.Event} [event] */functionsetRequired($element,event){/* jshint validthis: true */varrequired=true;this.$els.each(function(){this.setCustomValidity("");required=required&&!this.checkValidity();});if(this.options.requiredFilter){required=this.options.requiredFilter.call($element,required,this,event);}this.$els.prop("required",required);}$.fn[PLUGIN_NAME]=function(options){varplugin=this.data(PLUGIN_NAME+".plugin");if(!plugin){plugin=newPlugin(this,options);this.data(PLUGIN_NAME+".plugin",plugin);}if($.isFunction(Plugin.prototype[options])){returnplugin[options].apply(plugin,Array.prototype.slice.call(arguments,1));}returnthis;};$.fn[PLUGIN_NAME].defaults={namespace: "groupRequired",requiredFilter: null,errorMessage: ""};
However, when I run precise-commits it ends up malformed:
Click to expand
"use strict";varPLUGIN_NAME="groupRequired";Plugin.prototype={/** * Returns the plugin instance's options object. * @returns {object} */getOptions: function(){returnthis.options;},/* * Destroys the plugin instance. * * @returns {jQuery} * destroy: function() { // Reset each element's 'required' attribute. this.$els.each(function() { var origRequired = $(this).data( "origRequired." + PLUGIN_NAME ); (origRequired) { $(this).attr("required", origRequired);} else {$(this).removeAttr("required"); ;// Remove all events and data added by the plugin.return this.$els .off("." + this.options.namespace).removeData([PLUGIN_NAME + ".plugin", "origRequired." + PLUGIN_NAME]); }};/** * * @param {jQuery} $elements * @param {Object} options * @constructor */functionPlugin($elements,options){this.$els=$elements;this.options=$.extend({},$.fn[PLUGIN_NAME].defaults,options);var_this=this;this.$els.each(function(){$(this).data("origRequired."+PLUGIN_NAME,$(this).attr("required")setRequired.call(_this,$(this));}).on("input."+this.options.namespace+" change."+this.options.namespace,functi(event){setRequired.call(_this,$(this),event);}).on("invalid." +this.options.namespace,function(event){varerrorMessage=_this.options.errorMessage;if($.isFunction(errorMessage)){errorMessage=errorMessage.call(this,_this,event);}this.setCustomValidity(errorMessage);});}/** * Sets the required property of all other elements in the group based on the value of the given * element and the custom required filter function. * * Used as a handler for the 'input' event AND to initialise the plugin. * * @param {jQuery} $element * @param {jQuery.Event} [event] */functionsetRequired($element,event){/* jshint validthis: true */varrequired=true;this.$els.each(function(){this.setCustomValidity("");required=required&&!this.checkValidity();});if(this.options.requiredFilter){required=this.options.requiredFilter.call($element,required,this,event);}this.$els.prop("required",required);}$.fn[PLUGIN_NAME]=function(options){varplugin=this.data(PLUGIN_NAME+".plugin");if(!plugin){plugin=newPlugin(this,options);this.data(PLUGIN_NAME+".plugin",plugin);}if($.isFunction(Plugin.prototype[options])){returnplugin[options].apply(plugin,Array.prototype.slice.call(arguments,1));}returnthis;};$.fn[PLUGIN_NAME].defaults={namespace: "groupRequired",requiredFilter: null,errorMessage: ""};
I'm aware precise-commits runs on changed lines, so the diff for the file is as follows:
When I enter the following code into the Prettier playground it formats correctly:
Click to expand
Click to expand
The text was updated successfully, but these errors were encountered: