-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
Update ESLint configuration #32343
Update ESLint configuration #32343
Conversation
Hi @fredden. Thank you for your contribution
❗ Automated tests can be triggered manually with an appropriate comment:
You can find more information about the builds here ℹ️ Please run only needed test builds instead of all when developing. Please run all test builds before sending your PR for review. For more details, please, review the Magento Contributor Guide documentation. 🕙 You can find the schedule on the Magento Community Calendar page. 📞 The triage of Pull Requests happens in the queue order. If you want to speed up the delivery of your contribution, please join the Community Contributions Triage session to discuss the appropriate ticket. 🎥 You can find the recording of the previous Community Contributions Triage on the Magento Youtube Channel ✏️ Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel |
Mostly all magento js write in es5+. Get benefits form newer js generation by add syntax such as arrow function or spared operator |
@magento create issue |
@magento run Static Tests, Functional Tests CE, Functional Tests EE, Functional Tests B2B |
"no-useless-return": 2, | ||
"no-var": 2, | ||
"no-void": 2, | ||
"no-whitespace-before-property": 2, | ||
"no-with": 2, |
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.
no-var may cause some errors since i see lot of js code still use var ?
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.
https://eslint.org/docs/rules/no-var
The idea here is to configure ESLint to encourage use of modern JavaScript. Yes, var
still works but let
and const
are preferred.
Perhaps the testsuite should be changed to only fail ESLint checks on GitHub for files that are being modified, like it already does for PHP_CodeSniffer. This would mean we can get this configuration merged in and then migrate the existing JavaScript gradually. It'd be messy to try to do it all in one go here, especially as there are third party libraries and minified JavaScript files in the repository currently. @gabrieldagama or @mrtuvn, do you know how one might go about making such a change? I don't recall seeing code for the GitHub testsuite integration. Is there another repository to which I can be given access so that I can make this change? |
I don't have a problem adding Babel to If a particular website is trying to support an older / unsupported browser, then a transpiler makes sense along with various polyfills and library compatibility layers. Finding these and maintaining a list thereof seems out of scope to me. Perhaps it would be better to have a note in the documentation advising the existence of polyfills and transpilers. That would allow the codebase to respect its list of supported browsers, and provide information for those who wish to extend that support without the burden of (this project) supporting (a list of tools for compatibility with) unsupported browsers. |
thank you i think we no need babel at this time! Let's focus on other archievement and fix static fails first because i think a lot of files in codebase will not following standards |
@magento run Static Tests |
@gabrieldagama, can I please get access to https://github.com/magento-commerce/magento2-infrastructure/tree/2.4-develop or wherever the Static Tests configuration is to make the change suggested here? |
Hi @fredden, I'm afraid we won't be able to provide access to that repository, which is private and internal repo. However, do you work for an Adobe/Magento partner? If so access to https://github.com/magento/partners-magento2-infrastructure may be provided. Otherwise, we can proceed with this PR later. It may take a while because of its priority. |
Yes, I currently work for a Magento Partner. How do I go about requesting access to https://github.com/magento/partners-magento2-infrastructure? |
As discussed with @fredden on slack, that repo is actually not accessible through our partners program, so in order to proceed with this PR a member of our team has to work on this. |
@sivaschenko @fascinosum added label here( maybe adjust priority) but we still need extra works on this. A lot of js static fails with new changes in eslint rules. Imho i think this updates neccessary for code base in long terms |
I'm still willing to make the proposed changes to the test-suite to facilitate a smooth / easy roll-out of this change. Is someone able to grant me access to the relevant repositories? |
@mrtuvn this PR is not related to the 3rd party or infrastructure dependencies of Magento (that are the platform), so I have removed the Platform Health project label |
@sivaschenko is there anything I can do to help progress this? |
The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time. |
Any tool auto fix with your new config eslint ? Since a think a lot file js in code base will false after update new config |
I'd like to get the static tests for JavaScript on GitHub changed so that it will only lint files that have been changed in the pull request, rather than every file in the code-base. This is how the static tests for PHP work at present, so there's no change in policy. As a side benefit, the static tests will use less resource and run quicker. (Other tests (eg Functional, Integration, Unit) tests won't be affected.) The main reason for this suggestion/change is so we don't have to modify all JavaScript files within one pull request. Such a pull request would be unreasonably large and require significant testing before being accepted, and will very likely have many conflicts which would be time consuming to resolve. Given the long length of time any change requires to go through, this is infeasible. This approach (update static tests to treat JavaScript & PHP equally) allows us to work through the JavaScript files in a sensible & feasible way. Files that are changed should be brought in line with the current standards (which is how PHP files are being handled presently). Over time we will have more and more files matching the current standards. We can plan a project to update all files if desired. In my opinion this should be handled separately from updating the standards. |
@sivaschenko is there anything I can do to help progress this? |
Thanks for the update @sivaschenko. I can see that magento/magento-coding-standard#262 has been opened. Should I recreate this pull request in that repository? |
@fredden I think we might need to do this change in several stages:
Only the rules that will not fail Static tests build on the magento2 codebase can be added earlier. |
This has been copied from magento/magento2#32343
This has been superseded by magento/magento-coding-standard#347. |
This has been copied from magento/magento2#32343
Description
The ESLint configuration currently in use was last updated four years ago. A lot has changed in the JavaScript since then. Let's update the configuration to match today's standards.
Related Pull Requests
Fixed Issues
None
Manual testing scenarios
This is a coding standards change and does not make any changes to any functionality within the platform. Therefore no testing of Magento itself is required.
Questions or comments
I expect this pull request to spark some conversation. Many of the settings here have come from the JavaScript Standard Style, although some adaptations have been made to better fit with Magento's existing style guide (eg, four spaces for indentation). I have intentionally kept all existing settings unchanged.
I'm happy to receive feedback here, but may need to get someone from Magento to give a deciding vote / official stance if consensus cannot be amicably achieved.
Contribution checklist
Resolved issues: