module.exports = { 'parser': '@typescript-eslint/parser', 'plugins': ['@typescript-eslint'], 'env': { 'commonjs': true, 'browser': true, 'es2021': true, 'node' : true }, 'extends': [ 'airbnb', 'airbnb/hooks', 'plugin:@typescript-eslint/recommended' ], 'parserOptions': { 'project': './tsconfig.json', 'ecmaFeatures': { 'jsx': true, }, 'ecmaVersion': 12, 'sourceType': 'module', }, 'rules': { 'inden..
![](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FqypNd%2FbtqP6nZo3uk%2FMsqTCMSK06nkrP1gR5hTA0%2Fimg.png)
Typescript ์ฐธ๊ณ : https://www.typescriptlang.org/docs/handbook/typescript-in-5-minutes.html (Typescript ๊ณต์ ์ฌ์ดํธ) ๋ฐฐ์ฐ๋ ์ด์ JS์์๋ Type์ด ๊ณ์ ์ฒดํฌ๋์ง ์๋๋ค. 1. ์ด๋ ์๋ฌต์ ํ๋ณํ, hoisting, ๋ณต์ก์ฑ ๋ฌธ์ ๋ฅผ ์ผ์ผํฌ ์ ์๋ค. ์ด๋ฌํ ์ฝ๋ ์์ ์์์น ๋ชปํ ๋ฒ๊ทธ๋ฅผ ์์ ๊ธฐ ์ํด typescript๋ฅผ ์ฃผ๋ก ์ฌ์ฉํ๋ค. hoisting : ๋์ด์ฌ๋ฆฐ๋ค๋ ๋ป. javascript์์ ์ ์ธ๋ฌธ์ ๋์ด์ฌ๋ ค ์ฝ๋์์ ์ฌ์ฉํ ๋ ์์์ ์๊ด์์ด ์ฌ์ฉ ๊ฐ๋ฅํ๋๋ก ํ๋ ๊ธฐ์ . typescript๋ ๋ณต์กํ ์์ธ์ฒ๋ฆฌ ์ฝ๋ ์์ด ์ด๋ฅผ ์ํํ๋ค. 2. ํ์ ์์๋ ์ถํ์ ๋ณธ์ธ์ด ์ง ์ฝ๋๋ฅผ ๋ณด์์ ๋ ํ์ ์ด ์ ์๋์ด ์์ง ์๋ค๋ฉด ํ๋..
TS2691: import .ts file ์ฐธ๊ณ : https://github.com/microsoft/TypeScript/issues/37582 https://github.com/microsoft/TypeScript/issues/27481 https://github.com/microsoft/TypeScript/issues/39965 ์ด ์ค๋ฅ๋ typescript ํ์ผ์ ์ฐพ์ ์ ์์ด์ ๋๋ ์ค๋ฅ์ด๋ค. import A from 'A.tsx'; ์์ ๊ฐ์ด ํ์ผ์ ๋ถ๋ฌ์ค๋ฉด, import ์ ์ ts / tsx ํ์ผ์ด js / jsx ๋ก ๋ณํ๋๊ธฐ ๋๋ฌธ์ ํด๋น ํ์ผ์ ์ฐพ์ ์ ์๋ค๋ ์๋ฌ๊ฐ ๋ฌ๋ค. ๋ฐ๋ผ์, ๋จ์ํ ํ์ฅ์๋ฅผ ๋ถ์ด์ง ์๊ณ import ํด์ค๋ ๊ฒ์ด ๊ฐ์ฅ ๊ฐ๋จํ ๋ฐฉ๋ฒ์ธ๋ฐ ๊ทธ๋ ๊ฒ ํ๋ฉด esl..
![](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FbiC1Nx%2FbtqO3z7aFVj%2FNsgDKA5e4idFNKvJVy7XTK%2Fimg.png)
์์กด์ฑ ์๋ฌ ํด๊ฒฐ ์๋ฌ ๋ฐ์ ์ด๋ฐ ์ค๋ฅ๊ฐ ๋ด๋ค. CRA๊ฐ ์ ๊ณตํ๋ react-scripts ํจํค์ง๊ฐ eslint 6.6.0 ๋ฒ์ ์ ์์กดํ๋๋ฐ, 7.2.0 ๋ฒ์ ์ ์ค์นํด์ ๊ทธ๋ ๋ค๊ณ ํ๋ค. ์ ๋ฐ์ ๋์ค๋ ํด๊ฒฐ๋ฐฉ๋ฒ์ด ์๋๋ฐ, ๋ฐ๋ผํด๋ ํด๊ฒฐ๋์ง ์๋๋ค ใ ... ์ ๋ฒ์๋ ๊ฐ์ ๋ฌธ์ ๋ก ์์ฉ์ฌ์ ์ด๋ฒ์ ์ ๋๋ก ๊ฐ์ก๊ณ ํด๊ฒฐํด๋ณด๋ ค๊ณ ํ๋ค. ์ด์ ๋ฐ๊ฒฌ ์ด์ ๋ ๊ตฌ๊ธ๋งํ๋ค๊ฐ ๋ฐ๊ฒฌํ๋๋ฐ(https://github.com/wesbos/eslint-config-wesbos/issues/17) , react-scripts์ eslint ์์กด์ฑ ๋ฒ์ ๊ณผ airbnb linting์์์ eslint ์์กด์ฑ ๋ฒ์ ์ด ์ผ์นํ์ง ์์์ ๋์ค๋ ๋ฌธ์ ์๋ค. ๋ป์ง ๊ทธ๋์ ์ผ๋จ react-scripts version์ `npm view react-s..
VScode์์ eslint๊ฐ ์ ์ฉ์ด ์๋๊ณ ์๊พธ ํด๋น ์๋ฌ๊ฐ ๋จ๊ธธ๋ ๊ฒ์ํด๋ดค๋ค. ๋ฒ์ ์ด ์ ๋ง์์ ๊ทธ๋ฐ ๊ฒ์ด๋ VScode๋ฅผ ๋ค์ ๊น๋ฉด ๋ฒ์ ์ ๋ฐ์ดํธ๋๋ฉด์ eslint๊ฐ ์ ๋๋ค. ๋ค์ด๋ก๋ : code.visualstudio.com/download ์ฐธ๊ณ : https://github.com/typescript-eslint/typescript-eslint/issues/2020
์ฐธ๊ณ : https://hoilzz.github.io/webpack/11-eslint-prettier/ eslint์ parser๊ฐ ๊ณต์์ ์ผ๋ก ES ํ์ค๋ง์ ์ง์ํ๊ธฐ ๋๋ฌธ์, ES6~7 ํ์ฑ ์ ๋ฌธ์ ๊ฐ ์๊ธด๋ค. ๋ฐ๋ผ์, .eslintrc.js ํ์ผ์ export default๋ฅผ module.export๋ก ๋ณ๊ฒฝํ๊ธฐ export๋ ES6 syntax์ด๊ณ , module export๋ commonJS syntax์ด๋ค. babel-eslint ์ค์น ํ .eslintrc.js์ "parser": "babel-eslint",์ถ๊ฐํ๊ธฐ ๋ ๋ฐฉ๋ฒ ์ค ํ๋๋ฅผ ์ฌ์ฉํ๋ฉด ๋๋ค.
Comment