Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🏗 Fix linter when using dict({...spread}) #32586

Merged
merged 5 commits into from
Feb 10, 2021

Conversation

alanorozco
Copy link
Member

@alanorozco alanorozco commented Feb 10, 2021

My linting/formatting environment was not working for a particular file until I realized the linter failed when encountering it:

[09:23:26] TypeError in plugin "gulp-eslint"
Message:
    Cannot read property 'raw' of undefined
Occurred while linting file-abc.js:123

This is caused by lint plugin local/dict-string-keys failing when using a spread operator inside dict().

dict({...spreadOperatorBreaksLinter});

We likely want to forbid this, which this change accomplishes.

// Found: idKeysAreNotOkay.The Object Literal Expression passed into `dict` must only contain string keyed properties. (at 2:7)
   dict({idKeysAreNotOkay: true});
// ------^

// Found: spreadOperatorIsNotOkay. The Object Literal Expression passed into `dict` must only contain string keyed properties. (at 5:7)
   dict({...spreadOperatorIsNotOkay});
// ------^

Alternatively, we could follow the object definition to ensure it's a dict() but that is probably more work than it's worth.

@amp-owners-bot
Copy link

Hey @erwinmombay, @jridgewell! These files were changed:

build-system/eslint-rules/dict-string-keys.js

@erwinmombay
Copy link
Member

agree with "probably more work than it's worth."

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants