Nice way to get rid of no-unused-expressions linter error with chai

后端 未结 6 1757
长发绾君心
长发绾君心 2020-12-09 07:12

In my Chai tests I often find myself wanting to use their assertions that are something like .to.be.empty, .to.be.true e.t.c., because I find them

6条回答
  •  醉梦人生
    2020-12-09 08:00

    I had this issue with tslint and solved it by simply moving the rule for unused expressions down one level. My ./tslint.json has all the other rules I care about, then I made ./src/tslint.json that just looks like

    {
        "rules": {
            "no-unused-expression": true
        },
        "extends": "../tslint.json"
    }
    

    tslint automatically checks for a config file in every level as it descends the tree (with --project or using the VSCode extension) so this means that my tests (under ./test/) have all the other rules applied, but no-unused-expression only applies to files under ./src/.

提交回复
热议问题