강의

멘토링

로드맵

Inflearn Community Q&A

sorae314285625's profile image
sorae314285625

asked

Vue3 Perfect Master: From Basics to Practice - "Basic Edition"

ESLint, Prettier

eslint 세팅 질문 드립니다.

Written on

·

1.7K

0

vite로 프로젝트 설치 시, 영상과 다르게 extentsion설치에 대한 문의가 없어 바로 설치를 하였고,

eslint의 경우 npm으로 별도 설치 하였더니

영상에 보이는 cjs 파일이 보이지 않습니다.

rules세팅을 어떻게 해야 할까요?

vue.jsvuejs

Answer 2

0

Seung hyun님의 프로필 이미지
Seung hyun
Questioner

해결 하였습니다^^ 감사해요

0

gymcoding님의 프로필 이미지
gymcoding
Instructor

안녕하세요 :)

"영상과 다르게 extentsion설치에 대한 문의가 없어"

위 말씀이 터미널에서 npm init vue 명령어를 통하여 프로젝트를 생성할 때 eslint 설치여부 묻지 않았다는 말씀이시죠?

1) npm init vue 명령어를 통해 생성하신거죠?

2) npm 버전을 확인할 수 있을까요?

npm -v // 버전확인

제가 v8.11.0 , v9.5.1 에서는 정상 동작을 확인해서요. 만약 v8 이하 버전이라면 npm 업그레이드를 한 번 해보시겠어요?

sudo npm istall -g npm // 업그레이드

3) 버전이상이 없다면

  • node_modules 폴더 제거, package-lock.json 파일 제거 하신 후

  • package.json에 아래 코드를 넣고

{
  "name": "learn-vue3",
  "version": "0.0.0",
  "scripts": {
    "dev": "vite",
    "build": "vite build",
    "preview": "vite preview --port 5050",
    "lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs --fix --ignore-path .gitignore"
  },
  "dependencies": {
    "axios": "^0.27.2",
    "bootstrap": "^5.1.3",
    "vue": "^3.2.31"
  },
  "devDependencies": {
    "@rushstack/eslint-patch": "^1.1.0",
    "@vitejs/plugin-vue": "^2.3.1",
    "@vue/eslint-config-prettier": "^7.0.0",
    "eslint": "^8.5.0",
    "eslint-plugin-vue": "^8.2.0",
    "prettier": "^2.5.1",
    "vite": "^2.9.1"
  }
}
  • npm install 명령어로 모듈 설치 진행

  • .eslintrc.cjs 파일을 생성한 후 아래 코드 삽입

/* eslint-env node */
require('@rushstack/eslint-patch/modern-module-resolution');

module.exports = {
	root: true,
	parserOptions: {
		ecmaVersion: '2022',
		sourceType: 'module',
	},
	extends: [
		'plugin:vue/vue3-essential',
		'eslint:recommended',
		'@vue/eslint-config-prettier',
	],
	env: {
		'vue/setup-compiler-macros': true,
	},
	rules: {
		'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off',
		'no-unused-vars': 'off',
		'prettier/prettier': [
			'error',
			{
				singleQuote: true,
				semi: true,
				useTabs: true,
				tabWidth: 2,
				trailingComma: 'all',
				printWidth: 80,
				bracketSpacing: true,
				arrowParens: 'avoid',
			},
		],
	},
};

이렇게 하신다음에 강의대로 진행해 보시겠어요?

 

sorae314285625's profile image
sorae314285625

asked

Ask a question