Skip to content

Conversation

@kc-leung
Copy link
Contributor

fixes #25
Added ESLint for formatting check.

I followed this example:
https://medium.com/quick-code/how-to-integrate-eslint-prettier-in-react-6efbd206d5c4

1- After this is merge npm install is required since there were new package installed in order to rum the application

2- @tangoslee Is there anyway I can test if it is working properly?

@tangoslee
Copy link

tangoslee commented Jun 11, 2019

@kc-leung

After you install .eslintrc, if you install 'eslint plugin' in your vscode, you can see some warning or errors when you open 'reviewActions.js'

  • Before fix
    before

tilde line means warning (green), error (red)
You should fix your code to pass the eslint rule or change your eslint rule.

For example, according to your eslint rule, disallow call 'console' object. so, you can set

  • Call indirectly through Console variable (edit the code to follow the rule)
const Console = console;
...
Console.log(...)

or you can

  • Add no-console rule in the .eslintrc to allow call 'console' object (edit the rule for your development environment)
  "rules": {
    "react/jsx-filename-extension": [
      1,
      {
        "extensions": [".js", ".jsx"]
      }
    ],
    "react/prop-types": 0,
    "no-underscore-dangle": 0,
    "import/imports-first": ["error", "absolute-first"],
    "import/newline-after-import": "error",
    "no-console": "off"
  },

As the same way, red tilde line shows 'currentReviews' was used before it was defined.
so, shift 'currentReviews' up before 'reviewFetchData'; define first, use later.

Then, you can see all warnings are disappears in your file.

  • After fix (no-console: off, reorder const variables)

after

That let all developers follow the same rule is the purpose of using Eslint.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add eslint for formatting

3 participants