Error

Vuex에서 getters와 mutations 항목에서 state를 선언하면 state already declared라는 Eslint 오류를 뱉어낼 때 대처법

GreatSaiyaman 2022. 5. 2. 13:05
const getters = {
    commonModalLifeCycle: state => state.commonModalLifeCycle,
    estateModalLifeCycle: state => state.estateModalLifeCycle
};

 

Vuex 파일의 getters나 mutations 안에 갑자기 생뚱맞게 state에 밑줄이 그어지면서 eslint에서

state already declared라는 문구를 뱉어냅니다.

이는 Airbnb lint를 사용하는 개발자분들에게만 나타나는 현상입니다.

대처법은 아래와 같습니다.

1. .eslintrc.js 파일로 이동

2. 아래 옵션 추가해 주기

 

"no-shadow": ["error", { "allow": ["state"] }],

https://stackoverflow.com/questions/43843180/eslint-state-already-declared-vuex