Skip to content

ErickWendel/eslint-clone

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 

Repository files navigation

ESLint Reimagined: Creating a Linter from Scratch

Welcome, this repo is part of my youtube video about Creating your own ESLint from scratch (en-us)

First of all, leave your star 🌟 on this repo.

Access our exclusive telegram channel so I'll let you know about all the content I've been producing

Complete source code

  • Access it in app

ESLint Reimagined-thumb

Usage

Go to app and restore dependencies as follows:

nvm use
npm i
npm link
eslint-clone --file filename.js

Example

eslint-clone --file error.js

Outputs

Error: use "const" instead of "var"
error.js:1:1
Error: use single quotes instead of double quotes
error.js:1:12
Error: use single quotes instead of double quotes
error.js:1:23
Error: use "const" instead of "var"
error.js:2:1
Error: use single quotes instead of double quotes
error.js:3:24
Error: use "let" instead of "var"
error.js:5:1
Error: use single quotes instead of double quotes
error.js:6:25
Error: use single quotes instead of double quotes
error.js:9:25
Error: use "const" instead of "let"
error.js:15:1
Error: use single quotes instead of double quotes
error.js:15:25
Error: use single quotes instead of double quotes
error.js:17:9
Linting completed with 11 error(s).

Code fixed and saved at ./error.linted.js successfully!

Cleaning Up

npm unlink eslint-clone

Tasks

  • fix the bug when replacing quotes
    • if a code have single quotes enclosing double quotes such as:

      const name = '"ana"'

      it'd be transformed as below and will cause a syntax error.

      const name = ''ana''
    • How to fix: replace it to a template string instead.

      • Input:
        '"double"'.replaceAll('"', "'");
      • Current Output:
        ''double''.replaceAll(''', ''');
      • Expected Output:
        `"double"`.replaceAll(`"`, `'`);
  • keep line breaks
  • keep comments
  • keep spaces
  • don't put semicolons automatically
  • report missing semicolon ';'