ํ๋ก์ ํธ ์ค์บํด๋ฉ ์ค ์๋ง์ eslint ํ๋ฌ๊ทธ์ธ์ ๋ง์ฃผํ๊ฒ ๋ ๋..
์ผ์ผ์ด ๊ตฌ๊ธ๋งํ๋๋ผ ๊ณ ์ํ์ด์, ํน์ ๋๊ฐ์ ์ฌ๋์ด ์์๊น ์ ๋ฆฌํด๋ด!๐
ํจํค์ง๋ค์ ๋ช ๊ฐ์ง๋ก ๋ถ๋ฅํด๋์ผ๋, ์๋ ๋ถ๋ฅ๋ก ๊ฐ ํจํค์ง์ ๋๋ต์ ์ธ ์ญํ ๋ค์ ํ์ ํ์ ๋ค์ ์์ธํ ์ค์น ๊ณผ์ ์ ๊ตฌ๊ธ๋ง ํ์๋ฉด ๋ ๋ฏํฉ๋๋ค!
prettier ์ฌ์ฉ ๊ด๋ จ
prettier์ eslint๋ฅผ ํจ๊ป ์ฌ์ฉํ๊ธฐ ์ํ ํจํค์ง๋ค์ ๋๋ค. ์ฐธ๊ณ ๋ก prettier๋ ์ฝ๋ ํฌ๋งทํ ์ด ์ฃผ ๋ชฉ์ ์ด๊ณ , eslint๋ lint(์๋ฌ๋ฅผ ์ก์๋ด๋ ์ผ)๊ฐ ์ฃผ ๋ชฉ์ ์ด๊ธฐ ๋๋ฌธ์ ๋ณดํต ๋ ๊ฐ์ง๋ฅผ ํจ๊ป ์ฌ์ฉํฉ๋๋ค.
- eslint-config-prettier
- eslint-plugin-prettier
typescript ์ฌ์ฉ ๊ด๋ จ
- @typescript-eslint/eslint-plugin
- @typescript-eslint/parser
react-native ๊ด๋ จ
- eslint-plugin-react-native
- @react-native-community/eslint-config
airbnb style ์ ์ฉ ๊ด๋ จ
๋งจ ์ฒซ ๋ฒ์งธ์ ์๋ ํจํค์ง๋ฅผ ์ํด ์๋ ๋ค ๊ฐ๋ฅผ ์ค์นํ์ ์ผ ํฉ๋๋ค!
- eslint-config-airbnb
- eslint-plugin-import
- eslint-plugin-jsx-a11y
- eslint-plugin-react
- eslint-plugin-react-hooks
๊ทธ ์ธ
- eslint-import-resolver-typescript
- eslint-plugin-simple-import-sort
: import๋ฌธ์ ํน์ ๊ธฐ์ค์ ๋ฐ๋ผ ์๋์ ๋ ฌํ ์ ์๋ ํ๋ฌ๊ทธ์ธ์ ๋๋ค. .eslintrc.js ํ์ผ์์ ์ ๋ ฌ ์์๋ฅผ ์ปค์คํฐ๋ง์ด์ง ํ ์ ์์ต๋๋ค. - eslint-plugin-unused-imports
: ์ฌ์ฉ๋์ง ์์ import๋ฌธ์ ์ง์์ฃผ๋ ํ๋ฌ๊ทธ์ธ์ ๋๋ค.
.eslintrc.js
์ ํจํค์ง๋ค์ ์ฌ์ฉํ๋ฉด์ ์์ฑํ .eslintrc.js ํ์ผ์ ์ฒจ๋ถํฉ๋๋ค.
module.exports = {
root: true,
env: {
es2021: true,
node: true,
jest: true,
'react-native/react-native': true,
},
ignorePatterns: ['node_modules/', '.pnp.cjs', '.pnp.loader.mjs', '.yarn'],
plugins: [
'@typescript-eslint',
'react',
'react-native',
'simple-import-sort',
'unused-imports',
'jest',
'testing-library',
'import',
],
extends: [
'airbnb',
'@react-native-community',
'eslint:recommended',
'plugin:react/recommended',
'plugin:@typescript-eslint/recommended',
],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaFeatures: {
jsx: true,
},
ecmaVersion: 12,
sourceType: 'module',
},
overrides: [
{
files: ['*.ts', '*.tsx'],
extends: ['plugin:@typescript-eslint/eslint-recommended', 'plugin:@typescript-eslint/recommended'],
rules: {},
},
],
settings: {
'import/resolver': {
typescript: {},
},
},
rules: {
'prettier/prettier': ['error', { useTabs: false }],
'import/extensions': [
'error',
'ignorePackages',
{
js: 'never',
jsx: 'never',
ts: 'never',
tsx: 'never',
},
],
'react/jsx-filename-extension': [
'warn',
{
extensions: ['.js', '.jsx', '.ts', '.tsx'],
},
],
'no-console': [
'warn',
{
allow: ['warn', 'error'],
},
],
'import/no-unresolved': 'error',
'react/react-in-jsx-scope': 'off',
'no-use-before-define': 'off',
'@typescript-eslint/no-use-before-define': 'off',
'simple-import-sort/imports': [
'error',
{
groups: [
// Packages. `react` related packages come first.
['^react', '^@?\\w'],
// Internal packages.
['@pay-stitches', '^(@/?$)(/.*|$)'],
// Side effect imports.
['^\\u0000'],
// Parent imports. Put `..` last.
['^\\.\\.(?!/?$)', '^\\.\\./?$'],
// Other relative imports. Put same-folder imports and `.` last.
['^\\./(?=.*/)(?!/?$)', '^\\.(?!/?$)', '^\\./?$'],
],
},
],
'no-shadow': 'off',
'@typescript-eslint/no-shadow': 'error',
'simple-import-sort/exports': 'error',
'import/first': 'error',
'import/newline-after-import': 'error',
'import/no-duplicates': 'error',
'@typescript-eslint/no-unused-vars': 'off',
'unused-imports/no-unused-imports': 'error',
'unused-imports/no-unused-vars': [
'error',
{
vars: 'all',
varsIgnorePattern: '^_',
args: 'after-used',
argsIgnorePattern: '^_',
},
],
'react/require-default-props': 'off',
'react/function-component-definition': [
'warn',
{
namedComponents: 'arrow-function',
},
],
'react/jsx-props-no-spreading': ['warn', { exceptions: ['Button', 'AppComponent'] }],
'import/order': 'off',
},
};
'React' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
Yarn Berry ์ ์ฉ ์๋๋ ๋ฌธ์ ํด๊ฒฐ (0) | 2022.10.21 |
---|---|
ํ๋ก์ ํธ ์ค์บํด๋ฉ ๊ธฐ๋ก ๐ธ (0) | 2022.10.18 |
Yarn Berry๋ก React Native ํ๋ก์ ํธ ์์ํ๊ธฐ (0) | 2022.10.12 |
๋ชจ๋ํ์ ๊ฐ๋ ๋ถํฐ Yarn Berry๊น์ง (0) | 2022.10.10 |
npm, yarn, pnpm์ ์ฐจ์ด์ ์ ๋น๊ตํด๋ณด์ (0) | 2022.09.26 |