2017-07-19 88 views
1

當使用Sublime Text 3時,我怎樣才能讓兩者一起工作?我怎樣才能讓漂亮和ESLint一起工作?

在保存文件時,漂亮的用雙引號替換單引號,而ESLint查找單引號。

我怎樣才能讓兩個包一起工作?

.eslintrc

{ 
     "parser": "babel-eslint", 
     "extends": "airbnb", 
     "plugins": [ 
     "react", 
     "jsx-a11y", 
     "import", 
     "prettier" 
     ], 
     "rules": { 
     "no-use-before-define": 0, 
     "no-underscore-dangle": 0, 
     "no-tabs": 0, 
     "no-nested-ternary": 0, 
     "indent": 0, 
     "no-multi-assign": 0, 
     "no-param-reassign": 0, 
     "no-var": 0, 
     "no-mixed-operators": 0, 
     "no-unused-expressions": 0, 
     "no-plusplus": 0, 
     "no-confusing-arrow": 0, 
     "no-case-declarations": 0, 
     "vars-on-top": 0, 
     "block-scoped-var": 0, 
     "global-require": 0, 
     "react/sort-comp": 0, 
     "react/forbid-prop-types": 0, 
     "react/no-unused-prop-types": 0, 
     "react/no-multi-comp": 0, 
     "react/no-array-index-key": 0, 
     "no-trailing-spaces": 0, 
     "react/jsx-filename-extension": 0, 
     "import/prefer-default-export": 0 
     }, 
     "globals": { 
     "window": true, 
     "__DEV__": true, 
     "expect": true, 
     "it": true, 
     "navigator": true, 
     "fetch": true 
     } 
    } 

回答

1

默認情況下,更漂亮配置默認使用雙引號,可能與你在拉ESLint CONFIGS衝突。

你可以讓他們通過這幾個工作方式(最推薦第一種):

1)安裝eslint-config-prettier並從.eslintrc擴展它。這樣做會關閉ESLint中可能與Prettier衝突的一些與格式相關的規則。

{ 
    "extends": [ 
    "airbnb", 
    "prettier" 
    ] 
} 

2)改變.prettierrc配置文件

{ 
    "singleQuote": true, 
    ... 
} 

3)添加,當你調用命令行選項更漂亮

$ prettier --single-quote ... 

4)您.eslintrc配置中的關閉ESLint的quotes規則文件:

{ 
    "rules": { 
    "quotes": "off", 
    ... 
    } 
} 
相關問題