Closed robatwilliams closed 1 year ago
There should be a new optional option detectPrototypeMethods
(detect-prototype-methods
on the CLI), which when set to false
ignores those rules. Document it in the readmes under the packages folder.
The option should be passed into forbiddenFeatures()
in compatibility.js
, and used to filter out rules. Rule objects in the features
folder should have a new optional property isPrototypeMethod: true
to identify them.
If you're working around this by parsing the error messages to decide what to ignore, the correct way (i.e. without also ignoring definite real problems) is to look for .prototype.
in the message.
Solution will probably be:
Need to wait for aggressive mode to be released.
If you're working around this by parsing the error messages to decide what to ignore, the correct way (i.e. without also ignoring definite real problems) is to look for .prototype. in the message.
Recommend that you do each prototype method individually and make sure you have a polyfill in place for each one. See #2
Note this about es plugin aggressive mode:
If using this plugin and TypeScript, this plugin reports prototype methods by default because we can easily know types.
Unblocked by #56
Various usages of no-restricted-syntax
to be replaced by specific plugin rules:
2022: https://eslint-community.github.io/eslint-plugin-es-x/rules/no-array-string-prototype-at.html
2021: https://eslint-community.github.io/eslint-plugin-es-x/rules/no-string-prototype-replaceall.html
2020: https://eslint-community.github.io/eslint-plugin-es-x/rules/no-string-prototype-matchall.html
2019: https://eslint-community.github.io/eslint-plugin-es-x/rules/no-array-prototype-flat.html https://eslint-community.github.io/eslint-plugin-es-x/rules/no-string-prototype-trimstart-trimend.html https://eslint-community.github.io/eslint-plugin-es-x/rules/no-symbol-prototype-description.html
2018: https://eslint-community.github.io/eslint-plugin-es-x/rules/no-promise-prototype-finally.html
2017: https://eslint-community.github.io/eslint-plugin-es-x/rules/no-string-prototype-padstart-padend.html
2016: https://eslint-community.github.io/eslint-plugin-es-x/rules/no-array-prototype-includes.html
Readme would need updating, including footnotes.
Also features/es-versions.md
Used aggressive mode for es2022 .at()
- need to align that with whatever solution is for this issue
These prototype methods have quite distinct names, which developers would normally strive to avoid using for their own methods. So I don't think this is important.
This issue has been open for 2 years and received no comments or thumbs up, which also suggests it's not important.
If you use lodash, add a polyfills entry to silence the false alarms.
Feel free to comment if you read this and want this feature.
Some features are detected with a chance of false positives - https://github.com/robatwilliams/es-compat/blob/master/packages/eslint-plugin-ecmascript-compat/lib/features/es-versions.md
This will happen all the time if you're using e.g. lodash, or a library that tests for feature presence before using it.
There should be a way of ignoring these, and only report problems that we have full confidence in.