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
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;
});
Those wishing to selectively deactivate this rule might be interested in a proposed new option for the no-param-reassign
rule that would allow a "white list" of object names with respect to which parameter reassignment should be ignored.
As @Mathletics suggests, you can disable the rule entirely by adding this to your .eslintrc.json
file:
"rules": {
"no-param-reassign": 0
}
Or you could disable the rule specifically for param properties
"rules": {
"no-param-reassign": [2, { "props": false }]
}
Alternatively, you could disable the rule for that function
/* eslint-disable no-param-reassign */
function (el) {
el.expando = {};
}
/* eslint-enable no-param-reassign */
Or for that line only
function (el) {
el.expando = {}; // eslint-disable-line no-param-reassign
}
You might also check out this blog post on disabling ESLint rules specifically to accommodate AirBnB's style guide.
Following the documentation:
function (el) {
const element = el
element.expando = {}
}
You can use:
(param) => {
const data = Object.assign({}, param);
data.element = 'some value';
}