ihordiachenko / eslint-plugin-chai-friendly

Makes eslint friendly towards Chai.js 'expect' and 'should' statements.
MIT License
53 stars 10 forks source link

let's through non-existing statements #19

Open karlismelderis opened 3 years ago

karlismelderis commented 3 years ago

I caught that due to this lint rule setup:

        'chai-friendly/no-unused-expressions': 'error',
        'no-unused-expressions': 'off',

Things like this pass through: .to.be.disabled

Where syntax should be: .to.be.disabled()

As we don't have any plugin that has such .disabled implementation but do have .disabled().

Issue is that Jest just moves on happily and marks tests as green irrelevant of syntax.

no-unused-expressions and IntelliJ code inspection is able to detect this error.

ihordiachenko commented 3 years ago

Hi @karlismelderis

This plugin is for chai-js-style asserts like this:

expect(true).to.be.true;

It is useless for Jest-style asserts so just remove/disable the plugin.

karlismelderis commented 3 years ago

Due to historical decisions we're using chai assertions in Jest So .exist, .true and other chai syntax still exist in our test files

but chai do not have .disabled (it's only part of chai-jquery and we don't have it installed)

ihordiachenko commented 3 years ago

@karlismelderis I see. The linter is not aware of chai plugins, so the best we can do is to add a configurable whitelist of chai asserts. Will look into it this weekend.