Skip to content
This repository has been archived by the owner on Jun 6, 2024. It is now read-only.

refactor eslint of webportal #3235

Closed
debuggy opened this issue Jul 22, 2019 · 0 comments
Closed

refactor eslint of webportal #3235

debuggy opened this issue Jul 22, 2019 · 0 comments
Assignees

Comments

@debuggy
Copy link
Contributor

debuggy commented Jul 22, 2019

The eslint config of webportal is out-dated for a long time. As a result, the code format and style check does not work as expected when new codes come in. It has several drawbacks include:

  1. The code format style was not strict and fixed, so most prs have to include some format changes like space indent, new line change etc., which increases the hardness of code review and decreases code readability.
  2. The CI process in github missed some linting errors. In fact, when I corrected the eslint config file, there are almost 2000 format errors in webportal files of master branch.
  3. The style is hard to be consistent between new comers and existing codes.

After few days’ investigation on many open source projects, I proposed a new eslint guidline in webportal, which could improve code readability significantly. And currently the major changes are:

  1. Update eslint version from 4.18.2 to 6.1.0. The new eslint version has several big improvement in react and javascript code style, and it also deprecates many old rules. For rule deprecation: https://eslint.org/docs/user-guide/rule-deprecation
  2. Introduce prettier tools to format code. The prettier is the most popular and convenient tool for code format and has perfect cooperation with most editors like VS Code. Use prettier to format code and add it into eslint rules will largely improve the work productivity and save developers from formatting. More details: https://prettier.io/docs/en/index.html
  3. Use standard style instead of google eslint config. First of all, the eslint-config-google has few activity and updates recently and few focuses and discussions. It still includes some rules which has been deprecated by eslint. And from my investigation, hardly few open source projects utilize this config. Instead, standard is a public acknowledged style which accepted by more and more major projects. More details: https://github.com/standard/eslint-config-standard . Below is the graph about google vs standard

image

  1. Remove semi-colon at end of line. First of all, it has exactly no diff whether there is a semi at the end of line or not. It brings a intense debate about whether to add a semi or remove it. I don’t want to introduce all the discussion about it, however I prefer that the code is more clean without this semi. And it seems to become a trend to remove semi from javascript. If anyone has a different idea, I am happily and readily to be connected and see if we need to change this rule.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant