简体   繁体   中英

eslint error: Unexpected block statement surrounding arrow body

I am getting the following error Unexpected block statement surrounding arrow body when I run this code.

scope.$watch(() => {
            return ngModel.$viewValue;
          }, val => {
            if (ngModel.$isEmpty(val) && ngModel.$dirty) {
              scope.clearInputValue();
              // Remove validation errors
              ngModel.$setValidity('maxnum', true);
              ngModel.$setValidity('minnum', true);
              ngModel.$setValidity('maxsize', true);
              ngModel.$setValidity('minsize', true);
              ngModel.$setValidity('accept', true);
            }
          });

A block statement isn't needed in your first function. It is a single expression. If you remove the block statement it should get rid of the warning:

scope.$watch(() => ngModel.$viewValue, val => {
            if (ngModel.$isEmpty(val) && ngModel.$dirty) {
              scope.clearInputValue();
              // Remove validation errors
              ngModel.$setValidity('maxnum', true);
              ngModel.$setValidity('minnum', true);
              ngModel.$setValidity('maxsize', true);
              ngModel.$setValidity('minsize', true);
              ngModel.$setValidity('accept', true);
            }
          });

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM