-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
build(cdn): Ensure ES5 bundles do not use non-ES5 code #7550
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
packages/eslint-plugin-sdk/src/rules/no-unsupported-es6-methods.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
'use strict'; | ||
|
||
/** | ||
* Taken and adapted from https://github.com/nkt/eslint-plugin-es5/blob/master/src/rules/no-es6-methods.js | ||
*/ | ||
|
||
module.exports = { | ||
meta: { | ||
docs: { | ||
description: 'Forbid methods added in ES6 which are not polyfilled by Sentry.', | ||
}, | ||
schema: [], | ||
}, | ||
create(context) { | ||
return { | ||
CallExpression(node) { | ||
if (!node.callee || !node.callee.property) { | ||
return; | ||
} | ||
const functionName = node.callee.property.name; | ||
|
||
const es6ArrayFunctions = ['copyWithin', 'values', 'fill']; | ||
const es6StringFunctions = ['repeat']; | ||
|
||
const es6Functions = [].concat(es6ArrayFunctions, es6StringFunctions); | ||
if (es6Functions.indexOf(functionName) > -1) { | ||
context.report({ | ||
node: node.callee.property, | ||
message: `ES6 methods not allowed: ${functionName}`, | ||
}); | ||
} | ||
}, | ||
}; | ||
}, | ||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Sentry ES5 polyfills | ||
if (!('includes' in Array.prototype)) { | ||
Array.prototype.includes = function (searchElement) { | ||
return this.indexOf(searchElement) > -1; | ||
}; | ||
} | ||
if (!('find' in Array.prototype)) { | ||
Array.prototype.find = function (callback) { | ||
for (var i = 0; i < this.length; i++) { | ||
if (callback(this[i])) { | ||
return this[i]; | ||
} | ||
} | ||
}; | ||
} | ||
if (!('findIndex' in Array.prototype)) { | ||
Array.prototype.findIndex = function (callback) { | ||
for (var i = 0; i < this.length; i++) { | ||
if (callback(this[i])) { | ||
return i; | ||
} | ||
} | ||
return -1; | ||
}; | ||
} | ||
if (!('includes' in String.prototype)) { | ||
String.prototype.includes = function (searchElement) { | ||
return this.indexOf(searchElement) > -1; | ||
}; | ||
} | ||
if (!('startsWith' in String.prototype)) { | ||
String.prototype.startsWith = function (searchElement) { | ||
return this.indexOf(searchElement) === 0; | ||
}; | ||
} | ||
if (!('endsWith' in String.prototype)) { | ||
String.prototype.endsWith = function (searchElement) { | ||
var i = this.indexOf(searchElement); | ||
return i > -1 && i === this.length - searchElement.length; | ||
}; | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My only concern here is that we may interfere with polyfills that users themselves added 🤔 but I guess if that's the case users need to make sure to add the polyfills before they add sentry (which they should have done already anyhow in order for Sentry not to break).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whatever we do here will be better than what already exists, so I think this is fine. We are being good citizens via the
in
check on the prototype anyway.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 then let's