본문 바로가기

4. 개인 취미 생활

[26] Lint

https://ko.wikipedia.org/wiki/%EB%A6%B0%ED%8A%B8_(%EC%86%8C%ED%94%84%ED%8A%B8%EC%9B%A8%EC%96%B4) 

 

린트 (소프트웨어) - 위키백과, 우리 모두의 백과사전

 

ko.wikipedia.org

 

"린트(Lint)"란?

유닉스 운영체제에서 C언어 소스코드에 오류가 있는지 검사하는 프로그램.

요즘에는 소스코드를 분석하여 프로그램 오류, 버그, 스타일 오류 등을 점검하는 것을 말합니다.

 

그리고 "린트"를 도와주는 프로그램을 "린터" 혹은 "린트 툴" 등으로 부릅니다.

 

프로그래밍 언어 별로 다양한 린터가 존재합니다.

 

ESLint

Javascript 환경에서 많이 쓰는 린터

https://en.wikipedia.org/wiki/ESLint

 

ESLint - Wikipedia

From Wikipedia, the free encyclopedia Jump to navigation Jump to search JavaScript code analysis software ESLint is a static code analysis tool for identifying problematic patterns found in JavaScript code. It was created by Nicholas C. Zakas in 2013.[1][2

en.wikipedia.org

공식문서

https://eslint.org/docs/latest/

 

Documentation - ESLint - Pluggable JavaScript Linter

A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.

eslint.org

 

ESLint 설치하기

* 조건: node.js가 설치되어 있어야 합니다.

* global로 설치할 수도 있지만, 추천하지 않습니다.

npm install eslint --save-dev

 

ESLint 구성 초기화

npx eslint --init

 

구성(Configuration) 파일 우선 순위

동일한 디렉토리에 여러 구성 파일이 있는 경우 ESLint는 하나만 사용합니다. 우선 순위는 다음과 같습니다.

  1. .eslintrc.js
  2. .eslintrc.cjs
  3. .eslintrc.yaml
  4. .eslintrc.yml
  5. .eslintrc.json
  6. package.json

 

rules 와 extends

rules: 세부 규칙을 정합니다.

https://eslint.org/docs/latest/rules/

 

Rules - ESLint - Pluggable JavaScript Linter

A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.

eslint.org

 

extends: 규칙 집합인 plugins를 사용할 규칙으로 정합니다.

ex) Airbnb Style Guide: https://github.com/airbnb/javascript

 

GitHub - airbnb/javascript: JavaScript Style Guide

JavaScript Style Guide. Contribute to airbnb/javascript development by creating an account on GitHub.

github.com