Skip to content
This repository was archived by the owner on Oct 10, 2022. It is now read-only.

Conversation

@ehmicky
Copy link
Contributor

@ehmicky ehmicky commented Dec 16, 2020

This enables the fp/no-mutating-assigns ESLint rule.

@ehmicky ehmicky added the type: chore work needed to keep the product and development running smoothly label Dec 16, 2020
@ehmicky ehmicky requested a review from erezrokah December 16, 2020 16:20
@ehmicky ehmicky self-assigned this Dec 16, 2020

const methods = getMethods(this)
// eslint-disable-next-line fp/no-mutating-assign
Object.assign(this, methods)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to run after options have been assigned.

}

const getMethods = function (NetlifyApi) {
const getMethods = function ({ basePath, defaultHeaders, agent, globalParams }) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make options passing more explicit.

Object.assign(error, { name: 'FetchError', url, data })
error.name = 'FetchError'
error.url = url
error.data = data
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We allow direct mutations on variables that are known to be mutable by design. For example, errors should be directly mutated to keep the Error prototype. We allow those variables by variable names: https://github.com/netlify/eslint-config-node/blob/d76bd7afca8611d0a00277bdd24435adfdeca38b/.eslintrc.js#L181

However, the exceptions option is not available for this specific rule (about Object.assign()), so we need to use direct property mutations instead to fix linting.

@ehmicky ehmicky merged commit 2edd766 into master Dec 16, 2020
@ehmicky ehmicky deleted the lint/no-mutating-assign branch December 16, 2020 18:29
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

type: chore work needed to keep the product and development running smoothly

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants