Sitelet https://github.com/react/react/pull/9625
Skip to content

Disable ESLint's no-extend-native for two lines - #9625

Merged
nhunzaker merged 1 commit into
react:masterfrom
paulmanta:disable-no-extend-native
May 20, 2017
Merged

nhunzaker merged 1 commit into
react:masterfrom
paulmanta:disable-no-extend-native

Conversation

@paulmanta

Copy link
Copy Markdown
Contributor

This fixes the following two no-extend-native warnings by adding eslint-disable-line comments.

src/renderers/dom/shared/__tests__/ReactDOMComponent-test.js
  819:11  warning  Object prototype is read only, properties should not be added  no-extend-native
  828:11  warning  Object prototype is read only, properties should not be added  no-extend-native

I also had to move the code around a bit so both ESLint and Prettier would be satisfied. Initially the code was like like this:

Object.prototype.toString = function() { // eslint-disable-line no-extend-native
  ...
}

But Prettier moved the comment on the following line, which cased the ESLint warning to appear again.

Object.prototype.toString = function() {
  // eslint-disable-line no-extend-native
  ...
}

Moving the comment before the assignment prevented Prettier from reformatting the code but did not disable the warning, so I refactored the code like this:

let  wrappedToString = function() {
  ...
}
Object.prototype.toString = wrappedToString; // eslint-disable-line no-extend-native

The PR that introduced the warnings is #9163.

@nhunzaker nhunzaker left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This looks good to me. Thanks for the fix! I'll merge this tomorrow afternoon unless anyone has an outstanding concern.

@nhunzaker
nhunzaker merged commit 4b53dd0 into react:master May 20, 2017
@nhunzaker

Copy link
Copy Markdown
Contributor

Cool. Thanks for taking the time to look into this!

mrizwanashiq pushed a commit to mrizwanashiq/react that referenced this pull request Jun 25, 2026
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.

3 participants