# ESLintμ Prettier μ€μ νκΈ°
ν νλ‘μ νΈμμ λ·°λ₯Ό κ°λ°ν λ μ½λλ₯Ό μΌκ΄μ μΌλ‘ μμ±νκ³ μλ¬λ₯Ό λ λκ² νλ λ°©λ²μ΄ μμ΅λλ€. λ°λ‘ ESLint + Prettier νλ¬κ·ΈμΈμ μ¬μ©νλ λ°©λ²μΈλ°μ. μ΄ 2κ° λꡬμ λν μμΈν μ€λͺ κ³Ό μ€μ λ°©λ²μ λ€μ κΈμ μ°Έκ³ ν©λλ€.
# ESLintμ Vue.js 곡μ μ€νμΌ κ°μ΄λλ₯Ό μ μ©νλ λ°©λ²
μ λΈλ‘κ·Έ κΈμμ μλ΄λ κ² μ΄μΈμλ Vue.js 곡μ μ€νμΌ κ°μ΄λ (opens new window)λ₯Ό ESLint λ£°μ μ μ©νμ¬ μ¬μ©νλ λ°©λ²μ΄ μμ΅λλ€.
λ¨Όμ λ·° νλ‘μ νΈμ λ£¨νΈ λλ ν 리μ μλ .eslintrc
νμΌμ extends
λ₯Ό μλμ κ°μ΄ μμ ν©λλ€.
module.exports = {
// ...
extends: [
// 'plugin:vue/essential',
'@vue/prettier',
'@vue/typescript',
'plugin:import/errors',
'plugin:import/warnings',
'plugin:vue/recommended',
],
}
κ·Έλ¦¬κ³ λμ κ°μ νμΌμ rules
μμ±μ μλμ λ΄μ©μ μΆκ°ν΄μ€λλ€.
module.exports = {
rules: {
/**********************/
/* General Code Rules */
/**********************/
// Enforce import order
'import/order': 'error',
// Imports should come first
'import/first': 'error',
// Other import rules
'import/no-mutable-exports': 'error',
// Allow unresolved imports
'import/no-unresolved': 'off',
// Allow async-await
'generator-star-spacing': 'off',
// Prefer const over let
'prefer-const': [
'error',
{
destructuring: 'any',
ignoreReadBeforeAssign: false,
},
],
// No single if in an "else" block
'no-lonely-if': 'error',
// Force curly braces for control flow,
// including if blocks with a single statement
curly: ['error', 'all'],
// No async function without await
'require-await': 'error',
// Force dot notation when possible
'dot-notation': 'error',
'no-var': 'error',
// Force object shorthand where possible
'object-shorthand': 'error',
// No useless destructuring/importing/exporting renames
'no-useless-rename': 'error',
/**********************/
/* Vue Rules */
/**********************/
// Disable template errors regarding invalid end tags
'vue/no-parsing-error': [
'error',
{
'x-invalid-end-tag': false,
},
],
// Maximum 5 attributes per line instead of one
'vue/max-attributes-per-line': [
'error',
{
singleline: 5,
},
],
/***************************/
/* ESLint Vue Plugin Rules */
/***************************/
'vue/html-indent': [
'error',
'tab',
{
attribute: 1,
baseIndent: 1,
closeBracket: 0,
alignAttributesVertically: true,
ignores: [],
},
],
'vue/order-in-components': [
'error',
{
order: [
'el',
'name',
'parent',
'functional',
['delimiters', 'comments'],
['components', 'directives', 'filters'],
'extends',
'mixins',
'inheritAttrs',
'model',
['props', 'propsData'],
'fetch',
'asyncData',
'data',
'computed',
'watch',
'LIFECYCLE_HOOKS',
'methods',
'head',
['template', 'render'],
'renderError',
],
},
],
'vue/html-self-closing': ['off'],
// https://eslint.vuejs.org/rules/attributes-order.html
// TODO: ν λ΄ κΈ°μ€μΌλ‘ μ¬μ‘°μ νμ
'vue/attributes-order': [
'error',
{
order: [
'DEFINITION',
'LIST_RENDERING',
'CONDITIONALS',
'RENDER_MODIFIERS',
'GLOBAL',
'UNIQUE',
'TWO_WAY_BINDING',
'OTHER_DIRECTIVES',
'OTHER_ATTR',
'EVENTS',
'CONTENT',
],
},
],
},
}
μ΄λ κ² μμ±ν ESLintμ κ·μΉμ΄ νλ‘μ νΈμ μ μ©λλ €λ©΄ λ·° νλ‘μ νΈμ μλμ κ°μ΄ κ΄λ ¨ λΌμ΄λΈλ¬λ¦¬κ° μ€μΉλμ΄μΌ ν©λλ€.
{
"eslint-config-standard": "^14.1.0",
"eslint-plugin-import": "^2.18.2",
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-standard": "^4.0.1",
}
# μ°Έκ³ μλ£
β Project Setup Tutorials β