[ESLint] React hook + Typescript ํ”„๋กœ์ ํŠธ ์‹œ ์„ค์ •ํ•œ rule ๊ณต์œ 
์›น (WEB)/๊ณต๋ถ€ 2020. 12. 14. 14:01

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..

[Typescript] ๊ธฐ์กด React + js ํ”„๋กœ์ ํŠธ ts๋กœ ๋ฐ”๊พธ๊ธฐ
์›น (WEB)/๊ณต๋ถ€ 2020. 12. 14. 13:58

Typescript ์ฐธ๊ณ  : https://www.typescriptlang.org/docs/handbook/typescript-in-5-minutes.html (Typescript ๊ณต์‹ ์‚ฌ์ดํŠธ) ๋ฐฐ์šฐ๋Š” ์ด์œ  JS์—์„œ๋Š” Type์ด ๊ณ„์† ์ฒดํฌ๋˜์ง€ ์•Š๋Š”๋‹ค. 1. ์ด๋Š” ์•”๋ฌต์  ํ˜•๋ณ€ํ™˜, hoisting, ๋ณต์žก์„ฑ ๋ฌธ์ œ๋ฅผ ์ผ์œผํ‚ฌ ์ˆ˜ ์žˆ๋‹ค. ์ด๋Ÿฌํ•œ ์ฝ”๋“œ ์ƒ์˜ ์˜ˆ์ƒ์น˜ ๋ชปํ•œ ๋ฒ„๊ทธ๋ฅผ ์—†์• ๊ธฐ ์œ„ํ•ด typescript๋ฅผ ์ฃผ๋กœ ์‚ฌ์šฉํ•œ๋‹ค. hoisting : ๋Œ์–ด์˜ฌ๋ฆฐ๋‹ค๋Š” ๋œป. javascript์—์„œ ์„ ์–ธ๋ฌธ์„ ๋Œ์–ด์˜ฌ๋ ค ์ฝ”๋“œ์—์„œ ์‚ฌ์šฉํ•  ๋•Œ ์ˆœ์„œ์— ์ƒ๊ด€์—†์ด ์‚ฌ์šฉ ๊ฐ€๋Šฅํ•˜๋„๋ก ํ•˜๋Š” ๊ธฐ์ˆ . typescript๋Š” ๋ณต์žกํ•œ ์˜ˆ์™ธ์ฒ˜๋ฆฌ ์ฝ”๋“œ ์—†์ด ์ด๋ฅผ ์ˆ˜ํ–‰ํ•œ๋‹ค. 2. ํ˜‘์—… ์‹œ์—๋‚˜ ์ถ”ํ›„์— ๋ณธ์ธ์ด ์ง  ์ฝ”๋“œ๋ฅผ ๋ณด์•˜์„ ๋•Œ ํƒ€์ž…์ด ์ •์˜๋˜์–ด ์žˆ์ง€ ์•Š๋‹ค๋ฉด ํ•˜๋‚˜..

[Typescript] TS2691: import .ts file
์›น (WEB)/์—๋Ÿฌํ•ด๊ฒฐ 2020. 12. 14. 13:58

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..

[ESLint] The react-srcipts package provided by Create React App requires a dependency :: ์˜์กด์„ฑ ๋ฌธ์ œ
์›น (WEB)/์—๋Ÿฌํ•ด๊ฒฐ 2020. 12. 3. 14:42

์˜์กด์„ฑ ์—๋Ÿฌ ํ•ด๊ฒฐ ์—๋Ÿฌ ๋ฐœ์ƒ ์ด๋Ÿฐ ์˜ค๋ฅ˜๊ฐ€ ๋–ด๋‹ค. 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..

[ESLint] createRequire is not a function Referenced from: ...
์›น (WEB)/์—๋Ÿฌํ•ด๊ฒฐ 2020. 12. 3. 12:26

VScode์—์„œ eslint๊ฐ€ ์ ์šฉ์ด ์•ˆ๋˜๊ณ  ์ž๊พธ ํ•ด๋‹น ์—๋Ÿฌ๊ฐ€ ๋œจ๊ธธ๋ž˜ ๊ฒ€์ƒ‰ํ•ด๋ดค๋‹ค. ๋ฒ„์ „์ด ์•ˆ ๋งž์•„์„œ ๊ทธ๋Ÿฐ ๊ฒƒ์ด๋‹ˆ VScode๋ฅผ ๋‹ค์‹œ ๊น”๋ฉด ๋ฒ„์ „ ์—…๋ฐ์ดํŠธ๋˜๋ฉด์„œ eslint๊ฐ€ ์ž˜ ๋œ๋‹ค. ๋‹ค์šด๋กœ๋“œ : code.visualstudio.com/download ์ฐธ๊ณ  : https://github.com/typescript-eslint/typescript-eslint/issues/2020

[eslint] Error: Unexpected token 'export'
์›น (WEB)/์—๋Ÿฌํ•ด๊ฒฐ 2020. 11. 21. 21:46

์ฐธ๊ณ  : 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",์ถ”๊ฐ€ํ•˜๊ธฐ ๋‘ ๋ฐฉ๋ฒ• ์ค‘ ํ•˜๋‚˜๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด ๋œ๋‹ค.