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

前端 未结 11 729
无人共我
无人共我 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:12

    You can override this rule inside your .eslintrc file and disable it for param properties like this

    {
        "rules": {
            "no-param-reassign": [2, { 
                "props": false
            }]
        },
        "extends": "eslint-config-airbnb"
    }
    

    This way rule is still active but it will not warn for properties. More info: http://eslint.org/docs/rules/no-param-reassign

提交回复
热议问题