Linting using Eslint - Memory-Lane-COS301/miniproject-2023 GitHub Wiki

Guide for Local Linting

  1. Go to the folder/file you have modified
  2. Copy the relative Path
  3. Go to the root of the project and run
yarn lint relative/path/to/modified/fileOrFolder
  1. The syntax will be fixed were possible, detailed errors will be produced, which should be fixed
  2. Fix remaining errors, if any
  3. Test by running the command again
yarn lint relative/path/to/modified/file

Additional info

  1. Eslint supports linting an entire folder, meaing you can lint an entire foler, if you paste it's relative path
  2. Use Git status to check all the files you have modified and ensure that they have been linted

Currently Set-up rules:

  • Maximum length per line of code is set at 120 chars, excluding urls
   "max-len":["error",{"code":120,"ignoreUrls":true}]
  • No spacing before a semi colon, spacing after it
   "semi-spacing": ["error", {"before": false, "after": true}]
  • Commas that do not seperate elements are't allowed
      "comma-dangle":"error"
    
  • 2 array elements in one line during initialization, after, they should be seperated by a new-line
    "array-element-newline": ["error", {
              "ArrayExpression": "consistent",
              "ArrayPattern": { "minItems": 2 }
          }]
    

Important

  • There are many more rules applied than the ones listed above since we are extending from other standard rules