How to avoid no-param-reassign when setting a property on a DOM object

前端 未结 11 744
无人共我
无人共我 2020-12-23 15:41

I have a method which\'s main purpose is to set a property on a DOM object

function (el) {
  el.expando = {};
}

I use AirBnB\'s code style

11条回答
  •  醉酒成梦
    2020-12-23 16:24

    You can use methods for updating data. Eg. "res.status(404)" instead of "res.statusCode = 404" I found the solution. https://github.com/eslint/eslint/issues/6505#issuecomment-282325903

    /*eslint no-param-reassign: ["error", { "props": true, "ignorePropertyModificationsFor": ["$scope"] }]*/
    
    app.controller('MyCtrl', function($scope) {
      $scope.something = true;
    });
    

提交回复
热议问题