eslint extends와 plugins 차이

루카소·2023년 3월 29일
0

extends는 rules까지 적용된 일종의 통합 셋트이다.
plugin은 몇몇개의 룰들이다. plugin을 추가 했다고 해서 룰이 적용된 것은 아니다. 때문에 plugin있어도 rule은 별개로 활성화 시켜야 한다.
그러나 plugin 중에 config 파일이 있는 것도 있는데 이것이 있다면 플러그인을 extends에 추가해서 사용할 수도 있다.

rule은 extends를 오버로드 해서 덮어 쓸 수 있다.

plugin의 이름은 보통 eslint-plugin-xxx이다.
eslint-plugin- 부분은 제외할 수 있다.

extends를 위한 것은 eslint-config-xxx 형태이다. 보통 shareable config로 부르기도 한다.
예를 들면 eslint-config-prettier 라는 명칭이면 아래처럼 prettier만 쓰면 되는 것이다.

{
	"extends": ["prettier"]
}

몇몇 plugin은 extends를 할 수 있게 지원한다. 앞에 plugin:이라고 적힌 것은 plugin에서 지원하는 shared config이다.

예를 들면 아래와 같다면
plugin에 있는 여러 shareable config중에 recommended config를 이용하는 것이다.

{
	"extends": ["plugin:react/recommended"]
}
profile
rukkasso

0개의 댓글