Posts

Showing posts from September, 2020

Getting Started with ESLint

  ESLint is a tool for identifying and reporting on patterns found in ECMAScript/JavaScript code, with the goal of making code more consistent and avoiding bugs. In many ways, it is similar to JSLint and JSHint with a few exceptions: ESLint uses  Espree  for JavaScript parsing. ESLint uses an AST to evaluate patterns in code. ESLint is completely pluggable, every single rule is a plugin and you can add more at runtime. Installation and Usage Prerequisites:  Node.js  ( ^10.12.0 , or  >=12.0.0 ) built with SSL support. (If you are using an official Node.js distribution, SSL is always built in.) You can install ESLint using npm or yarn: npm install eslint --save-dev # or yarn add eslint --dev You should then set up a configuration file: $ npx eslint --init After that, you can run ESLint on any file or directory like this: $ npx eslint yourfile.js It is also possible to install ESLint globally rather than locally (using  npm install eslint --global )....

LINTER – GIÚP BẠN VIẾT CODE TỐT HƠN, XỊN HƠN, KHÔNG CẦN SENIOR HAY GIÁO VIÊN CHỈ DẠY

Image
  Hôm nay, Code Dạo sẽ giới thiệu với các bạn một công cụ đơn giản, miễn phí mà lại rất mạnh mẽ mang tên … linter. Công cụ này có thể review,  tìm những lỗi lặt vặt  trong cách viết code của bạn,  đưa ra đề xuất cải tiến  (hoặc tự sửa code luôn). Thật đấy! Sử dụng linter, bạn sẽ thấy như có thêm một người anh, người thầy ngồi cạnh mình khi code, nhắc nhở mình mỗi khi mình  viết code lô, code đểu  và nhắc sửa. Linter chỉ ra tè le những chỗ mình code nhầm Trong phạm vi bài viết, mình sẽ giới thiệu về linter, cũng như hướng dẫn cách cài đặt  ESLint  cho JavaScript trên  VSCode  nhé. Linter là cái quái gì? Theo  Wikipedia về lint , linter là một công cụ dùng để phân tích source để phát hiện những lỗi sai, bug, vi phạm lỗi sai viết code. Trong thực tế, mình dùng linter để bảo đảm code mình viết ra theo đúng chuẩn (do mình hoặc team đặt ra). Các team sử dụng linter để thống nhất style code / coding convention. Vì mỗi team có mỗi styl...

Linter