WordPress-Coding-Standards / eslint-config-wordpress

This package has been deprecated, please use @wordpress/eslint-plugin or @wordpress/scripts
https://www.npmjs.com/package/@wordpress/eslint-plugin
MIT License
45 stars 13 forks source link

space-unary-ops allow space for words #44

Open swashata opened 6 years ago

swashata commented 6 years ago

Right now with the space-unary-ops settings, unary words like yield throw error saying

file: 'file:///Volumes/Development/vagrant/www/es6/public_html/wesbos-js-es6/16%20-%20Generators/indes.js'
severity: 'Error'
message: 'Unexpected space after unary word operator 'yield'. (space-unary-ops)'
at: '2,2'
source: 'eslint'
code: 'space-unary-ops'

Example code:

function* listPeople() {
    yield 'Swas';
    yield 'Sonali';
    const myArray = new Array( 1, 2, 3 );
}

Strangely, it doesn't throw error for line 4 with const myArray = new Array( 1, 2, 3 );.

Overriding the space-unary-ops rule like this

        "space-unary-ops": [
            'error', {
                "words": true,
                "nonwords": false,
                "overrides": {
                    "!": true
                }
            }
        ]

does solve the problem. Should we go ahead and implement that?